OGR
ogr_core.h
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id: ogr_core.h 27792 2014-10-04 09:02:06Z 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  * Copyright (c) 2007-2014, Even Rouault <even dot rouault at mines-paris dot org>
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a
13  * copy of this software and associated documentation files (the "Software"),
14  * to deal in the Software without restriction, including without limitation
15  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16  * and/or sell copies of the Software, and to permit persons to whom the
17  * Software is furnished to do so, subject to the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be included
20  * in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28  * DEALINGS IN THE SOFTWARE.
29  ****************************************************************************/
30 
31 #ifndef OGR_CORE_H_INCLUDED
32 #define OGR_CORE_H_INCLUDED
33 
34 #include "cpl_port.h"
35 #include "gdal_version.h"
36 
47 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
48 class CPL_DLL OGREnvelope
49 {
50  public:
51  OGREnvelope() : MinX(0.0), MaxX(0.0), MinY(0.0), MaxY(0.0)
52  {
53  }
54 
55  OGREnvelope(const OGREnvelope& oOther) :
56  MinX(oOther.MinX),MaxX(oOther.MaxX), MinY(oOther.MinY), MaxY(oOther.MaxY)
57  {
58  }
59 
60  double MinX;
61  double MaxX;
62  double MinY;
63  double MaxY;
64 
65 /* See http://trac.osgeo.org/gdal/ticket/5299 for details on this pragma */
66 #if ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(_MSC_VER))
67 #pragma GCC diagnostic push
68 #pragma GCC diagnostic ignored "-Wfloat-equal"
69 #endif
70  int IsInit() const { return MinX != 0 || MinY != 0 || MaxX != 0 || MaxY != 0; }
71 
72 #if ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(_MSC_VER))
73 #pragma GCC diagnostic pop
74 #endif
75 
76  void Merge( OGREnvelope const& sOther ) {
77  if( IsInit() )
78  {
79  MinX = MIN(MinX,sOther.MinX);
80  MaxX = MAX(MaxX,sOther.MaxX);
81  MinY = MIN(MinY,sOther.MinY);
82  MaxY = MAX(MaxY,sOther.MaxY);
83  }
84  else
85  {
86  MinX = sOther.MinX;
87  MaxX = sOther.MaxX;
88  MinY = sOther.MinY;
89  MaxY = sOther.MaxY;
90  }
91  }
92  void Merge( double dfX, double dfY ) {
93  if( IsInit() )
94  {
95  MinX = MIN(MinX,dfX);
96  MaxX = MAX(MaxX,dfX);
97  MinY = MIN(MinY,dfY);
98  MaxY = MAX(MaxY,dfY);
99  }
100  else
101  {
102  MinX = MaxX = dfX;
103  MinY = MaxY = dfY;
104  }
105  }
106 
107  void Intersect( OGREnvelope const& sOther ) {
108  if(Intersects(sOther))
109  {
110  if( IsInit() )
111  {
112  MinX = MAX(MinX,sOther.MinX);
113  MaxX = MIN(MaxX,sOther.MaxX);
114  MinY = MAX(MinY,sOther.MinY);
115  MaxY = MIN(MaxY,sOther.MaxY);
116  }
117  else
118  {
119  MinX = sOther.MinX;
120  MaxX = sOther.MaxX;
121  MinY = sOther.MinY;
122  MaxY = sOther.MaxY;
123  }
124  }
125  else
126  {
127  MinX = 0;
128  MaxX = 0;
129  MinY = 0;
130  MaxY = 0;
131  }
132  }
133 
134  int Intersects(OGREnvelope const& other) const
135  {
136  return MinX <= other.MaxX && MaxX >= other.MinX &&
137  MinY <= other.MaxY && MaxY >= other.MinY;
138  }
139 
140  int Contains(OGREnvelope const& other) const
141  {
142  return MinX <= other.MinX && MinY <= other.MinY &&
143  MaxX >= other.MaxX && MaxY >= other.MaxY;
144  }
145 };
146 #else
147 typedef struct
148 {
149  double MinX;
150  double MaxX;
151  double MinY;
152  double MaxY;
153 } OGREnvelope;
154 #endif
155 
156 
161 #if defined(__cplusplus) && !defined(CPL_SURESS_CPLUSPLUS)
162 class CPL_DLL OGREnvelope3D : public OGREnvelope
163 {
164  public:
165  OGREnvelope3D() : OGREnvelope(), MinZ(0.0), MaxZ(0.0)
166  {
167  }
168 
169  OGREnvelope3D(const OGREnvelope3D& oOther) :
170  OGREnvelope(oOther),
171  MinZ(oOther.MinZ), MaxZ(oOther.MaxZ)
172  {
173  }
174 
175  double MinZ;
176  double MaxZ;
177 
178  int IsInit() const { return MinX != 0 || MinY != 0 || MaxX != 0 || MaxY != 0 || MinZ != 0 || MaxZ != 0; }
179  void Merge( OGREnvelope3D const& sOther ) {
180  if( IsInit() )
181  {
182  MinX = MIN(MinX,sOther.MinX);
183  MaxX = MAX(MaxX,sOther.MaxX);
184  MinY = MIN(MinY,sOther.MinY);
185  MaxY = MAX(MaxY,sOther.MaxY);
186  MinZ = MIN(MinZ,sOther.MinZ);
187  MaxZ = MAX(MaxZ,sOther.MaxZ);
188  }
189  else
190  {
191  MinX = sOther.MinX;
192  MaxX = sOther.MaxX;
193  MinY = sOther.MinY;
194  MaxY = sOther.MaxY;
195  MinZ = sOther.MinZ;
196  MaxZ = sOther.MaxZ;
197  }
198  }
199  void Merge( double dfX, double dfY, double dfZ ) {
200  if( IsInit() )
201  {
202  MinX = MIN(MinX,dfX);
203  MaxX = MAX(MaxX,dfX);
204  MinY = MIN(MinY,dfY);
205  MaxY = MAX(MaxY,dfY);
206  MinZ = MIN(MinZ,dfZ);
207  MaxZ = MAX(MaxZ,dfZ);
208  }
209  else
210  {
211  MinX = MaxX = dfX;
212  MinY = MaxY = dfY;
213  MinZ = MaxZ = dfZ;
214  }
215  }
216 
217  void Intersect( OGREnvelope3D const& sOther ) {
218  if(Intersects(sOther))
219  {
220  if( IsInit() )
221  {
222  MinX = MAX(MinX,sOther.MinX);
223  MaxX = MIN(MaxX,sOther.MaxX);
224  MinY = MAX(MinY,sOther.MinY);
225  MaxY = MIN(MaxY,sOther.MaxY);
226  MinZ = MAX(MinZ,sOther.MinZ);
227  MaxZ = MIN(MaxZ,sOther.MaxZ);
228  }
229  else
230  {
231  MinX = sOther.MinX;
232  MaxX = sOther.MaxX;
233  MinY = sOther.MinY;
234  MaxY = sOther.MaxY;
235  MinZ = sOther.MinZ;
236  MaxZ = sOther.MaxZ;
237  }
238  }
239  else
240  {
241  MinX = 0;
242  MaxX = 0;
243  MinY = 0;
244  MaxY = 0;
245  MinZ = 0;
246  MaxZ = 0;
247  }
248  }
249 
250  int Intersects(OGREnvelope3D const& other) const
251  {
252  return MinX <= other.MaxX && MaxX >= other.MinX &&
253  MinY <= other.MaxY && MaxY >= other.MinY &&
254  MinZ <= other.MaxZ && MaxZ >= other.MinZ;
255  }
256 
257  int Contains(OGREnvelope3D const& other) const
258  {
259  return MinX <= other.MinX && MinY <= other.MinY &&
260  MaxX >= other.MaxX && MaxY >= other.MaxY &&
261  MinZ <= other.MinZ && MaxZ >= other.MaxZ;
262  }
263 };
264 #else
265 typedef struct
266 {
267  double MinX;
268  double MaxX;
269  double MinY;
270  double MaxY;
271  double MinZ;
272  double MaxZ;
273 } OGREnvelope3D;
274 #endif
275 
276 
277 CPL_C_START
278 
279 void CPL_DLL *OGRMalloc( size_t );
280 void CPL_DLL *OGRCalloc( size_t, size_t );
281 void CPL_DLL *OGRRealloc( void *, size_t );
282 char CPL_DLL *OGRStrdup( const char * );
283 void CPL_DLL OGRFree( void * );
284 
285 typedef int OGRErr;
286 
287 #define OGRERR_NONE 0
288 #define OGRERR_NOT_ENOUGH_DATA 1 /* not enough data to deserialize */
289 #define OGRERR_NOT_ENOUGH_MEMORY 2
290 #define OGRERR_UNSUPPORTED_GEOMETRY_TYPE 3
291 #define OGRERR_UNSUPPORTED_OPERATION 4
292 #define OGRERR_CORRUPT_DATA 5
293 #define OGRERR_FAILURE 6
294 #define OGRERR_UNSUPPORTED_SRS 7
295 #define OGRERR_INVALID_HANDLE 8
296 
297 typedef int OGRBoolean;
298 
299 /* -------------------------------------------------------------------- */
300 /* ogr_geometry.h related definitions. */
301 /* -------------------------------------------------------------------- */
302 
308 typedef enum
309 {
311  wkbPoint = 1,
322  wkbNone = 100,
324  wkbPoint25D = 0x80000001,
325  wkbLineString25D = 0x80000002,
326  wkbPolygon25D = 0x80000003,
327  wkbMultiPoint25D = 0x80000004,
328  wkbMultiLineString25D = 0x80000005,
329  wkbMultiPolygon25D = 0x80000006,
332 
340 typedef enum
341 {
344 } OGRwkbVariant;
345 
346 #define wkb25DBit 0x80000000
347 #define wkbFlatten(x) ((OGRwkbGeometryType) ((x) & (~wkb25DBit)))
348 
349 #define ogrZMarker 0x21125711
350 
351 const char CPL_DLL * OGRGeometryTypeToName( OGRwkbGeometryType eType );
353  OGRwkbGeometryType eExtra );
354 
355 typedef enum
356 {
357  wkbXDR = 0, /* MSB/Sun/Motoroloa: Most Significant Byte First */
358  wkbNDR = 1 /* LSB/Intel/Vax: Least Significant Byte First */
359 } OGRwkbByteOrder;
360 
361 #ifndef NO_HACK_FOR_IBM_DB2_V72
362 # define HACK_FOR_IBM_DB2_V72
363 #endif
364 
365 #ifdef HACK_FOR_IBM_DB2_V72
366 # define DB2_V72_FIX_BYTE_ORDER(x) ((((x) & 0x31) == (x)) ? (OGRwkbByteOrder) ((x) & 0x1) : (x))
367 # define DB2_V72_UNFIX_BYTE_ORDER(x) ((unsigned char) (OGRGeometry::bGenerate_DB2_V72_BYTE_ORDER ? ((x) | 0x30) : (x)))
368 #else
369 # define DB2_V72_FIX_BYTE_ORDER(x) (x)
370 # define DB2_V72_UNFIX_BYTE_ORDER(x) (x)
371 #endif
372 
373 #define ALTER_NAME_FLAG 0x1
374 #define ALTER_TYPE_FLAG 0x2
375 #define ALTER_WIDTH_PRECISION_FLAG 0x4
376 #define ALTER_ALL_FLAG (ALTER_NAME_FLAG | ALTER_TYPE_FLAG | ALTER_WIDTH_PRECISION_FLAG)
377 
378 /************************************************************************/
379 /* ogr_feature.h related definitions. */
380 /************************************************************************/
381 
388 typedef enum
402  OFTMaxType = 11
403 } OGRFieldType;
404 
409 typedef enum
410 {
411  OJUndefined = 0,
412  OJLeft = 1,
413  OJRight = 2
415 
416 #define OGRNullFID -1
417 #define OGRUnsetMarker -21121
418 
419 /************************************************************************/
420 /* OGRField */
421 /************************************************************************/
422 
427 typedef union {
428  int Integer;
429  double Real;
430  char *String;
431 
432  struct {
433  int nCount;
434  int *paList;
435  } IntegerList;
436 
437  struct {
438  int nCount;
439  double *paList;
440  } RealList;
441 
442  struct {
443  int nCount;
444  char **paList;
445  } StringList;
446 
447  struct {
448  int nCount;
449  GByte *paData;
450  } Binary;
451 
452  struct {
453  int nMarker1;
454  int nMarker2;
455  } Set;
456 
457  struct {
458  GInt16 Year;
459  GByte Month;
460  GByte Day;
461  GByte Hour;
462  GByte Minute;
463  GByte Second;
464  GByte TZFlag; /* 0=unknown, 1=localtime(ambiguous),
465  100=GMT, 104=GMT+1, 80=GMT-5, etc */
466  } Date;
467 } OGRField;
468 
469 int CPL_DLL OGRParseDate( const char *pszInput, OGRField *psOutput,
470  int nOptions );
471 
472 /* -------------------------------------------------------------------- */
473 /* Constants from ogrsf_frmts.h for capabilities. */
474 /* -------------------------------------------------------------------- */
475 #define OLCRandomRead "RandomRead"
476 #define OLCSequentialWrite "SequentialWrite"
477 #define OLCRandomWrite "RandomWrite"
478 #define OLCFastSpatialFilter "FastSpatialFilter"
479 #define OLCFastFeatureCount "FastFeatureCount"
480 #define OLCFastGetExtent "FastGetExtent"
481 #define OLCCreateField "CreateField"
482 #define OLCDeleteField "DeleteField"
483 #define OLCReorderFields "ReorderFields"
484 #define OLCAlterFieldDefn "AlterFieldDefn"
485 #define OLCTransactions "Transactions"
486 #define OLCDeleteFeature "DeleteFeature"
487 #define OLCFastSetNextByIndex "FastSetNextByIndex"
488 #define OLCStringsAsUTF8 "StringsAsUTF8"
489 #define OLCIgnoreFields "IgnoreFields"
490 #define OLCCreateGeomField "CreateGeomField"
491 
492 #define ODsCCreateLayer "CreateLayer"
493 #define ODsCDeleteLayer "DeleteLayer"
494 #define ODsCCreateGeomFieldAfterCreateLayer "CreateGeomFieldAfterCreateLayer"
495 
496 #define ODrCCreateDataSource "CreateDataSource"
497 #define ODrCDeleteDataSource "DeleteDataSource"
498 
499 
500 /************************************************************************/
501 /* ogr_featurestyle.h related definitions. */
502 /************************************************************************/
503 
509 {
510  OGRSTCNone = 0,
511  OGRSTCPen = 1,
512  OGRSTCBrush = 2,
513  OGRSTCSymbol = 3,
514  OGRSTCLabel = 4,
515  OGRSTCVector = 5
516 } OGRSTClassId;
517 
522 {
523  OGRSTUGround = 0,
524  OGRSTUPixel = 1,
525  OGRSTUPoints = 2,
526  OGRSTUMM = 3,
527  OGRSTUCM = 4,
528  OGRSTUInches = 5
529 } OGRSTUnitId;
530 
535 {
536  OGRSTPenColor = 0,
537  OGRSTPenWidth = 1,
538  OGRSTPenPattern = 2,
539  OGRSTPenId = 3,
540  OGRSTPenPerOffset = 4,
541  OGRSTPenCap = 5,
542  OGRSTPenJoin = 6,
543  OGRSTPenPriority = 7,
544  OGRSTPenLast = 8
545 
546 } OGRSTPenParam;
547 
552 {
553  OGRSTBrushFColor = 0,
554  OGRSTBrushBColor = 1,
555  OGRSTBrushId = 2,
556  OGRSTBrushAngle = 3,
557  OGRSTBrushSize = 4,
558  OGRSTBrushDx = 5,
559  OGRSTBrushDy = 6,
560  OGRSTBrushPriority = 7,
561  OGRSTBrushLast = 8
562 
564 
565 
570 {
571  OGRSTSymbolId = 0,
572  OGRSTSymbolAngle = 1,
573  OGRSTSymbolColor = 2,
574  OGRSTSymbolSize = 3,
575  OGRSTSymbolDx = 4,
576  OGRSTSymbolDy = 5,
577  OGRSTSymbolStep = 6,
578  OGRSTSymbolPerp = 7,
579  OGRSTSymbolOffset = 8,
580  OGRSTSymbolPriority = 9,
581  OGRSTSymbolFontName = 10,
582  OGRSTSymbolOColor = 11,
583  OGRSTSymbolLast = 12
584 
586 
591 {
592  OGRSTLabelFontName = 0,
593  OGRSTLabelSize = 1,
594  OGRSTLabelTextString = 2,
595  OGRSTLabelAngle = 3,
596  OGRSTLabelFColor = 4,
597  OGRSTLabelBColor = 5,
598  OGRSTLabelPlacement = 6,
599  OGRSTLabelAnchor = 7,
600  OGRSTLabelDx = 8,
601  OGRSTLabelDy = 9,
602  OGRSTLabelPerp = 10,
603  OGRSTLabelBold = 11,
604  OGRSTLabelItalic = 12,
605  OGRSTLabelUnderline = 13,
606  OGRSTLabelPriority = 14,
607  OGRSTLabelStrikeout = 15,
608  OGRSTLabelStretch = 16,
609  OGRSTLabelAdjHor = 17,
610  OGRSTLabelAdjVert = 18,
611  OGRSTLabelHColor = 19,
612  OGRSTLabelOColor = 20,
613  OGRSTLabelLast = 21
614 
616 
617 /* ------------------------------------------------------------------- */
618 /* Version checking */
619 /* -------------------------------------------------------------------- */
620 
621 /* Note to developers : please keep this section in sync with gdal.h */
622 
623 #ifndef GDAL_VERSION_INFO_DEFINED
624 #define GDAL_VERSION_INFO_DEFINED
625 const char CPL_DLL * CPL_STDCALL GDALVersionInfo( const char * );
626 #endif
627 
628 #ifndef GDAL_CHECK_VERSION
629 
641 int CPL_DLL CPL_STDCALL GDALCheckVersion( int nVersionMajor, int nVersionMinor,
642  const char* pszCallingComponentName);
643 
645 #define GDAL_CHECK_VERSION(pszCallingComponentName) \
646  GDALCheckVersion(GDAL_VERSION_MAJOR, GDAL_VERSION_MINOR, pszCallingComponentName)
647 
648 #endif
649 
650 CPL_C_END
651 
652 #endif /* ndef OGR_CORE_H_INCLUDED */
Definition: ogr_core.h:322
Definition: ogr_core.h:343
enum ogr_style_tool_param_symbol_id OGRSTSymbolParam
ogr_style_tool_param_label_id
Definition: ogr_core.h:590
Definition: ogr_core.h:329
Definition: ogr_core.h:328
Definition: ogr_core.h:314
Definition: ogr_core.h:400
Definition: ogr_core.h:323
Definition: ogr_core.h:399
enum ogr_style_tool_param_brush_id OGRSTBrushParam
Definition: ogr_core.h:325
enum ogr_style_tool_param_label_id OGRSTLabelParam
ogr_style_tool_param_pen_id
Definition: ogr_core.h:534
Definition: ogr_core.h:393
ogr_style_tool_param_symbol_id
Definition: ogr_core.h:569
Definition: ogr_core.h:320
Definition: ogr_core.h:312
Definition: ogr_core.h:392
Definition: ogr_core.h:310
Definition: ogr_core.h:330
Definition: ogr_core.h:317
enum ogr_style_tool_class_id OGRSTClassId
Definition: ogr_core.h:398
Definition: ogr_core.h:327
enum ogr_style_tool_param_pen_id OGRSTPenParam
enum ogr_style_tool_units_id OGRSTUnitId
OGRwkbGeometryType
Definition: ogr_core.h:308
OGRwkbGeometryType OGRMergeGeometryTypes(OGRwkbGeometryType eMain, OGRwkbGeometryType eExtra)
Find common geometry type.
Definition: ogrgeometry.cpp:1738
Definition: ogr_core.h:326
Definition: ogr_core.h:318
OGRJustification
Definition: ogr_core.h:409
ogr_style_tool_units_id
Definition: ogr_core.h:521
Definition: ogr_core.h:342
Definition: ogr_core.h:397
Definition: ogr_core.h:311
OGRFieldType
Definition: ogr_core.h:388
Definition: ogr_core.h:401
Definition: ogr_core.h:162
int CPL_STDCALL GDALCheckVersion(int nVersionMajor, int nVersionMinor, const char *pszCallingComponentName)
OGRwkbVariant
Definition: ogr_core.h:340
Definition: ogr_core.h:396
ogr_style_tool_param_brush_id
Definition: ogr_core.h:551
Definition: ogr_core.h:48
Definition: ogr_core.h:427
ogr_style_tool_class_id
Definition: ogr_core.h:508
Definition: ogr_core.h:319
Definition: ogr_core.h:394
Definition: ogr_core.h:324
const char * OGRGeometryTypeToName(OGRwkbGeometryType eType)
Fetch a human readable name corresponding to an OGRwkBGeometryType value. The returned value should n...
Definition: ogrgeometry.cpp:1642
Definition: ogr_core.h:395
Definition: ogr_core.h:391
Definition: ogr_core.h:390

Generated for GDAL by doxygen 1.8.11.