OGR
ogr_core.h
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id: ogr_core.h 23947 2012-02-11 17:37:02Z rouault $
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 #ifndef OGR_CORE_H_INCLUDED
31 #define OGR_CORE_H_INCLUDED
32 
33 #include "cpl_port.h"
34 #include "gdal_version.h"
35 
46 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
47 class CPL_DLL OGREnvelope
48 {
49  public:
50  OGREnvelope() : MinX(0.0), MaxX(0.0), MinY(0.0), MaxY(0.0)
51  {
52  }
53 
54  OGREnvelope(const OGREnvelope& oOther) :
55  MinX(oOther.MinX),MaxX(oOther.MaxX), MinY(oOther.MinY), MaxY(oOther.MaxY)
56  {
57  }
58 
59  double MinX;
60  double MaxX;
61  double MinY;
62  double MaxY;
63 
64  int IsInit() const { return MinX != 0 || MinY != 0 || MaxX != 0 || MaxY != 0; }
65  void Merge( OGREnvelope const& sOther ) {
66  if( IsInit() )
67  {
68  MinX = MIN(MinX,sOther.MinX);
69  MaxX = MAX(MaxX,sOther.MaxX);
70  MinY = MIN(MinY,sOther.MinY);
71  MaxY = MAX(MaxY,sOther.MaxY);
72  }
73  else
74  {
75  MinX = sOther.MinX;
76  MaxX = sOther.MaxX;
77  MinY = sOther.MinY;
78  MaxY = sOther.MaxY;
79  }
80  }
81  void Merge( double dfX, double dfY ) {
82  if( IsInit() )
83  {
84  MinX = MIN(MinX,dfX);
85  MaxX = MAX(MaxX,dfX);
86  MinY = MIN(MinY,dfY);
87  MaxY = MAX(MaxY,dfY);
88  }
89  else
90  {
91  MinX = MaxX = dfX;
92  MinY = MaxY = dfY;
93  }
94  }
95 
96  void Intersect( OGREnvelope const& sOther ) {
97  if(Intersects(sOther))
98  {
99  if( IsInit() )
100  {
101  MinX = MAX(MinX,sOther.MinX);
102  MaxX = MIN(MaxX,sOther.MaxX);
103  MinY = MAX(MinY,sOther.MinY);
104  MaxY = MIN(MaxY,sOther.MaxY);
105  }
106  else
107  {
108  MinX = sOther.MinX;
109  MaxX = sOther.MaxX;
110  MinY = sOther.MinY;
111  MaxY = sOther.MaxY;
112  }
113  }
114  else
115  {
116  MinX = 0;
117  MaxX = 0;
118  MinY = 0;
119  MaxY = 0;
120  }
121  }
122 
123  int Intersects(OGREnvelope const& other) const
124  {
125  return MinX <= other.MaxX && MaxX >= other.MinX &&
126  MinY <= other.MaxY && MaxY >= other.MinY;
127  }
128 
129  int Contains(OGREnvelope const& other) const
130  {
131  return MinX <= other.MinX && MinY <= other.MinY &&
132  MaxX >= other.MaxX && MaxY >= other.MaxY;
133  }
134 };
135 #else
136 typedef struct
137 {
138  double MinX;
139  double MaxX;
140  double MinY;
141  double MaxY;
142 } OGREnvelope;
143 #endif
144 
145 
150 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
151 class CPL_DLL OGREnvelope3D : public OGREnvelope
152 {
153  public:
154  OGREnvelope3D() : OGREnvelope(), MinZ(0.0), MaxZ(0.0)
155  {
156  }
157 
158  OGREnvelope3D(const OGREnvelope3D& oOther) :
159  OGREnvelope(oOther),
160  MinZ(oOther.MinZ), MaxZ(oOther.MaxZ)
161  {
162  }
163 
164  double MinZ;
165  double MaxZ;
166 
167  int IsInit() const { return MinX != 0 || MinY != 0 || MaxX != 0 || MaxY != 0 || MinZ != 0 || MaxZ != 0; }
168  void Merge( OGREnvelope3D const& sOther ) {
169  if( IsInit() )
170  {
171  MinX = MIN(MinX,sOther.MinX);
172  MaxX = MAX(MaxX,sOther.MaxX);
173  MinY = MIN(MinY,sOther.MinY);
174  MaxY = MAX(MaxY,sOther.MaxY);
175  MinZ = MIN(MinZ,sOther.MinZ);
176  MaxZ = MAX(MaxZ,sOther.MaxZ);
177  }
178  else
179  {
180  MinX = sOther.MinX;
181  MaxX = sOther.MaxX;
182  MinY = sOther.MinY;
183  MaxY = sOther.MaxY;
184  MinZ = sOther.MinZ;
185  MaxZ = sOther.MaxZ;
186  }
187  }
188  void Merge( double dfX, double dfY, double dfZ ) {
189  if( IsInit() )
190  {
191  MinX = MIN(MinX,dfX);
192  MaxX = MAX(MaxX,dfX);
193  MinY = MIN(MinY,dfY);
194  MaxY = MAX(MaxY,dfY);
195  MinZ = MIN(MinZ,dfZ);
196  MaxZ = MAX(MaxZ,dfZ);
197  }
198  else
199  {
200  MinX = MaxX = dfX;
201  MinY = MaxY = dfY;
202  MinZ = MaxZ = dfZ;
203  }
204  }
205 
206  void Intersect( OGREnvelope3D const& sOther ) {
207  if(Intersects(sOther))
208  {
209  if( IsInit() )
210  {
211  MinX = MAX(MinX,sOther.MinX);
212  MaxX = MIN(MaxX,sOther.MaxX);
213  MinY = MAX(MinY,sOther.MinY);
214  MaxY = MIN(MaxY,sOther.MaxY);
215  MinZ = MAX(MinZ,sOther.MinZ);
216  MaxZ = MIN(MaxZ,sOther.MaxZ);
217  }
218  else
219  {
220  MinX = sOther.MinX;
221  MaxX = sOther.MaxX;
222  MinY = sOther.MinY;
223  MaxY = sOther.MaxY;
224  MinZ = sOther.MinZ;
225  MaxZ = sOther.MaxZ;
226  }
227  }
228  else
229  {
230  MinX = 0;
231  MaxX = 0;
232  MinY = 0;
233  MaxY = 0;
234  MinZ = 0;
235  MaxZ = 0;
236  }
237  }
238 
239  int Intersects(OGREnvelope3D const& other) const
240  {
241  return MinX <= other.MaxX && MaxX >= other.MinX &&
242  MinY <= other.MaxY && MaxY >= other.MinY &&
243  MinZ <= other.MaxZ && MaxZ >= other.MinZ;
244  }
245 
246  int Contains(OGREnvelope3D const& other) const
247  {
248  return MinX <= other.MinX && MinY <= other.MinY &&
249  MaxX >= other.MaxX && MaxY >= other.MaxY &&
250  MaxZ >= other.MaxZ && MaxZ >= other.MaxZ;
251  }
252 };
253 #else
254 typedef struct
255 {
256  double MinX;
257  double MaxX;
258  double MinY;
259  double MaxY;
260  double MinZ;
261  double MaxZ;
262 } OGREnvelope3D;
263 #endif
264 
265 
266 CPL_C_START
267 
268 void CPL_DLL *OGRMalloc( size_t );
269 void CPL_DLL *OGRCalloc( size_t, size_t );
270 void CPL_DLL *OGRRealloc( void *, size_t );
271 char CPL_DLL *OGRStrdup( const char * );
272 void CPL_DLL OGRFree( void * );
273 
274 typedef int OGRErr;
275 
276 #define OGRERR_NONE 0
277 #define OGRERR_NOT_ENOUGH_DATA 1 /* not enough data to deserialize */
278 #define OGRERR_NOT_ENOUGH_MEMORY 2
279 #define OGRERR_UNSUPPORTED_GEOMETRY_TYPE 3
280 #define OGRERR_UNSUPPORTED_OPERATION 4
281 #define OGRERR_CORRUPT_DATA 5
282 #define OGRERR_FAILURE 6
283 #define OGRERR_UNSUPPORTED_SRS 7
284 #define OGRERR_INVALID_HANDLE 8
285 
286 typedef int OGRBoolean;
287 
288 /* -------------------------------------------------------------------- */
289 /* ogr_geometry.h related definitions. */
290 /* -------------------------------------------------------------------- */
297 typedef enum
298 {
300  wkbPoint = 1,
311  wkbNone = 100,
313  wkbPoint25D = 0x80000001,
314  wkbLineString25D = 0x80000002,
315  wkbPolygon25D = 0x80000003,
316  wkbMultiPoint25D = 0x80000004,
317  wkbMultiLineString25D = 0x80000005,
318  wkbMultiPolygon25D = 0x80000006,
321 
322 #define wkb25DBit 0x80000000
323 #define wkbFlatten(x) ((OGRwkbGeometryType) ((x) & (~wkb25DBit)))
324 
325 #define ogrZMarker 0x21125711
326 
327 const char CPL_DLL * OGRGeometryTypeToName( OGRwkbGeometryType eType );
329  OGRwkbGeometryType eExtra );
330 
331 typedef enum
332 {
333  wkbXDR = 0, /* MSB/Sun/Motoroloa: Most Significant Byte First */
334  wkbNDR = 1 /* LSB/Intel/Vax: Least Significant Byte First */
335 } OGRwkbByteOrder;
336 
337 #ifndef NO_HACK_FOR_IBM_DB2_V72
338 # define HACK_FOR_IBM_DB2_V72
339 #endif
340 
341 #ifdef HACK_FOR_IBM_DB2_V72
342 # define DB2_V72_FIX_BYTE_ORDER(x) ((((x) & 0x31) == (x)) ? (OGRwkbByteOrder) ((x) & 0x1) : (x))
343 # define DB2_V72_UNFIX_BYTE_ORDER(x) ((unsigned char) (OGRGeometry::bGenerate_DB2_V72_BYTE_ORDER ? ((x) | 0x30) : (x)))
344 #else
345 # define DB2_V72_FIX_BYTE_ORDER(x) (x)
346 # define DB2_V72_UNFIX_BYTE_ORDER(x) (x)
347 #endif
348 
349 #define ALTER_NAME_FLAG 0x1
350 #define ALTER_TYPE_FLAG 0x2
351 #define ALTER_WIDTH_PRECISION_FLAG 0x4
352 #define ALTER_ALL_FLAG (ALTER_NAME_FLAG | ALTER_TYPE_FLAG | ALTER_WIDTH_PRECISION_FLAG)
353 
354 /************************************************************************/
355 /* ogr_feature.h related definitions. */
356 /************************************************************************/
357 
364 typedef enum
378  OFTMaxType = 11
379 } OGRFieldType;
380 
385 typedef enum
386 {
387  OJUndefined = 0,
388  OJLeft = 1,
389  OJRight = 2
391 
392 #define OGRNullFID -1
393 #define OGRUnsetMarker -21121
394 
395 /************************************************************************/
396 /* OGRField */
397 /************************************************************************/
398 
403 typedef union {
404  int Integer;
405  double Real;
406  char *String;
407 
408  struct {
409  int nCount;
410  int *paList;
411  } IntegerList;
412 
413  struct {
414  int nCount;
415  double *paList;
416  } RealList;
417 
418  struct {
419  int nCount;
420  char **paList;
421  } StringList;
422 
423  struct {
424  int nCount;
425  GByte *paData;
426  } Binary;
427 
428  struct {
429  int nMarker1;
430  int nMarker2;
431  } Set;
432 
433  struct {
434  GInt16 Year;
435  GByte Month;
436  GByte Day;
437  GByte Hour;
438  GByte Minute;
439  GByte Second;
440  GByte TZFlag; /* 0=unknown, 1=localtime(ambiguous),
441  100=GMT, 104=GMT+1, 80=GMT-5, etc */
442  } Date;
443 } OGRField;
444 
445 int CPL_DLL OGRParseDate( const char *pszInput, OGRField *psOutput,
446  int nOptions );
447 
448 /* -------------------------------------------------------------------- */
449 /* Constants from ogrsf_frmts.h for capabilities. */
450 /* -------------------------------------------------------------------- */
451 #define OLCRandomRead "RandomRead"
452 #define OLCSequentialWrite "SequentialWrite"
453 #define OLCRandomWrite "RandomWrite"
454 #define OLCFastSpatialFilter "FastSpatialFilter"
455 #define OLCFastFeatureCount "FastFeatureCount"
456 #define OLCFastGetExtent "FastGetExtent"
457 #define OLCCreateField "CreateField"
458 #define OLCDeleteField "DeleteField"
459 #define OLCReorderFields "ReorderFields"
460 #define OLCAlterFieldDefn "AlterFieldDefn"
461 #define OLCTransactions "Transactions"
462 #define OLCDeleteFeature "DeleteFeature"
463 #define OLCFastSetNextByIndex "FastSetNextByIndex"
464 #define OLCStringsAsUTF8 "StringsAsUTF8"
465 #define OLCIgnoreFields "IgnoreFields"
466 
467 #define ODsCCreateLayer "CreateLayer"
468 #define ODsCDeleteLayer "DeleteLayer"
469 
470 #define ODrCCreateDataSource "CreateDataSource"
471 #define ODrCDeleteDataSource "DeleteDataSource"
472 
473 
474 /************************************************************************/
475 /* ogr_featurestyle.h related definitions. */
476 /************************************************************************/
477 
483 {
484  OGRSTCNone = 0,
485  OGRSTCPen = 1,
486  OGRSTCBrush = 2,
487  OGRSTCSymbol = 3,
488  OGRSTCLabel = 4,
489  OGRSTCVector = 5
490 } OGRSTClassId;
491 
496 {
497  OGRSTUGround = 0,
498  OGRSTUPixel = 1,
499  OGRSTUPoints = 2,
500  OGRSTUMM = 3,
501  OGRSTUCM = 4,
502  OGRSTUInches = 5
503 } OGRSTUnitId;
504 
509 {
510  OGRSTPenColor = 0,
511  OGRSTPenWidth = 1,
512  OGRSTPenPattern = 2,
513  OGRSTPenId = 3,
514  OGRSTPenPerOffset = 4,
515  OGRSTPenCap = 5,
516  OGRSTPenJoin = 6,
517  OGRSTPenPriority = 7,
518  OGRSTPenLast = 8
519 
520 } OGRSTPenParam;
521 
526 {
527  OGRSTBrushFColor = 0,
528  OGRSTBrushBColor = 1,
529  OGRSTBrushId = 2,
530  OGRSTBrushAngle = 3,
531  OGRSTBrushSize = 4,
532  OGRSTBrushDx = 5,
533  OGRSTBrushDy = 6,
534  OGRSTBrushPriority = 7,
535  OGRSTBrushLast = 8
536 
538 
539 
544 {
545  OGRSTSymbolId = 0,
546  OGRSTSymbolAngle = 1,
547  OGRSTSymbolColor = 2,
548  OGRSTSymbolSize = 3,
549  OGRSTSymbolDx = 4,
550  OGRSTSymbolDy = 5,
551  OGRSTSymbolStep = 6,
552  OGRSTSymbolPerp = 7,
553  OGRSTSymbolOffset = 8,
554  OGRSTSymbolPriority = 9,
555  OGRSTSymbolFontName = 10,
556  OGRSTSymbolOColor = 11,
557  OGRSTSymbolLast = 12
558 
560 
565 {
566  OGRSTLabelFontName = 0,
567  OGRSTLabelSize = 1,
568  OGRSTLabelTextString = 2,
569  OGRSTLabelAngle = 3,
570  OGRSTLabelFColor = 4,
571  OGRSTLabelBColor = 5,
572  OGRSTLabelPlacement = 6,
573  OGRSTLabelAnchor = 7,
574  OGRSTLabelDx = 8,
575  OGRSTLabelDy = 9,
576  OGRSTLabelPerp = 10,
577  OGRSTLabelBold = 11,
578  OGRSTLabelItalic = 12,
579  OGRSTLabelUnderline = 13,
580  OGRSTLabelPriority = 14,
581  OGRSTLabelStrikeout = 15,
582  OGRSTLabelStretch = 16,
583  OGRSTLabelAdjHor = 17,
584  OGRSTLabelAdjVert = 18,
585  OGRSTLabelHColor = 19,
586  OGRSTLabelOColor = 20,
587  OGRSTLabelLast = 21
588 
590 
591 /* ------------------------------------------------------------------- */
592 /* Version checking */
593 /* -------------------------------------------------------------------- */
594 
595 /* Note to developers : please keep this section in sync with gdal.h */
596 
597 #ifndef GDAL_VERSION_INFO_DEFINED
598 #define GDAL_VERSION_INFO_DEFINED
599 const char CPL_DLL * CPL_STDCALL GDALVersionInfo( const char * );
600 #endif
601 
602 #ifndef GDAL_CHECK_VERSION
603 
615 int CPL_DLL CPL_STDCALL GDALCheckVersion( int nVersionMajor, int nVersionMinor,
616  const char* pszCallingComponentName);
617 
619 #define GDAL_CHECK_VERSION(pszCallingComponentName) \
620  GDALCheckVersion(GDAL_VERSION_MAJOR, GDAL_VERSION_MINOR, pszCallingComponentName)
621 
622 #endif
623 
624 CPL_C_END
625 
626 #endif /* ndef OGR_CORE_H_INCLUDED */
Definition: ogr_core.h:311
enum ogr_style_tool_param_symbol_id OGRSTSymbolParam
ogr_style_tool_param_label_id
Definition: ogr_core.h:564
Definition: ogr_core.h:318
Definition: ogr_core.h:317
Definition: ogr_core.h:303
Definition: ogr_core.h:376
Definition: ogr_core.h:312
Definition: ogr_core.h:375
enum ogr_style_tool_param_brush_id OGRSTBrushParam
Definition: ogr_core.h:314
enum ogr_style_tool_param_label_id OGRSTLabelParam
ogr_style_tool_param_pen_id
Definition: ogr_core.h:508
Definition: ogr_core.h:369
ogr_style_tool_param_symbol_id
Definition: ogr_core.h:543
Definition: ogr_core.h:309
Definition: ogr_core.h:301
Definition: ogr_core.h:368
Definition: ogr_core.h:299
Definition: ogr_core.h:319
Definition: ogr_core.h:306
enum ogr_style_tool_class_id OGRSTClassId
Definition: ogr_core.h:374
Definition: ogr_core.h:316
enum ogr_style_tool_param_pen_id OGRSTPenParam
enum ogr_style_tool_units_id OGRSTUnitId
OGRwkbGeometryType
Definition: ogr_core.h:297
OGRwkbGeometryType OGRMergeGeometryTypes(OGRwkbGeometryType eMain, OGRwkbGeometryType eExtra)
Find common geometry type.
Definition: ogrgeometry.cpp:1705
Definition: ogr_core.h:315
Definition: ogr_core.h:307
OGRJustification
Definition: ogr_core.h:385
ogr_style_tool_units_id
Definition: ogr_core.h:495
Definition: ogr_core.h:373
Definition: ogr_core.h:300
OGRFieldType
Definition: ogr_core.h:364
Definition: ogr_core.h:377
Definition: ogr_core.h:151
int CPL_STDCALL GDALCheckVersion(int nVersionMajor, int nVersionMinor, const char *pszCallingComponentName)
Definition: ogr_core.h:372
ogr_style_tool_param_brush_id
Definition: ogr_core.h:525
Definition: ogr_core.h:47
Definition: ogr_core.h:403
ogr_style_tool_class_id
Definition: ogr_core.h:482
Definition: ogr_core.h:308
Definition: ogr_core.h:370
Definition: ogr_core.h:313
const char * OGRGeometryTypeToName(OGRwkbGeometryType eType)
Fetch a human readable name corresponding to an OGRwkBGeometryType value. The returned value should n...
Definition: ogrgeometry.cpp:1609
int OGRParseDate(const char *pszInput, OGRField *psOutput, int nOptions)
Definition: ogrutils.cpp:812
Definition: ogr_core.h:371
Definition: ogr_core.h:367
Definition: ogr_core.h:366

Generated for GDAL by doxygen 1.8.8.