Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libjni-gdal / include / ogr_core.h @ 5557

History | View | Annotate | Download (10.3 KB)

1 716 igbrotru
/******************************************************************************
2
 * $Id$
3
 *
4
 * Project:  OpenGIS Simple Features Reference Implementation
5
 * Purpose:  Define some core portability services for cross-platform OGR code.
6
 * Author:   Frank Warmerdam, warmerdam@pobox.com
7
 *
8
 ******************************************************************************
9
 * Copyright (c) 1999, Frank Warmerdam
10
 *
11
 * Permission is hereby granted, free of charge, to any person obtaining a
12
 * copy of this software and associated documentation files (the "Software"),
13
 * to deal in the Software without restriction, including without limitation
14
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15
 * and/or sell copies of the Software, and to permit persons to whom the
16
 * Software is furnished to do so, subject to the following conditions:
17
 *
18
 * The above copyright notice and this permission notice shall be included
19
 * in all copies or substantial portions of the Software.
20
 *
21
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27
 * DEALINGS IN THE SOFTWARE.
28
 ******************************************************************************
29
 *
30
 * $Log$
31 3540 nacho
 * Revision 1.2  2006-01-09 12:50:13  nacho
32 716 igbrotru
 * *** empty log message ***
33
 *
34 3540 nacho
 * Revision 1.1  2005/07/27 08:22:55  igbrotru
35
 * *** empty log message ***
36
 *
37
 * Revision 1.1  2004/12/28 14:06:59  igbrotru
38
 * *** empty log message ***
39
 *
40 716 igbrotru
 * Revision 1.1  2004/12/28 13:32:25  igbrotru
41
 * *** empty log message ***
42
 *
43
 * Revision 1.24  2003/10/09 15:27:41  warmerda
44
 * added OGRLayer::DeleteFeature() support
45
 *
46
 * Revision 1.23  2003/09/11 19:59:41  warmerda
47
 * avoid casting issue with UNFIX macro
48
 *
49
 * Revision 1.22  2003/08/27 15:40:37  warmerda
50
 * added support for generating DB2 V7.2 compatible WKB
51
 *
52
 * Revision 1.21  2003/08/11 03:28:04  warmerda
53
 * Export OGREnvelope C++ class with CPL_DLL as per bug 378.
54
 *
55
 * Revision 1.20  2003/06/09 13:48:54  warmerda
56
 * added DB2 V7.2 byte order hack
57
 *
58
 * Revision 1.19  2003/05/08 13:27:22  warmerda
59
 * dont use C++ comments in this c includable file
60
 *
61
 * Revision 1.18  2003/04/29 19:03:58  warmerda
62
 * removed extra comma
63
 *
64
 * Revision 1.17  2003/03/03 05:05:54  warmerda
65
 * added support for DeleteDataSource and DeleteLayer
66
 *
67
 * Revision 1.16  2003/02/19 02:57:49  warmerda
68
 * added wkbLinearRing support
69
 *
70
 * Revision 1.15  2003/01/14 20:08:49  warmerda
71
 * fixed another bug in OGREnvelope.Merge
72
 *
73
 * Revision 1.14  2003/01/07 17:51:55  warmerda
74
 * fixed OGREnvelope.Merge()
75
 *
76
 * Revision 1.13  2003/01/06 17:56:03  warmerda
77
 * Added Merge and IsInit() method on OGREnvelope
78
 *
79
 * Revision 1.12  2002/11/08 18:25:45  warmerda
80
 * remove extranious comma in enum, confuses HPUX compiler
81
 *
82
 * Revision 1.11  2002/11/08 15:42:41  warmerda
83
 * ensure type correctness of wkbFlatten
84
 *
85
 * Revision 1.10  2002/10/24 20:53:02  warmerda
86
 * expand tabs
87
 *
88
 * Revision 1.9  2002/09/26 18:13:17  warmerda
89
 * moved some defs to ogr_core.h for sharing with ogr_api.h
90
 *
91
 * Revision 1.8  2000/07/11 20:15:12  warmerda
92
 * apply CPL_DLL to OGR functions
93
 *
94
 * Revision 1.7  2000/07/09 20:47:35  warmerda
95
 * added CPL_START/END
96
 *
97
 * Revision 1.6  1999/11/18 19:02:19  warmerda
98
 * expanded tabs
99
 *
100
 * Revision 1.5  1999/07/07 04:23:07  danmo
101
 * Fixed typo in  #define _OGR_..._H_INCLUDED  line
102
 *
103
 * Revision 1.4  1999/07/05 18:56:52  warmerda
104
 * now includes cpl_port.h
105
 *
106
 * Revision 1.3  1999/07/05 17:19:03  warmerda
107
 * added OGRERR_UNSUPPORTED_SRS
108
 *
109
 * Revision 1.2  1999/05/31 15:00:37  warmerda
110
 * added generic OGRERR_FAILURE error code.
111
 *
112
 * Revision 1.1  1999/05/20 14:35:00  warmerda
113
 * New
114
 *
115
 */
