ogr_core.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820
  1. /******************************************************************************
  2. * $Id: ogr_core.h 28900 2015-04-14 09:40:34Z 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. #ifndef OGR_CORE_H_INCLUDED
  31. #define OGR_CORE_H_INCLUDED
  32. #include "cpl_port.h"
  33. #include "gdal_version.h"
  34. /**
  35. * \file
  36. *
  37. * Core portability services for cross-platform OGR code.
  38. */
  39. /**
  40. * Simple container for a bounding region.
  41. */
  42. #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
  43. class CPL_DLL OGREnvelope
  44. {
  45. public:
  46. OGREnvelope() : MinX(0.0), MaxX(0.0), MinY(0.0), MaxY(0.0)
  47. {
  48. }
  49. OGREnvelope(const OGREnvelope& oOther) :
  50. MinX(oOther.MinX),MaxX(oOther.MaxX), MinY(oOther.MinY), MaxY(oOther.MaxY)
  51. {
  52. }
  53. double MinX;
  54. double MaxX;
  55. double MinY;
  56. double MaxY;
  57. /* See http://trac.osgeo.org/gdal/ticket/5299 for details on this pragma */
  58. #if ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(_MSC_VER))
  59. #pragma GCC diagnostic push
  60. #pragma GCC diagnostic ignored "-Wfloat-equal"
  61. #endif
  62. int IsInit() const { return MinX != 0 || MinY != 0 || MaxX != 0 || MaxY != 0; }
  63. #if ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(_MSC_VER))
  64. #pragma GCC diagnostic pop
  65. #endif
  66. void Merge( OGREnvelope const& sOther ) {
  67. if( IsInit() )
  68. {
  69. MinX = MIN(MinX,sOther.MinX);
  70. MaxX = MAX(MaxX,sOther.MaxX);
  71. MinY = MIN(MinY,sOther.MinY);
  72. MaxY = MAX(MaxY,sOther.MaxY);
  73. }
  74. else
  75. {
  76. MinX = sOther.MinX;
  77. MaxX = sOther.MaxX;
  78. MinY = sOther.MinY;
  79. MaxY = sOther.MaxY;
  80. }
  81. }
  82. void Merge( double dfX, double dfY ) {
  83. if( IsInit() )
  84. {
  85. MinX = MIN(MinX,dfX);
  86. MaxX = MAX(MaxX,dfX);
  87. MinY = MIN(MinY,dfY);
  88. MaxY = MAX(MaxY,dfY);
  89. }
  90. else
  91. {
  92. MinX = MaxX = dfX;
  93. MinY = MaxY = dfY;
  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. int Intersects(OGREnvelope const& other) const
  123. {
  124. return MinX <= other.MaxX && MaxX >= other.MinX &&
  125. MinY <= other.MaxY && MaxY >= other.MinY;
  126. }
  127. int Contains(OGREnvelope const& other) const
  128. {
  129. return MinX <= other.MinX && MinY <= other.MinY &&
  130. MaxX >= other.MaxX && MaxY >= other.MaxY;
  131. }
  132. };
  133. #else
  134. typedef struct
  135. {
  136. double MinX;
  137. double MaxX;
  138. double MinY;
  139. double MaxY;
  140. } OGREnvelope;
  141. #endif
  142. /**
  143. * Simple container for a bounding region in 3D.
  144. */
  145. #if defined(__cplusplus) && !defined(CPL_SURESS_CPLUSPLUS)
  146. class CPL_DLL OGREnvelope3D : public OGREnvelope
  147. {
  148. public:
  149. OGREnvelope3D() : OGREnvelope(), MinZ(0.0), MaxZ(0.0)
  150. {
  151. }
  152. OGREnvelope3D(const OGREnvelope3D& oOther) :
  153. OGREnvelope(oOther),
  154. MinZ(oOther.MinZ), MaxZ(oOther.MaxZ)
  155. {
  156. }
  157. double MinZ;
  158. double MaxZ;
  159. int IsInit() const { return MinX != 0 || MinY != 0 || MaxX != 0 || MaxY != 0 || MinZ != 0 || MaxZ != 0; }
  160. void Merge( OGREnvelope3D const& sOther ) {
  161. if( IsInit() )
  162. {
  163. MinX = MIN(MinX,sOther.MinX);
  164. MaxX = MAX(MaxX,sOther.MaxX);
  165. MinY = MIN(MinY,sOther.MinY);
  166. MaxY = MAX(MaxY,sOther.MaxY);
  167. MinZ = MIN(MinZ,sOther.MinZ);
  168. MaxZ = MAX(MaxZ,sOther.MaxZ);
  169. }
  170. else
  171. {
  172. MinX = sOther.MinX;
  173. MaxX = sOther.MaxX;
  174. MinY = sOther.MinY;
  175. MaxY = sOther.MaxY;
  176. MinZ = sOther.MinZ;
  177. MaxZ = sOther.MaxZ;
  178. }
  179. }
  180. void Merge( double dfX, double dfY, double dfZ ) {
  181. if( IsInit() )
  182. {
  183. MinX = MIN(MinX,dfX);
  184. MaxX = MAX(MaxX,dfX);
  185. MinY = MIN(MinY,dfY);
  186. MaxY = MAX(MaxY,dfY);
  187. MinZ = MIN(MinZ,dfZ);
  188. MaxZ = MAX(MaxZ,dfZ);
  189. }
  190. else
  191. {
  192. MinX = MaxX = dfX;
  193. MinY = MaxY = dfY;
  194. MinZ = MaxZ = dfZ;
  195. }
  196. }
  197. void Intersect( OGREnvelope3D const& sOther ) {
  198. if(Intersects(sOther))
  199. {
  200. if( IsInit() )
  201. {
  202. MinX = MAX(MinX,sOther.MinX);
  203. MaxX = MIN(MaxX,sOther.MaxX);
  204. MinY = MAX(MinY,sOther.MinY);
  205. MaxY = MIN(MaxY,sOther.MaxY);
  206. MinZ = MAX(MinZ,sOther.MinZ);
  207. MaxZ = MIN(MaxZ,sOther.MaxZ);
  208. }
  209. else
  210. {
  211. MinX = sOther.MinX;
  212. MaxX = sOther.MaxX;
  213. MinY = sOther.MinY;
  214. MaxY = sOther.MaxY;
  215. MinZ = sOther.MinZ;
  216. MaxZ = sOther.MaxZ;
  217. }
  218. }
  219. else
  220. {
  221. MinX = 0;
  222. MaxX = 0;
  223. MinY = 0;
  224. MaxY = 0;
  225. MinZ = 0;
  226. MaxZ = 0;
  227. }
  228. }
  229. int Intersects(OGREnvelope3D const& other) const
  230. {
  231. return MinX <= other.MaxX && MaxX >= other.MinX &&
  232. MinY <= other.MaxY && MaxY >= other.MinY &&
  233. MinZ <= other.MaxZ && MaxZ >= other.MinZ;
  234. }
  235. int Contains(OGREnvelope3D const& other) const
  236. {
  237. return MinX <= other.MinX && MinY <= other.MinY &&
  238. MaxX >= other.MaxX && MaxY >= other.MaxY &&
  239. MinZ <= other.MinZ && MaxZ >= other.MaxZ;
  240. }
  241. };
  242. #else
  243. typedef struct
  244. {
  245. double MinX;
  246. double MaxX;
  247. double MinY;
  248. double MaxY;
  249. double MinZ;
  250. double MaxZ;
  251. } OGREnvelope3D;
  252. #endif
  253. CPL_C_START
  254. void CPL_DLL *OGRMalloc( size_t );
  255. void CPL_DLL *OGRCalloc( size_t, size_t );
  256. void CPL_DLL *OGRRealloc( void *, size_t );
  257. char CPL_DLL *OGRStrdup( const char * );
  258. void CPL_DLL OGRFree( void * );
  259. typedef int OGRErr;
  260. #define OGRERR_NONE 0
  261. #define OGRERR_NOT_ENOUGH_DATA 1 /* not enough data to deserialize */
  262. #define OGRERR_NOT_ENOUGH_MEMORY 2
  263. #define OGRERR_UNSUPPORTED_GEOMETRY_TYPE 3
  264. #define OGRERR_UNSUPPORTED_OPERATION 4
  265. #define OGRERR_CORRUPT_DATA 5
  266. #define OGRERR_FAILURE 6
  267. #define OGRERR_UNSUPPORTED_SRS 7
  268. #define OGRERR_INVALID_HANDLE 8
  269. #define OGRERR_NON_EXISTING_FEATURE 9 /* added in GDAL 2.0 */
  270. typedef int OGRBoolean;
  271. /* -------------------------------------------------------------------- */
  272. /* ogr_geometry.h related definitions. */
  273. /* -------------------------------------------------------------------- */
  274. /**
  275. * List of well known binary geometry types. These are used within the BLOBs
  276. * but are also returned from OGRGeometry::getGeometryType() to identify the
  277. * type of a geometry object.
  278. */
  279. typedef enum
  280. {
  281. wkbUnknown = 0, /**< unknown type, non-standard */
  282. wkbPoint = 1, /**< 0-dimensional geometric object, standard WKB */
  283. wkbLineString = 2, /**< 1-dimensional geometric object with linear
  284. * interpolation between Points, standard WKB */
  285. wkbPolygon = 3, /**< planar 2-dimensional geometric object defined
  286. * by 1 exterior boundary and 0 or more interior
  287. * boundaries, standard WKB */
  288. wkbMultiPoint = 4, /**< GeometryCollection of Points, standard WKB */
  289. wkbMultiLineString = 5, /**< GeometryCollection of LineStrings, standard WKB */
  290. wkbMultiPolygon = 6, /**< GeometryCollection of Polygons, standard WKB */
  291. wkbGeometryCollection = 7, /**< geometric object that is a collection of 1
  292. or more geometric objects, standard WKB */
  293. wkbCircularString = 8, /**< one or more circular arc segments connected end to end,
  294. * ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
  295. wkbCompoundCurve = 9, /**< sequence of contiguous curves, ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
  296. wkbCurvePolygon = 10, /**< planar surface, defined by 1 exterior boundary
  297. * and zero or more interior boundaries, that are curves.
  298. * ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
  299. wkbMultiCurve = 11, /**< GeometryCollection of Curves, ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
  300. wkbMultiSurface = 12, /**< GeometryCollection of Surfaces, ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
  301. wkbNone = 100, /**< non-standard, for pure attribute records */
  302. wkbLinearRing = 101, /**< non-standard, just for createGeometry() */
  303. wkbCircularStringZ = 1008, /**< wkbCircularString with Z component. ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
  304. wkbCompoundCurveZ = 1009, /**< wkbCompoundCurve with Z component. ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
  305. wkbCurvePolygonZ = 1010, /**< wkbCurvePolygon with Z component. ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
  306. wkbMultiCurveZ = 1011, /**< wkbMultiCurve with Z component. ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
  307. wkbMultiSurfaceZ = 1012, /**< wkbMultiSurface with Z component. ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
  308. wkbPoint25D = 0x80000001, /**< 2.5D extension as per 99-402 */
  309. wkbLineString25D = 0x80000002, /**< 2.5D extension as per 99-402 */
  310. wkbPolygon25D = 0x80000003, /**< 2.5D extension as per 99-402 */
  311. wkbMultiPoint25D = 0x80000004, /**< 2.5D extension as per 99-402 */
  312. wkbMultiLineString25D = 0x80000005, /**< 2.5D extension as per 99-402 */
  313. wkbMultiPolygon25D = 0x80000006, /**< 2.5D extension as per 99-402 */
  314. wkbGeometryCollection25D = 0x80000007 /**< 2.5D extension as per 99-402 */
  315. } OGRwkbGeometryType;
  316. /* Outside of OGRwkbGeometryType since they are abstract types */
  317. #define wkbCurve ((OGRwkbGeometryType)13) /**< Curve (abstract type). SF-SQL 1.2 */
  318. #define wkbSurface ((OGRwkbGeometryType)14) /**< Surface (abstract type). SF-SQL 1.2 */
  319. /**
  320. * Output variants of WKB we support.
  321. *
  322. * 99-402 was a short-lived extension to SFSQL 1.1 that used a high-bit flag
  323. * to indicate the presence of Z coordiantes in a WKB geometry.
  324. *
  325. * SQL/MM Part 3 and SFSQL 1.2 use offsets of 1000 (Z), 2000 (M) and 3000 (ZM)
  326. * to indicate the present of higher dimensional coordinates in a WKB geometry.
  327. * Reference: <a href="https://portal.opengeospatial.org/files/?artifact_id=320243">
  328. * 09-009_Committee_Draft_ISOIEC_CD_13249-3_SQLMM_Spatial.pdf</a>,
  329. * ISO/IEC JTC 1/SC 32 N 1820, ISO/IEC CD 13249-3:201x(E), Date: 2009-01-16.
  330. * The codes are also found in §8.2.3 of <a href="http://portal.opengeospatial.org/files/?artifact_id=25355">
  331. * OGC 06-103r4 "OpenGIS® Implementation Standard for Geographic information - Simple feature access - Part 1: Common architecture", v1.2.1</a>
  332. */
  333. typedef enum
  334. {
  335. wkbVariantOldOgc, /**< Old-style 99-402 extended dimension (Z) WKB types */
  336. wkbVariantIso, /**< SFSQL 1.2 and ISO SQL/MM Part 3 extended dimension (Z&M) WKB types */
  337. wkbVariantPostGIS1 /**< PostGIS 1.X has different codes for CurvePolygon, MultiCurve and MultiSurface */
  338. } OGRwkbVariant;
  339. /** @deprecated in GDAL 2.0. Use wkbHasZ() or wkbSetZ() instead */
  340. #ifndef GDAL_COMPILATION
  341. #define wkb25DBit 0x80000000
  342. #endif
  343. /** Return the 2D geometry type corresponding to the specified geometry type */
  344. #define wkbFlatten(x) OGR_GT_Flatten((OGRwkbGeometryType)(x))
  345. /** Return if the geometry type is a 3D geometry type
  346. * @since GDAL 2.0
  347. */
  348. #define wkbHasZ(x) OGR_GT_HasZ(x)
  349. /** Return the 3D geometry type corresponding to the specified geometry type.
  350. * @since GDAL 2.0
  351. */
  352. #define wkbSetZ(x) OGR_GT_SetZ(x)
  353. #define ogrZMarker 0x21125711
  354. const char CPL_DLL * OGRGeometryTypeToName( OGRwkbGeometryType eType );
  355. OGRwkbGeometryType CPL_DLL OGRMergeGeometryTypes( OGRwkbGeometryType eMain,
  356. OGRwkbGeometryType eExtra );
  357. OGRwkbGeometryType CPL_DLL OGRMergeGeometryTypesEx( OGRwkbGeometryType eMain,
  358. OGRwkbGeometryType eExtra,
  359. int bAllowPromotingToCurves );
  360. OGRwkbGeometryType CPL_DLL OGR_GT_Flatten( OGRwkbGeometryType eType );
  361. OGRwkbGeometryType CPL_DLL OGR_GT_SetZ( OGRwkbGeometryType eType );
  362. OGRwkbGeometryType CPL_DLL OGR_GT_SetModifier( OGRwkbGeometryType eType, int bSetZ, int bSetM );
  363. int CPL_DLL OGR_GT_HasZ( OGRwkbGeometryType eType );
  364. int CPL_DLL OGR_GT_IsSubClassOf( OGRwkbGeometryType eType,
  365. OGRwkbGeometryType eSuperType );
  366. int CPL_DLL OGR_GT_IsCurve( OGRwkbGeometryType );
  367. int CPL_DLL OGR_GT_IsSurface( OGRwkbGeometryType );
  368. int CPL_DLL OGR_GT_IsNonLinear( OGRwkbGeometryType );
  369. OGRwkbGeometryType CPL_DLL OGR_GT_GetCollection( OGRwkbGeometryType eType );
  370. OGRwkbGeometryType CPL_DLL OGR_GT_GetCurve( OGRwkbGeometryType eType );
  371. OGRwkbGeometryType CPL_DLL OGR_GT_GetLinear( OGRwkbGeometryType eType );
  372. typedef enum
  373. {
  374. wkbXDR = 0, /* MSB/Sun/Motoroloa: Most Significant Byte First */
  375. wkbNDR = 1 /* LSB/Intel/Vax: Least Significant Byte First */
  376. } OGRwkbByteOrder;
  377. #ifndef NO_HACK_FOR_IBM_DB2_V72
  378. # define HACK_FOR_IBM_DB2_V72
  379. #endif
  380. #ifdef HACK_FOR_IBM_DB2_V72
  381. # define DB2_V72_FIX_BYTE_ORDER(x) ((((x) & 0x31) == (x)) ? (OGRwkbByteOrder) ((x) & 0x1) : (x))
  382. # define DB2_V72_UNFIX_BYTE_ORDER(x) ((unsigned char) (OGRGeometry::bGenerate_DB2_V72_BYTE_ORDER ? ((x) | 0x30) : (x)))
  383. #else
  384. # define DB2_V72_FIX_BYTE_ORDER(x) (x)
  385. # define DB2_V72_UNFIX_BYTE_ORDER(x) (x)
  386. #endif
  387. /** Alter field name.
  388. * Used by OGR_L_AlterFieldDefn().
  389. */
  390. #define ALTER_NAME_FLAG 0x1
  391. /** Alter field type.
  392. * Used by OGR_L_AlterFieldDefn().
  393. */
  394. #define ALTER_TYPE_FLAG 0x2
  395. /** Alter field width and precision.
  396. * Used by OGR_L_AlterFieldDefn().
  397. */
  398. #define ALTER_WIDTH_PRECISION_FLAG 0x4
  399. /** Alter field NOT NULL constraint.
  400. * Used by OGR_L_AlterFieldDefn().
  401. * @since GDAL 2.0
  402. */
  403. #define ALTER_NULLABLE_FLAG 0x8
  404. /** Alter field DEFAULT value.
  405. * Used by OGR_L_AlterFieldDefn().
  406. * @since GDAL 2.0
  407. */
  408. #define ALTER_DEFAULT_FLAG 0x10
  409. /** Alter all parameters of field definition.
  410. * Used by OGR_L_AlterFieldDefn().
  411. */
  412. #define ALTER_ALL_FLAG (ALTER_NAME_FLAG | ALTER_TYPE_FLAG | ALTER_WIDTH_PRECISION_FLAG | ALTER_NULLABLE_FLAG | ALTER_DEFAULT_FLAG)
  413. /** Validate that fields respect not-null constraints.
  414. * Used by OGR_F_Validate().
  415. * @since GDAL 2.0
  416. */
  417. #define OGR_F_VAL_NULL 0x00000001
  418. /** Validate that geometries respect geometry column type.
  419. * Used by OGR_F_Validate().
  420. * @since GDAL 2.0
  421. */
  422. #define OGR_F_VAL_GEOM_TYPE 0x00000002
  423. /** Validate that (string) fields respect field width.
  424. * Used by OGR_F_Validate().
  425. * @since GDAL 2.0
  426. */
  427. #define OGR_F_VAL_WIDTH 0x00000004
  428. /** Allow fields that are null when there's an associated default value.
  429. * This can be used for drivers where the low-level layers will automatically set the
  430. * field value to the associated default value.
  431. * This flag only makes sense if OGR_F_VAL_NULL is set too.
  432. * Used by OGR_F_Validate().
  433. * @since GDAL 2.0
  434. */
  435. #define OGR_F_VAL_ALLOW_NULL_WHEN_DEFAULT 0x00000008
  436. /** Enable all validation tests.
  437. * Used by OGR_F_Validate().
  438. * @since GDAL 2.0
  439. */
  440. #define OGR_F_VAL_ALL 0xFFFFFFFF
  441. /************************************************************************/
  442. /* ogr_feature.h related definitions. */
  443. /************************************************************************/
  444. /**
  445. * List of feature field types. This list is likely to be extended in the
  446. * future ... avoid coding applications based on the assumption that all
  447. * field types can be known.
  448. */
  449. typedef enum
  450. {
  451. /** Simple 32bit integer */ OFTInteger = 0,
  452. /** List of 32bit integers */ OFTIntegerList = 1,
  453. /** Double Precision floating point */ OFTReal = 2,
  454. /** List of doubles */ OFTRealList = 3,
  455. /** String of ASCII chars */ OFTString = 4,
  456. /** Array of strings */ OFTStringList = 5,
  457. /** deprecated */ OFTWideString = 6,
  458. /** deprecated */ OFTWideStringList = 7,
  459. /** Raw Binary data */ OFTBinary = 8,
  460. /** Date */ OFTDate = 9,
  461. /** Time */ OFTTime = 10,
  462. /** Date and Time */ OFTDateTime = 11,
  463. /** Single 64bit integer */ OFTInteger64 = 12,
  464. /** List of 64bit integers */ OFTInteger64List = 13,
  465. OFTMaxType = 13
  466. } OGRFieldType;
  467. /**
  468. * List of field subtypes. A subtype represents a hint, a restriction of the
  469. * main type, that is not strictly necessary to consult.
  470. * This list is likely to be extended in the
  471. * future ... avoid coding applications based on the assumption that all
  472. * field types can be known.
  473. * Most subtypes only make sense for a restricted set of main types.
  474. * @since GDAL 2.0
  475. */
  476. typedef enum
  477. {
  478. /** No subtype. This is the default value */ OFSTNone = 0,
  479. /** Boolean integer. Only valid for OFTInteger and OFTIntegerList.*/
  480. OFSTBoolean = 1,
  481. /** Signed 16-bit integer. Only valid for OFTInteger and OFTIntegerList. */
  482. OFSTInt16 = 2,
  483. /** Single precision (32 bit) floatint point. Only valid for OFTReal and OFTRealList. */
  484. OFSTFloat32 = 3,
  485. OFSTMaxSubType = 3
  486. } OGRFieldSubType;
  487. /**
  488. * Display justification for field values.
  489. */
  490. typedef enum
  491. {
  492. OJUndefined = 0,
  493. OJLeft = 1,
  494. OJRight = 2
  495. } OGRJustification;
  496. #define OGRNullFID -1
  497. #define OGRUnsetMarker -21121
  498. /************************************************************************/
  499. /* OGRField */
  500. /************************************************************************/
  501. /**
  502. * OGRFeature field attribute value union.
  503. */
  504. typedef union {
  505. int Integer;
  506. GIntBig Integer64;
  507. double Real;
  508. char *String;
  509. struct {
  510. int nCount;
  511. int *paList;
  512. } IntegerList;
  513. struct {
  514. int nCount;
  515. GIntBig *paList;
  516. } Integer64List;
  517. struct {
  518. int nCount;
  519. double *paList;
  520. } RealList;
  521. struct {
  522. int nCount;
  523. char **paList;
  524. } StringList;
  525. struct {
  526. int nCount;
  527. GByte *paData;
  528. } Binary;
  529. struct {
  530. int nMarker1;
  531. int nMarker2;
  532. } Set;
  533. struct {
  534. GInt16 Year;
  535. GByte Month;
  536. GByte Day;
  537. GByte Hour;
  538. GByte Minute;
  539. GByte TZFlag; /* 0=unknown, 1=localtime(ambiguous),
  540. 100=GMT, 104=GMT+1, 80=GMT-5, etc */
  541. GByte Reserved; /* must be set to 0 */
  542. float Second; /* with millisecond accuracy. at the end of the structure, so as to keep it 12 bytes on 32 bit */
  543. } Date;
  544. } OGRField;
  545. #define OGR_GET_MS(floatingpoint_sec) (int)(((floatingpoint_sec) - (int)(floatingpoint_sec)) * 1000 + 0.5)
  546. int CPL_DLL OGRParseDate( const char *pszInput, OGRField *psOutput,
  547. int nOptions );
  548. /* -------------------------------------------------------------------- */
  549. /* Constants from ogrsf_frmts.h for capabilities. */
  550. /* -------------------------------------------------------------------- */
  551. #define OLCRandomRead "RandomRead"
  552. #define OLCSequentialWrite "SequentialWrite"
  553. #define OLCRandomWrite "RandomWrite"
  554. #define OLCFastSpatialFilter "FastSpatialFilter"
  555. #define OLCFastFeatureCount "FastFeatureCount"
  556. #define OLCFastGetExtent "FastGetExtent"
  557. #define OLCCreateField "CreateField"
  558. #define OLCDeleteField "DeleteField"
  559. #define OLCReorderFields "ReorderFields"
  560. #define OLCAlterFieldDefn "AlterFieldDefn"
  561. #define OLCTransactions "Transactions"
  562. #define OLCDeleteFeature "DeleteFeature"
  563. #define OLCFastSetNextByIndex "FastSetNextByIndex"
  564. #define OLCStringsAsUTF8 "StringsAsUTF8"
  565. #define OLCIgnoreFields "IgnoreFields"
  566. #define OLCCreateGeomField "CreateGeomField"
  567. #define OLCCurveGeometries "CurveGeometries"
  568. #define ODsCCreateLayer "CreateLayer"
  569. #define ODsCDeleteLayer "DeleteLayer"
  570. #define ODsCCreateGeomFieldAfterCreateLayer "CreateGeomFieldAfterCreateLayer"
  571. #define ODsCCurveGeometries "CurveGeometries"
  572. #define ODsCTransactions "Transactions"
  573. #define ODsCEmulatedTransactions "EmulatedTransactions"
  574. #define ODrCCreateDataSource "CreateDataSource"
  575. #define ODrCDeleteDataSource "DeleteDataSource"
  576. /* -------------------------------------------------------------------- */
  577. /* Layer metadata items. */
  578. /* -------------------------------------------------------------------- */
  579. /** Capability set to YES as metadata on a layer that has features with
  580. * 64 bit identifiers.
  581. @since GDAL 2.0
  582. */
  583. #define OLMD_FID64 "OLMD_FID64"
  584. /************************************************************************/
  585. /* ogr_featurestyle.h related definitions. */
  586. /************************************************************************/
  587. /**
  588. * OGRStyleTool derived class types (returned by GetType()).
  589. */
  590. typedef enum ogr_style_tool_class_id
  591. {
  592. OGRSTCNone = 0,
  593. OGRSTCPen = 1,
  594. OGRSTCBrush = 2,
  595. OGRSTCSymbol = 3,
  596. OGRSTCLabel = 4,
  597. OGRSTCVector = 5
  598. } OGRSTClassId;
  599. /**
  600. * List of units supported by OGRStyleTools.
  601. */
  602. typedef enum ogr_style_tool_units_id
  603. {
  604. OGRSTUGround = 0,
  605. OGRSTUPixel = 1,
  606. OGRSTUPoints = 2,
  607. OGRSTUMM = 3,
  608. OGRSTUCM = 4,
  609. OGRSTUInches = 5
  610. } OGRSTUnitId;
  611. /**
  612. * List of parameters for use with OGRStylePen.
  613. */
  614. typedef enum ogr_style_tool_param_pen_id
  615. {
  616. OGRSTPenColor = 0,
  617. OGRSTPenWidth = 1,
  618. OGRSTPenPattern = 2,
  619. OGRSTPenId = 3,
  620. OGRSTPenPerOffset = 4,
  621. OGRSTPenCap = 5,
  622. OGRSTPenJoin = 6,
  623. OGRSTPenPriority = 7,
  624. OGRSTPenLast = 8
  625. } OGRSTPenParam;
  626. /**
  627. * List of parameters for use with OGRStyleBrush.
  628. */
  629. typedef enum ogr_style_tool_param_brush_id
  630. {
  631. OGRSTBrushFColor = 0,
  632. OGRSTBrushBColor = 1,
  633. OGRSTBrushId = 2,
  634. OGRSTBrushAngle = 3,
  635. OGRSTBrushSize = 4,
  636. OGRSTBrushDx = 5,
  637. OGRSTBrushDy = 6,
  638. OGRSTBrushPriority = 7,
  639. OGRSTBrushLast = 8
  640. } OGRSTBrushParam;
  641. /**
  642. * List of parameters for use with OGRStyleSymbol.
  643. */
  644. typedef enum ogr_style_tool_param_symbol_id
  645. {
  646. OGRSTSymbolId = 0,
  647. OGRSTSymbolAngle = 1,
  648. OGRSTSymbolColor = 2,
  649. OGRSTSymbolSize = 3,
  650. OGRSTSymbolDx = 4,
  651. OGRSTSymbolDy = 5,
  652. OGRSTSymbolStep = 6,
  653. OGRSTSymbolPerp = 7,
  654. OGRSTSymbolOffset = 8,
  655. OGRSTSymbolPriority = 9,
  656. OGRSTSymbolFontName = 10,
  657. OGRSTSymbolOColor = 11,
  658. OGRSTSymbolLast = 12
  659. } OGRSTSymbolParam;
  660. /**
  661. * List of parameters for use with OGRStyleLabel.
  662. */
  663. typedef enum ogr_style_tool_param_label_id
  664. {
  665. OGRSTLabelFontName = 0,
  666. OGRSTLabelSize = 1,
  667. OGRSTLabelTextString = 2,
  668. OGRSTLabelAngle = 3,
  669. OGRSTLabelFColor = 4,
  670. OGRSTLabelBColor = 5,
  671. OGRSTLabelPlacement = 6,
  672. OGRSTLabelAnchor = 7,
  673. OGRSTLabelDx = 8,
  674. OGRSTLabelDy = 9,
  675. OGRSTLabelPerp = 10,
  676. OGRSTLabelBold = 11,
  677. OGRSTLabelItalic = 12,
  678. OGRSTLabelUnderline = 13,
  679. OGRSTLabelPriority = 14,
  680. OGRSTLabelStrikeout = 15,
  681. OGRSTLabelStretch = 16,
  682. OGRSTLabelAdjHor = 17,
  683. OGRSTLabelAdjVert = 18,
  684. OGRSTLabelHColor = 19,
  685. OGRSTLabelOColor = 20,
  686. OGRSTLabelLast = 21
  687. } OGRSTLabelParam;
  688. /* ------------------------------------------------------------------- */
  689. /* Version checking */
  690. /* -------------------------------------------------------------------- */
  691. /* Note to developers : please keep this section in sync with gdal.h */
  692. #ifndef GDAL_VERSION_INFO_DEFINED
  693. #define GDAL_VERSION_INFO_DEFINED
  694. const char CPL_DLL * CPL_STDCALL GDALVersionInfo( const char * );
  695. #endif
  696. #ifndef GDAL_CHECK_VERSION
  697. /** Return TRUE if GDAL library version at runtime matches nVersionMajor.nVersionMinor.
  698. The purpose of this method is to ensure that calling code will run with the GDAL
  699. version it is compiled for. It is primarly intented for external plugins.
  700. @param nVersionMajor Major version to be tested against
  701. @param nVersionMinor Minor version to be tested against
  702. @param pszCallingComponentName If not NULL, in case of version mismatch, the method
  703. will issue a failure mentionning the name of
  704. the calling component.
  705. */
  706. int CPL_DLL CPL_STDCALL GDALCheckVersion( int nVersionMajor, int nVersionMinor,
  707. const char* pszCallingComponentName);
  708. /** Helper macro for GDALCheckVersion */
  709. #define GDAL_CHECK_VERSION(pszCallingComponentName) \
  710. GDALCheckVersion(GDAL_VERSION_MAJOR, GDAL_VERSION_MINOR, pszCallingComponentName)
  711. #endif
  712. CPL_C_END
  713. #endif /* ndef OGR_CORE_H_INCLUDED */