116
117
#ifndef _OGR_CORE_H_INCLUDED
118
#define _OGR_CORE_H_INCLUDED
119
120
#include "cpl_port.h"
121
122
/**
123
 * Simple container for a bounding region.
124
 */
125
126
#ifdef __cplusplus
127
class CPL_DLL OGREnvelope
128
{
129
  public:
130
        OGREnvelope()
131
        {
132
                MinX = MaxX = MinY = MaxY = 0;
133
        }
134
    double      MinX;
135
    double      MaxX;
136
    double      MinY;
137
    double      MaxY;
138
139
    int  IsInit() { return MinX != 0 || MinY != 0 || MaxX != 0 || MaxY != 0; }
140
    void Merge( OGREnvelope & sOther ) {
141
        if( IsInit() )
142
        {
143
            MinX = MIN(MinX,sOther.MinX);
144
            MaxX = MAX(MaxX,sOther.MaxX);
145
            MinY = MIN(MinY,sOther.MinY);
146
            MaxY = MAX(MaxY,sOther.MaxY);
147
        }
148
        else
149
        {
150
            MinX = sOther.MinX;
151
            MaxX = sOther.MaxX;
152
            MinY = sOther.MinY;
153
            MaxY = sOther.MaxY;
154
        }
155
    }
156
};
157
#else
158
typedef struct
159
{
160
    double      MinX;
161
    double      MaxX;
162
    double      MinY;
163
    double      MaxY;
164
} OGREnvelope;
165
#endif
166
167
CPL_C_START
168
169
void CPL_DLL *OGRMalloc( size_t );
170
void CPL_DLL *OGRCalloc( size_t, size_t );
171
void CPL_DLL *OGRRealloc( void *, size_t );
172
char CPL_DLL *OGRStrdup( const char * );
173
void CPL_DLL OGRFree( void * );
174
175
typedef int OGRErr;
176
177
#define OGRERR_NONE                0
178
#define OGRERR_NOT_ENOUGH_DATA     1    /* not enough data to deserialize */
179
#define OGRERR_NOT_ENOUGH_MEMORY   2
180
#define OGRERR_UNSUPPORTED_GEOMETRY_TYPE 3
181
#define OGRERR_UNSUPPORTED_OPERATION 4
182
#define OGRERR_CORRUPT_DATA        5
183
#define OGRERR_FAILURE             6
184
#define OGRERR_UNSUPPORTED_SRS     7
185
186
typedef int     OGRBoolean;
187
188
/* -------------------------------------------------------------------- */
189
/*      ogr_geometry.h related definitions.                             */
190
/* -------------------------------------------------------------------- */
191
/**
192
 * List of well known binary geometry types.  These are used within the BLOBs
193
 * but are also returned from OGRGeometry::getGeometryType() to identify the
194
 * type of a geometry object.
195
 */
196
197
typedef enum
198
{
199
    wkbUnknown = 0,             /* non-standard */
200
    wkbPoint = 1,               /* rest are standard WKB type codes */
201
    wkbLineString = 2,
202
    wkbPolygon = 3,
203
    wkbMultiPoint = 4,
204
    wkbMultiLineString = 5,
205
    wkbMultiPolygon = 6,
206
    wkbGeometryCollection = 7,
207
    wkbNone = 100,              /* non-standard, for pure attribute records */
208
    wkbLinearRing = 101,        /* non-standard, just for createGeometry() */
209
    wkbPoint25D = 0x80000001,   /* 2.5D extensions as per 99-402 */
210
    wkbLineString25D = 0x80000002,
211
    wkbPolygon25D = 0x80000003,
212
    wkbMultiPoint25D = 0x80000004,
213
    wkbMultiLineString25D = 0x80000005,
214
    wkbMultiPolygon25D = 0x80000006,
215
    wkbGeometryCollection25D = 0x80000007
216
} OGRwkbGeometryType;
217
218
#define wkb25DBit 0x80000000
219
#define wkbFlatten(x)  ((OGRwkbGeometryType) ((x) & (~wkb25DBit)))
220
221
#define ogrZMarker 0x21125711
222
223
const char CPL_DLL * OGRGeometryTypeToName( OGRwkbGeometryType eType );
224
225
typedef enum
226
{
227
    wkbXDR = 0,         /* MSB/Sun/Motoroloa: Most Significant Byte First   */
228
    wkbNDR = 1          /* LSB/Intel/Vax: Least Significant Byte First      */
229
} OGRwkbByteOrder;
230
231
#ifndef NO_HACK_FOR_IBM_DB2_V72
232
#  define HACK_FOR_IBM_DB2_V72
233
#endif
234
235
#ifdef HACK_FOR_IBM_DB2_V72
236
#  define DB2_V72_FIX_BYTE_ORDER(x) ((((x) & 0x31) == (x)) ? (OGRwkbByteOrder) ((x) & 0x1) : (x))
237
#  define DB2_V72_UNFIX_BYTE_ORDER(x) ((unsigned char) (OGRGeometry::bGenerate_DB2_V72_BYTE_ORDER ? ((x) | 0x30) : (x)))
238
#else
239
#  define DB2_V72_FIX_BYTE_ORDER(x) (x)
240
#  define DB2_V72_UNFIX_BYTE_ORDER(x) (x)
241
#endif
242
243
/************************************************************************/
244
/*                  ogr_feature.h related definitions.                  */
245
/************************************************************************/
246
247
/**
248
 * List of feature field types.  This list is likely to be extended in the
249
 * future ... avoid coding applications based on the assumption that all
250
 * field types can be known.
251
 */
252
253
typedef enum
254
{
255
  /** Simple 32bit integer */                   OFTInteger = 0,
256
  /** List of 32bit integers */                 OFTIntegerList = 1,
257
  /** Double Precision floating point */        OFTReal = 2,
258
  /** List of doubles */                        OFTRealList = 3,
259
  /** String of ASCII chars */                  OFTString = 4,
260
  /** Array of strings */                       OFTStringList = 5,
261
  /** Double byte string (unsupported) */       OFTWideString = 6,
262
  /** List of wide strings (unsupported) */     OFTWideStringList = 7,
263
  /** Raw Binary data (unsupported) */          OFTBinary = 8
264
} OGRFieldType;
265
266
/**
267
 * Display justification for field values.
268
 */
269
270
typedef enum
271
{
272
    OJUndefined = 0,
273
    OJLeft = 1,
274
    OJRight = 2
275
} OGRJustification;
276
277
#define OGRNullFID            -1
278
#define OGRUnsetMarker        -21121
279
280
/************************************************************************/
281
/*                               OGRField                               */
282
/************************************************************************/
283
284
/**
285
 * OGRFeature field attribute value union.
286
 */
287
288
typedef union {
289
    int         Integer;
290
    double      Real;
291
    char       *String;
292
    /* wchar    *WideString; */
293
294
    struct {
295
        int     nCount;
296
        int     *paList;
297
    } IntegerList;
298
299
    struct {
300
        int     nCount;
301
        double  *paList;
302
    } RealList;
303
304
    struct {
305
        int     nCount;
306
        char    **paList;
307
    } StringList;
308
309
    /*
310
    union {
311
        int   nCount;
312
        wchar *paList;
313
    } WideStringList;
314
    */
315
316
    struct {
317
        int     nMarker1;
318
        int     nMarker2;
319
    } Set;
320
} OGRField;
321
322
/* -------------------------------------------------------------------- */
323
/*      Constants from ogrsf_frmts.h for capabilities.                  */
324
/* -------------------------------------------------------------------- */
325
#define OLCRandomRead          "RandomRead"
326
#define OLCSequentialWrite     "SequentialWrite"
327
#define OLCRandomWrite         "RandomWrite"
328
#define OLCFastSpatialFilter   "FastSpatialFilter"
329
#define OLCFastFeatureCount    "FastFeatureCount"
330
#define OLCFastGetExtent       "FastGetExtent"
331
#define OLCCreateField         "CreateField"
332
#define OLCTransactions        "Transactions"
333
#define OLCDeleteFeature       "DeleteFeature"
334
335
#define ODsCCreateLayer        "CreateLayer"
336
#define ODsCDeleteLayer        "DeleteLayer"
337
338
#define ODrCCreateDataSource   "CreateDataSource"
339
#define ODrCDeleteDataSource   "DeleteDataSource"
340
341
CPL_C_END
342
343
#endif /* ndef _OGR_CORE_H_INCLUDED */