1 /******************************************************************************
2  * $Id: ogr_core.h 4a9078b00804fc0de0063d36cbbde997a24c087a 2021-09-18 15:37:17 +0200 Even 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 spatialys.com>
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 #if defined(GDAL_COMPILATION)
36 #define DO_NOT_DEFINE_GDAL_RELEASE_DATE_AND_GDAL_RELEASE_NAME
37 #endif
38 #include "gdal_version.h"
39 
40 /**
41  * \file
42  *
43  * Core portability services for cross-platform OGR code.
44  */
45 
46 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
47 
48 extern "C++"
49 {
50 #if !defined(DOXYGEN_SKIP)
51 #include <limits>
52 #endif
53 
54 /**
55  * Simple container for a bounding region (rectangle)
56  */
57 class CPL_DLL OGREnvelope
58 {
59   public:
60         /** Default constructor. Defines an empty rectangle  */
OGREnvelope()61         OGREnvelope() : MinX(std::numeric_limits<double>::infinity()),
62                         MaxX(-std::numeric_limits<double>::infinity()),
63                         MinY(std::numeric_limits<double>::infinity()),
64                         MaxY(-std::numeric_limits<double>::infinity())
65         {
66         }
67 
68         /** Copy constructor */
OGREnvelope(const OGREnvelope & oOther)69         OGREnvelope(const OGREnvelope& oOther) :
70             MinX(oOther.MinX),MaxX(oOther.MaxX), MinY(oOther.MinY), MaxY(oOther.MaxY)
71         {
72         }
73 
74         /** Assignment operator */
75         OGREnvelope& operator=(const OGREnvelope&) = default;
76 
77     /** Minimum X value */
78     double      MinX;
79 
80     /** Maximum X value */
81     double      MaxX;
82 
83     /** Minimum Y value */
84     double      MinY;
85 
86     /** Maximum Y value */
87     double      MaxY;
88 
89 #ifdef HAVE_GCC_DIAGNOSTIC_PUSH
90 #pragma GCC diagnostic push
91 #pragma GCC diagnostic ignored "-Wfloat-equal"
92 #endif
93     /** Return whether the object has been initialized, that is, is non empty */
IsInit()94     int  IsInit() const { return MinX != std::numeric_limits<double>::infinity(); }
95 
96 #ifdef HAVE_GCC_DIAGNOSTIC_PUSH
97 #pragma GCC diagnostic pop
98 #endif
99 
100     /** Update the current object by computing its union with the other rectangle */
Merge(OGREnvelope const & sOther)101     void Merge( OGREnvelope const& sOther ) {
102         MinX = MIN(MinX,sOther.MinX);
103         MaxX = MAX(MaxX,sOther.MaxX);
104         MinY = MIN(MinY,sOther.MinY);
105         MaxY = MAX(MaxY,sOther.MaxY);
106     }
107 
108     /** Update the current object by computing its union with the provided point */
Merge(double dfX,double dfY)109     void Merge( double dfX, double dfY ) {
110         MinX = MIN(MinX,dfX);
111         MaxX = MAX(MaxX,dfX);
112         MinY = MIN(MinY,dfY);
113         MaxY = MAX(MaxY,dfY);
114     }
115 
116     /** Update the current object by computing its intersection with the other rectangle */
Intersect(OGREnvelope const & sOther)117     void Intersect( OGREnvelope const& sOther ) {
118         if(Intersects(sOther))
119         {
120             if( IsInit() )
121             {
122                 MinX = MAX(MinX,sOther.MinX);
123                 MaxX = MIN(MaxX,sOther.MaxX);
124                 MinY = MAX(MinY,sOther.MinY);
125                 MaxY = MIN(MaxY,sOther.MaxY);
126             }
127             else
128             {
129                 MinX = sOther.MinX;
130                 MaxX = sOther.MaxX;
131                 MinY = sOther.MinY;
132                 MaxY = sOther.MaxY;
133             }
134         }
135         else
136         {
137             *this = OGREnvelope();
138         }
139     }
140 
141     /** Return whether the current object intersects with the other rectangle */
Intersects(OGREnvelope const & other)142     int Intersects(OGREnvelope const& other) const
143     {
144         return MinX <= other.MaxX && MaxX >= other.MinX &&
145                MinY <= other.MaxY && MaxY >= other.MinY;
146     }
147 
148     /** Return whether the current object contains the other rectangle */
Contains(OGREnvelope const & other)149     int Contains(OGREnvelope const& other) const
150     {
151         return MinX <= other.MinX && MinY <= other.MinY &&
152                MaxX >= other.MaxX && MaxY >= other.MaxY;
153     }
154 };
155 
156 } // extern "C++"
157 
158 #else
159 typedef struct
160 {
161     double      MinX;
162     double      MaxX;
163     double      MinY;
164     double      MaxY;
165 } OGREnvelope;
166 #endif
167 
168 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
169 
170 extern "C++" {
171 
172 /**
173  * Simple container for a bounding region in 3D.
174  */
175 class CPL_DLL OGREnvelope3D : public OGREnvelope
176 {
177   public:
178         /** Default constructor. Defines an empty rectangle  */
OGREnvelope3D()179         OGREnvelope3D() : OGREnvelope(),
180                           MinZ(std::numeric_limits<double>::infinity()),
181                           MaxZ(-std::numeric_limits<double>::infinity())
182         {
183         }
184 
185         /** Copy constructor */
OGREnvelope3D(const OGREnvelope3D & oOther)186         OGREnvelope3D(const OGREnvelope3D& oOther) :
187                             OGREnvelope(oOther),
188                             MinZ(oOther.MinZ), MaxZ(oOther.MaxZ)
189         {
190         }
191 
192         /** Assignment operator */
193         OGREnvelope3D& operator=(const OGREnvelope3D&) = default;
194 
195     /** Minimum Z value */
196     double      MinZ;
197 
198     /** Maximum Z value */
199     double      MaxZ;
200 
201 #ifdef HAVE_GCC_DIAGNOSTIC_PUSH
202 #pragma GCC diagnostic push
203 #pragma GCC diagnostic ignored "-Wfloat-equal"
204 #endif
205     /** Return whether the object has been initialized, that is, is non empty */
IsInit()206     int  IsInit() const { return MinX != std::numeric_limits<double>::infinity(); }
207 #ifdef HAVE_GCC_DIAGNOSTIC_PUSH
208 #pragma GCC diagnostic pop
209 #endif
210 
211     /** Update the current object by computing its union with the other rectangle */
Merge(OGREnvelope3D const & sOther)212     void Merge( OGREnvelope3D const& sOther ) {
213         MinX = MIN(MinX,sOther.MinX);
214         MaxX = MAX(MaxX,sOther.MaxX);
215         MinY = MIN(MinY,sOther.MinY);
216         MaxY = MAX(MaxY,sOther.MaxY);
217         MinZ = MIN(MinZ,sOther.MinZ);
218         MaxZ = MAX(MaxZ,sOther.MaxZ);
219     }
220 
221     /** Update the current object by computing its union with the provided point */
Merge(double dfX,double dfY,double dfZ)222     void Merge( double dfX, double dfY, double dfZ ) {
223         MinX = MIN(MinX,dfX);
224         MaxX = MAX(MaxX,dfX);
225         MinY = MIN(MinY,dfY);
226         MaxY = MAX(MaxY,dfY);
227         MinZ = MIN(MinZ,dfZ);
228         MaxZ = MAX(MaxZ,dfZ);
229     }
230 
231     /** Update the current object by computing its intersection with the other rectangle */
Intersect(OGREnvelope3D const & sOther)232     void Intersect( OGREnvelope3D const& sOther ) {
233         if(Intersects(sOther))
234         {
235             if( IsInit() )
236             {
237                 MinX = MAX(MinX,sOther.MinX);
238                 MaxX = MIN(MaxX,sOther.MaxX);
239                 MinY = MAX(MinY,sOther.MinY);
240                 MaxY = MIN(MaxY,sOther.MaxY);
241                 MinZ = MAX(MinZ,sOther.MinZ);
242                 MaxZ = MIN(MaxZ,sOther.MaxZ);
243             }
244             else
245             {
246                 MinX = sOther.MinX;
247                 MaxX = sOther.MaxX;
248                 MinY = sOther.MinY;
249                 MaxY = sOther.MaxY;
250                 MinZ = sOther.MinZ;
251                 MaxZ = sOther.MaxZ;
252             }
253         }
254         else
255         {
256             *this = OGREnvelope3D();
257         }
258     }
259 
260     /** Return whether the current object intersects with the other rectangle */
Intersects(OGREnvelope3D const & other)261     int Intersects(OGREnvelope3D const& other) const
262     {
263         return MinX <= other.MaxX && MaxX >= other.MinX &&
264                MinY <= other.MaxY && MaxY >= other.MinY &&
265                MinZ <= other.MaxZ && MaxZ >= other.MinZ;
266     }
267 
268     /** Return whether the current object contains the other rectangle */
Contains(OGREnvelope3D const & other)269     int Contains(OGREnvelope3D const& other) const
270     {
271         return MinX <= other.MinX && MinY <= other.MinY &&
272                MaxX >= other.MaxX && MaxY >= other.MaxY &&
273                MinZ <= other.MinZ && MaxZ >= other.MaxZ;
274     }
275 };
276 
277 } // extern "C++"
278 
279 #else
280 typedef struct
281 {
282     double      MinX;
283     double      MaxX;
284     double      MinY;
285     double      MaxY;
286     double      MinZ;
287     double      MaxZ;
288 } OGREnvelope3D;
289 #endif
290 
291 CPL_C_START
292 
293 /*! @cond Doxygen_Suppress */
294 void CPL_DLL *OGRMalloc( size_t ) CPL_WARN_DEPRECATED("Use CPLMalloc instead.");
295 void CPL_DLL *OGRCalloc( size_t, size_t ) CPL_WARN_DEPRECATED("Use CPLCalloc instead.");
296 void CPL_DLL *OGRRealloc( void *, size_t ) CPL_WARN_DEPRECATED("Use CPLRealloc instead.");
297 char CPL_DLL *OGRStrdup( const char * ) CPL_WARN_DEPRECATED("Use CPLStrdup instead.");
298 void CPL_DLL OGRFree( void * ) CPL_WARN_DEPRECATED("Use CPLFree instead.");
299 /*! @endcond */
300 
301 #ifdef STRICT_OGRERR_TYPE
302 /** Type for a OGR error */
303 typedef enum
304 {
305     OGRERR_NONE,                       /**< Success */
306     OGRERR_NOT_ENOUGH_DATA,            /**< Not enough data to deserialize */
307     OGRERR_NOT_ENOUGH_MEMORY,          /**< Not enough memory */
308     OGRERR_UNSUPPORTED_GEOMETRY_TYPE,  /**< Unsupported geometry type */
309     OGRERR_UNSUPPORTED_OPERATION,      /**< Unsupported operation */
310     OGRERR_CORRUPT_DATA,               /**< Corrupt data */
311     OGRERR_FAILURE,                    /**< Failure */
312     OGRERR_UNSUPPORTED_SRS,            /**< Unsupported SRS */
313     OGRERR_INVALID_HANDLE,             /**< Invalid handle */
314     OGRERR_NON_EXISTING_FEATURE        /**< Non existing feature. Added in GDAL 2.0 */
315 } OGRErr;
316 #else
317 /** Type for a OGR error */
318 typedef int OGRErr;
319 
320 #define OGRERR_NONE                0       /**< Success */
321 #define OGRERR_NOT_ENOUGH_DATA     1       /**< Not enough data to deserialize */
322 #define OGRERR_NOT_ENOUGH_MEMORY   2       /**< Not enough memory */
323 #define OGRERR_UNSUPPORTED_GEOMETRY_TYPE 3 /**< Unsupported geometry type */
324 #define OGRERR_UNSUPPORTED_OPERATION 4     /**< Unsupported operation */
325 #define OGRERR_CORRUPT_DATA        5       /**< Corrupt data */
326 #define OGRERR_FAILURE             6       /**< Failure */
327 #define OGRERR_UNSUPPORTED_SRS     7       /**< Unsupported SRS */
328 #define OGRERR_INVALID_HANDLE      8       /**< Invalid handle */
329 #define OGRERR_NON_EXISTING_FEATURE 9      /**< Non existing feature. Added in GDAL 2.0 */
330 
331 #endif
332 
333 /** Type for a OGR boolean */
334 typedef int     OGRBoolean;
335 
336 /* -------------------------------------------------------------------- */
337 /*      ogr_geometry.h related definitions.                             */
338 /* -------------------------------------------------------------------- */
339 
340 /**
341  * List of well known binary geometry types.  These are used within the BLOBs
342  * but are also returned from OGRGeometry::getGeometryType() to identify the
343  * type of a geometry object.
344  */
345 typedef enum
346 {
347     wkbUnknown = 0,         /**< unknown type, non-standard */
348 
349     wkbPoint = 1,           /**< 0-dimensional geometric object, standard WKB */
350     wkbLineString = 2,      /**< 1-dimensional geometric object with linear
351                              *   interpolation between Points, standard WKB */
352     wkbPolygon = 3,         /**< planar 2-dimensional geometric object defined
353                              *   by 1 exterior boundary and 0 or more interior
354                              *   boundaries, standard WKB */
355     wkbMultiPoint = 4,      /**< GeometryCollection of Points, standard WKB */
356     wkbMultiLineString = 5, /**< GeometryCollection of LineStrings, standard WKB */
357     wkbMultiPolygon = 6,    /**< GeometryCollection of Polygons, standard WKB */
358     wkbGeometryCollection = 7, /**< geometric object that is a collection of 1
359                                     or more geometric objects, standard WKB */
360 
361     wkbCircularString = 8,  /**< one or more circular arc segments connected end to end,
362                              *   ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
363     wkbCompoundCurve = 9,   /**< sequence of contiguous curves, ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
364     wkbCurvePolygon = 10,   /**< planar surface, defined by 1 exterior boundary
365                              *   and zero or more interior boundaries, that are curves.
366                              *    ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
367     wkbMultiCurve = 11,     /**< GeometryCollection of Curves, ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
368     wkbMultiSurface = 12,   /**< GeometryCollection of Surfaces, ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
369     wkbCurve = 13,          /**< Curve (abstract type). ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
370     wkbSurface = 14,        /**< Surface (abstract type). ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
371     wkbPolyhedralSurface = 15,/**< a contiguous collection of polygons, which share common boundary segments,
372                                *   ISO SQL/MM Part 3. GDAL &gt;= 2.3 */
373     wkbTIN = 16,              /**< a PolyhedralSurface consisting only of Triangle patches
374                                *    ISO SQL/MM Part 3. GDAL &gt;= 2.3 */
375     wkbTriangle = 17,         /**< a Triangle. ISO SQL/MM Part 3. GDAL &gt;= 2.3 */
376 
377     wkbNone = 100,          /**< non-standard, for pure attribute records */
378     wkbLinearRing = 101,    /**< non-standard, just for createGeometry() */
379 
380     wkbCircularStringZ = 1008,  /**< wkbCircularString with Z component. ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
381     wkbCompoundCurveZ = 1009,   /**< wkbCompoundCurve with Z component. ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
382     wkbCurvePolygonZ = 1010,    /**< wkbCurvePolygon with Z component. ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
383     wkbMultiCurveZ = 1011,      /**< wkbMultiCurve with Z component. ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
384     wkbMultiSurfaceZ = 1012,    /**< wkbMultiSurface with Z component. ISO SQL/MM Part 3. GDAL &gt;= 2.0 */
385     wkbCurveZ = 1013,           /**< wkbCurve with Z component. ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
386     wkbSurfaceZ = 1014,         /**< wkbSurface with Z component. ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
387     wkbPolyhedralSurfaceZ = 1015,  /**< ISO SQL/MM Part 3. GDAL &gt;= 2.3 */
388     wkbTINZ = 1016,                /**< ISO SQL/MM Part 3. GDAL &gt;= 2.3 */
389     wkbTriangleZ = 1017,           /**< ISO SQL/MM Part 3. GDAL &gt;= 2.3 */
390 
391     wkbPointM = 2001,              /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
392     wkbLineStringM = 2002,         /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
393     wkbPolygonM = 2003,            /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
394     wkbMultiPointM = 2004,         /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
395     wkbMultiLineStringM = 2005,    /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
396     wkbMultiPolygonM = 2006,       /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
397     wkbGeometryCollectionM = 2007, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
398     wkbCircularStringM = 2008,     /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
399     wkbCompoundCurveM = 2009,      /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
400     wkbCurvePolygonM = 2010,       /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
401     wkbMultiCurveM = 2011,         /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
402     wkbMultiSurfaceM = 2012,       /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
403     wkbCurveM = 2013,              /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
404     wkbSurfaceM = 2014,            /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
405     wkbPolyhedralSurfaceM = 2015,  /**< ISO SQL/MM Part 3. GDAL &gt;= 2.3 */
406     wkbTINM = 2016,                /**< ISO SQL/MM Part 3. GDAL &gt;= 2.3 */
407     wkbTriangleM = 2017,           /**< ISO SQL/MM Part 3. GDAL &gt;= 2.3 */
408 
409     wkbPointZM = 3001,              /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
410     wkbLineStringZM = 3002,         /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
411     wkbPolygonZM = 3003,            /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
412     wkbMultiPointZM = 3004,         /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
413     wkbMultiLineStringZM = 3005,    /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
414     wkbMultiPolygonZM = 3006,       /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
415     wkbGeometryCollectionZM = 3007, /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
416     wkbCircularStringZM = 3008,     /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
417     wkbCompoundCurveZM = 3009,      /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
418     wkbCurvePolygonZM = 3010,       /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
419     wkbMultiCurveZM = 3011,         /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
420     wkbMultiSurfaceZM = 3012,       /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
421     wkbCurveZM = 3013,              /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
422     wkbSurfaceZM = 3014,            /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
423     wkbPolyhedralSurfaceZM = 3015,  /**< ISO SQL/MM Part 3. GDAL &gt;= 2.3 */
424     wkbTINZM = 3016,                /**< ISO SQL/MM Part 3. GDAL &gt;= 2.3 */
425     wkbTriangleZM = 3017,           /**< ISO SQL/MM Part 3. GDAL &gt;= 2.3 */
426 
427 #if defined(DOXYGEN_SKIP)
428     // Sphinx doesn't like 0x8000000x constants
429     wkbPoint25D = -2147483647, /**< 2.5D extension as per 99-402 */
430     wkbLineString25D = -2147483646, /**< 2.5D extension as per 99-402 */
431     wkbPolygon25D = -2147483645, /**< 2.5D extension as per 99-402 */
432     wkbMultiPoint25D = -2147483644, /**< 2.5D extension as per 99-402 */
433     wkbMultiLineString25D = -2147483643, /**< 2.5D extension as per 99-402 */
434     wkbMultiPolygon25D = -2147483642, /**< 2.5D extension as per 99-402 */
435     wkbGeometryCollection25D = -2147483641 /**< 2.5D extension as per 99-402 */
436 #else
437     wkbPoint25D = 0x80000001, /**< 2.5D extension as per 99-402 */
438     wkbLineString25D = 0x80000002, /**< 2.5D extension as per 99-402 */
439     wkbPolygon25D = 0x80000003, /**< 2.5D extension as per 99-402 */
440     wkbMultiPoint25D = 0x80000004, /**< 2.5D extension as per 99-402 */
441     wkbMultiLineString25D = 0x80000005, /**< 2.5D extension as per 99-402 */
442     wkbMultiPolygon25D = 0x80000006, /**< 2.5D extension as per 99-402 */
443     wkbGeometryCollection25D = 0x80000007 /**< 2.5D extension as per 99-402 */
444 #endif
445 } OGRwkbGeometryType;
446 
447 /**
448  * Output variants of WKB we support.
449  *
450  * 99-402 was a short-lived extension to SFSQL 1.1 that used a high-bit flag
451  * to indicate the presence of Z coordinates in a WKB geometry.
452  *
453  * SQL/MM Part 3 and SFSQL 1.2 use offsets of 1000 (Z), 2000 (M) and 3000 (ZM)
454  * to indicate the present of higher dimensional coordinates in a WKB geometry.
455  * Reference: <a href="https://portal.opengeospatial.org/files/?artifact_id=320243">
456  * 09-009_Committee_Draft_ISOIEC_CD_13249-3_SQLMM_Spatial.pdf</a>,
457  * ISO/IEC JTC 1/SC 32 N 1820, ISO/IEC CD 13249-3:201x(E), Date: 2009-01-16.
458  * The codes are also found in §8.2.3 of <a href="http://portal.opengeospatial.org/files/?artifact_id=25355">
459  * OGC 06-103r4 "OpenGIS® Implementation Standard for Geographic information - Simple feature access - Part 1: Common architecture", v1.2.1</a>
460  */
461 typedef enum
462 {
463     wkbVariantOldOgc, /**< Old-style 99-402 extended dimension (Z) WKB types */
464     wkbVariantIso,  /**< SFSQL 1.2 and ISO SQL/MM Part 3 extended dimension (Z&M) WKB types */
465     wkbVariantPostGIS1 /**< PostGIS 1.X has different codes for CurvePolygon, MultiCurve and MultiSurface */
466 } OGRwkbVariant;
467 
468 #ifndef GDAL_COMPILATION
469 /** @deprecated in GDAL 2.0. Use wkbHasZ() or wkbSetZ() instead */
470 #define wkb25DBit 0x80000000
471 #endif
472 
473 #ifndef __cplusplus
474 /** Return the 2D geometry type corresponding to the specified geometry type */
475 #define wkbFlatten(x)  OGR_GT_Flatten((OGRwkbGeometryType)(x))
476 #else
477 /** Return the 2D geometry type corresponding to the specified geometry type */
478 #define wkbFlatten(x)  OGR_GT_Flatten(static_cast<OGRwkbGeometryType>(x))
479 #endif
480 
481 /** Return if the geometry type is a 3D geometry type
482   * @since GDAL 2.0
483   */
484 #define wkbHasZ(x)     (OGR_GT_HasZ(x) != 0)
485 
486 /** Return the 3D geometry type corresponding to the specified geometry type.
487   * @since GDAL 2.0
488   */
489 #define wkbSetZ(x)     OGR_GT_SetZ(x)
490 
491 /** Return if the geometry type is a measured geometry type
492   * @since GDAL 2.1
493   */
494 #define wkbHasM(x)     (OGR_GT_HasM(x) != 0)
495 
496 /** Return the measured geometry type corresponding to the specified geometry type.
497   * @since GDAL 2.1
498   */
499 #define wkbSetM(x)     OGR_GT_SetM(x)
500 
501 #ifndef DOXYGEN_SKIP
502 #define ogrZMarker 0x21125711
503 #endif
504 
505 const char CPL_DLL * OGRGeometryTypeToName( OGRwkbGeometryType eType );
506 OGRwkbGeometryType CPL_DLL OGRMergeGeometryTypes( OGRwkbGeometryType eMain,
507                                                   OGRwkbGeometryType eExtra );
508 OGRwkbGeometryType CPL_DLL OGRMergeGeometryTypesEx( OGRwkbGeometryType eMain,
509                                                     OGRwkbGeometryType eExtra,
510                                                     int bAllowPromotingToCurves );
511 OGRwkbGeometryType CPL_DLL OGR_GT_Flatten( OGRwkbGeometryType eType );
512 OGRwkbGeometryType CPL_DLL OGR_GT_SetZ( OGRwkbGeometryType eType );
513 OGRwkbGeometryType CPL_DLL OGR_GT_SetM( OGRwkbGeometryType eType );
514 OGRwkbGeometryType CPL_DLL OGR_GT_SetModifier( OGRwkbGeometryType eType, int bSetZ, int bSetM );
515 int                CPL_DLL OGR_GT_HasZ( OGRwkbGeometryType eType );
516 int                CPL_DLL OGR_GT_HasM( OGRwkbGeometryType eType );
517 int                CPL_DLL OGR_GT_IsSubClassOf( OGRwkbGeometryType eType,
518                                                 OGRwkbGeometryType eSuperType );
519 int                CPL_DLL OGR_GT_IsCurve( OGRwkbGeometryType );
520 int                CPL_DLL OGR_GT_IsSurface( OGRwkbGeometryType );
521 int                CPL_DLL OGR_GT_IsNonLinear( OGRwkbGeometryType );
522 OGRwkbGeometryType CPL_DLL OGR_GT_GetCollection( OGRwkbGeometryType eType );
523 OGRwkbGeometryType CPL_DLL OGR_GT_GetCurve( OGRwkbGeometryType eType );
524 OGRwkbGeometryType CPL_DLL OGR_GT_GetLinear( OGRwkbGeometryType eType );
525 
526 /** Enumeration to describe byte order */
527 typedef enum
528 {
529     wkbXDR = 0,         /**< MSB/Sun/Motorola: Most Significant Byte First   */
530     wkbNDR = 1          /**< LSB/Intel/Vax: Least Significant Byte First      */
531 } OGRwkbByteOrder;
532 
533 #ifndef DOXYGEN_SKIP
534 
535 #ifndef NO_HACK_FOR_IBM_DB2_V72
536 #  define HACK_FOR_IBM_DB2_V72
537 #endif
538 
539 #ifdef HACK_FOR_IBM_DB2_V72
540 #  define DB2_V72_FIX_BYTE_ORDER(x) ((((x) & 0x31) == (x)) ? ((x) & 0x1) : (x))
541 #  define DB2_V72_UNFIX_BYTE_ORDER(x) CPL_STATIC_CAST(unsigned char, OGRGeometry::bGenerate_DB2_V72_BYTE_ORDER ? ((x) | 0x30) : (x))
542 #else
543 #  define DB2_V72_FIX_BYTE_ORDER(x) (x)
544 #  define DB2_V72_UNFIX_BYTE_ORDER(x) (x)
545 #endif
546 
547 #endif /* #ifndef DOXYGEN_SKIP */
548 
549 /** Alter field name.
550  * Used by OGR_L_AlterFieldDefn().
551  */
552 #define ALTER_NAME_FLAG            0x1
553 
554 /** Alter field type.
555  * Used by OGR_L_AlterFieldDefn().
556  */
557 #define ALTER_TYPE_FLAG            0x2
558 
559 /** Alter field width and precision.
560  * Used by OGR_L_AlterFieldDefn().
561  */
562 #define ALTER_WIDTH_PRECISION_FLAG 0x4
563 
564 /** Alter field NOT NULL constraint.
565  * Used by OGR_L_AlterFieldDefn().
566  * @since GDAL 2.0
567  */
568 #define ALTER_NULLABLE_FLAG        0x8
569 
570 /** Alter field DEFAULT value.
571  * Used by OGR_L_AlterFieldDefn().
572  * @since GDAL 2.0
573  */
574 #define ALTER_DEFAULT_FLAG         0x10
575 
576 /** Alter field UNIQUE constraint.
577  * Used by OGR_L_AlterFieldDefn().
578  * @since GDAL 3.2
579  */
580 #define ALTER_UNIQUE_FLAG         0x20
581 
582 /** Alter field domain name.
583  * Used by OGR_L_AlterFieldDefn().
584  * @since GDAL 3.3
585  */
586 #define ALTER_DOMAIN_FLAG         0x40
587 
588 
589 /** Alter all parameters of field definition.
590  * Used by OGR_L_AlterFieldDefn().
591  */
592 #define ALTER_ALL_FLAG             (ALTER_NAME_FLAG | ALTER_TYPE_FLAG | ALTER_WIDTH_PRECISION_FLAG | ALTER_NULLABLE_FLAG | ALTER_DEFAULT_FLAG | ALTER_UNIQUE_FLAG | ALTER_DOMAIN_FLAG)
593 
594 /** Validate that fields respect not-null constraints.
595  * Used by OGR_F_Validate().
596  * @since GDAL 2.0
597  */
598 #define OGR_F_VAL_NULL           0x00000001
599 
600 /** Validate that geometries respect geometry column type.
601  * Used by OGR_F_Validate().
602  * @since GDAL 2.0
603  */
604 #define OGR_F_VAL_GEOM_TYPE      0x00000002
605 
606 /** Validate that (string) fields respect field width.
607  * Used by OGR_F_Validate().
608  * @since GDAL 2.0
609  */
610 #define OGR_F_VAL_WIDTH          0x00000004
611 
612 /** Allow fields that are null when there's an associated default value.
613  * This can be used for drivers where the low-level layers will automatically set the
614  * field value to the associated default value.
615  * This flag only makes sense if OGR_F_VAL_NULL is set too.
616  * Used by OGR_F_Validate().
617  * @since GDAL 2.0
618  */
619 #define OGR_F_VAL_ALLOW_NULL_WHEN_DEFAULT       0x00000008
620 
621 /** Allow geometry fields to have a different coordinate dimension that their
622  * geometry column type.
623  * This flag only makes sense if OGR_F_VAL_GEOM_TYPE is set too.
624  * Used by OGR_F_Validate().
625  * @since GDAL 2.1
626  */
627 #define OGR_F_VAL_ALLOW_DIFFERENT_GEOM_DIM       0x00000010
628 
629 /** Enable all validation tests (except OGR_F_VAL_ALLOW_DIFFERENT_GEOM_DIM)
630  * Used by OGR_F_Validate().
631  * @since GDAL 2.0
632  */
633 #define OGR_F_VAL_ALL            (0x7FFFFFFF & ~OGR_F_VAL_ALLOW_DIFFERENT_GEOM_DIM)
634 
635 /************************************************************************/
636 /*                  ogr_feature.h related definitions.                  */
637 /************************************************************************/
638 
639 /**
640  * List of feature field types.  This list is likely to be extended in the
641  * future ... avoid coding applications based on the assumption that all
642  * field types can be known.
643  */
644 
645 typedef enum
646 {
647   /** Simple 32bit integer */                   OFTInteger = 0,
648   /** List of 32bit integers */                 OFTIntegerList = 1,
649   /** Double Precision floating point */        OFTReal = 2,
650   /** List of doubles */                        OFTRealList = 3,
651   /** String of ASCII chars */                  OFTString = 4,
652   /** Array of strings */                       OFTStringList = 5,
653   /** deprecated */                             OFTWideString = 6,
654   /** deprecated */                             OFTWideStringList = 7,
655   /** Raw Binary data */                        OFTBinary = 8,
656   /** Date */                                   OFTDate = 9,
657   /** Time */                                   OFTTime = 10,
658   /** Date and Time */                          OFTDateTime = 11,
659   /** Single 64bit integer */                   OFTInteger64 = 12,
660   /** List of 64bit integers */                 OFTInteger64List = 13,
661                                                 OFTMaxType = 13
662 } OGRFieldType;
663 
664 /**
665  * List of field subtypes. A subtype represents a hint, a restriction of the
666  * main type, that is not strictly necessary to consult.
667  * This list is likely to be extended in the
668  * future ... avoid coding applications based on the assumption that all
669  * field types can be known.
670  * Most subtypes only make sense for a restricted set of main types.
671  * @since GDAL 2.0
672  */
673 typedef enum
674 {
675     /** No subtype. This is the default value */        OFSTNone = 0,
676     /** Boolean integer. Only valid for OFTInteger and OFTIntegerList.*/
677                                                         OFSTBoolean = 1,
678     /** Signed 16-bit integer. Only valid for OFTInteger and OFTIntegerList. */
679                                                         OFSTInt16 = 2,
680     /** Single precision (32 bit) floating point. Only valid for OFTReal and OFTRealList. */
681                                                         OFSTFloat32 = 3,
682     /** JSON content. Only valid for OFTString.
683      * @since GDAL 2.4
684      */
685                                                         OFSTJSON = 4,
686     /** UUID string representation. Only valid for OFTString.
687      * @since GDAL 3.3
688      */
689                                                         OFSTUUID = 5,
690                                                         OFSTMaxSubType = 5
691 } OGRFieldSubType;
692 
693 /**
694  * Display justification for field values.
695  */
696 
697 typedef enum
698 {
699     OJUndefined = 0,
700     OJLeft = 1,
701     OJRight = 2
702 } OGRJustification;
703 
704 /** Special value for a unset FID */
705 #define OGRNullFID            -1
706 
707 /* Special value for an unknown field type. This should only be used
708  * while reading a file. At the end of file any unknown types should
709  * be set to OFTString.
710 */
711 /*! @cond Doxygen_Suppress */
712 #define OGRUnknownType        static_cast<OGRFieldType>(-1)
713 /*! @endcond */
714 
715 /** Special value set in OGRField.Set.nMarker1, nMarker2 and nMarker3 for
716  *  a unset field.
717  *  Direct use of this value is strongly discouraged.
718  *  Use OGR_RawField_SetUnset() or OGR_RawField_IsUnset() instead.
719  */
720 #define OGRUnsetMarker        -21121
721 
722 /** Special value set in OGRField.Set.nMarker1, nMarker2 and nMarker3 for
723  *  a null field.
724  *  Direct use of this value is strongly discouraged.
725  *  Use OGR_RawField_SetNull() or OGR_RawField_IsNull() instead.
726  *  @since GDAL 2.2
727  */
728 #define OGRNullMarker         -21122
729 
730 /************************************************************************/
731 /*                               OGRField                               */
732 /************************************************************************/
733 
734 /**
735  * OGRFeature field attribute value union.
736  */
737 
738 typedef union {
739 /*! @cond Doxygen_Suppress */
740     int         Integer;
741     GIntBig     Integer64;
742     double      Real;
743     char       *String;
744 
745     struct {
746         int     nCount;
747         int     *paList;
748     } IntegerList;
749 
750     struct {
751         int     nCount;
752         GIntBig *paList;
753     } Integer64List;
754 
755     struct {
756         int     nCount;
757         double  *paList;
758     } RealList;
759 
760     struct {
761         int     nCount;
762         char    **paList;
763     } StringList;
764 
765     struct {
766         int     nCount;
767         GByte   *paData;
768     } Binary;
769 
770     struct {
771         int     nMarker1;
772         int     nMarker2;
773         int     nMarker3;
774     } Set;
775 
776     struct {
777         GInt16  Year;
778         GByte   Month;
779         GByte   Day;
780         GByte   Hour;
781         GByte   Minute;
782         GByte   TZFlag; /* 0=unknown, 1=localtime(ambiguous),
783                            100=GMT, 104=GMT+1, 80=GMT-5, etc */
784         GByte   Reserved; /* must be set to 0 */
785         float   Second; /* with millisecond accuracy. at the end of the structure, so as to keep it 12 bytes on 32 bit */
786     } Date;
787 /*! @endcond */
788 } OGRField;
789 
790 #ifdef __cplusplus
791 /** Return the number of milliseconds from a datetime with decimal seconds */
OGR_GET_MS(float fSec)792 inline int OGR_GET_MS(float fSec) {
793   if( CPLIsNan(fSec) ) return 0;
794   if( fSec >= 999 ) return 999;
795   if( fSec <= 0 ) return 0;
796   const float fValue = (fSec - static_cast<int>(fSec)) * 1000 + 0.5f;
797   return static_cast<int>(fValue);
798 }
799 #endif  // __cplusplus
800 
801 int CPL_DLL OGRParseDate( const char *pszInput, OGRField *psOutput,
802                           int nOptions );
803 
804 /* -------------------------------------------------------------------- */
805 /*      Constants from ogrsf_frmts.h for capabilities.                  */
806 /* -------------------------------------------------------------------- */
807 #define OLCRandomRead          "RandomRead"         /**< Layer capability for random read */
808 #define OLCSequentialWrite     "SequentialWrite"    /**< Layer capability for sequential write */
809 #define OLCRandomWrite         "RandomWrite"        /**< Layer capability for random write */
810 #define OLCFastSpatialFilter   "FastSpatialFilter"  /**< Layer capability for fast spatial filter */
811 #define OLCFastFeatureCount    "FastFeatureCount"   /**< Layer capability for fast feature count retrieval */
812 #define OLCFastGetExtent       "FastGetExtent"      /**< Layer capability for fast extent retrieval */
813 #define OLCCreateField         "CreateField"        /**< Layer capability for field creation */
814 #define OLCDeleteField         "DeleteField"        /**< Layer capability for field deletion */
815 #define OLCReorderFields       "ReorderFields"      /**< Layer capability for field reordering */
816 #define OLCAlterFieldDefn      "AlterFieldDefn"     /**< Layer capability for field alteration */
817 #define OLCTransactions        "Transactions"       /**< Layer capability for transactions */
818 #define OLCDeleteFeature       "DeleteFeature"      /**< Layer capability for feature deletion */
819 #define OLCFastSetNextByIndex  "FastSetNextByIndex" /**< Layer capability for setting next feature index */
820 #define OLCStringsAsUTF8       "StringsAsUTF8"      /**< Layer capability for strings returned with UTF-8 encoding */
821 #define OLCIgnoreFields        "IgnoreFields"       /**< Layer capability for field ignoring */
822 #define OLCCreateGeomField     "CreateGeomField"    /**< Layer capability for geometry field creation */
823 #define OLCCurveGeometries     "CurveGeometries"    /**< Layer capability for curve geometries support */
824 #define OLCMeasuredGeometries  "MeasuredGeometries" /**< Layer capability for measured geometries support */
825 
826 #define ODsCCreateLayer        "CreateLayer"        /**< Dataset capability for layer creation */
827 #define ODsCDeleteLayer        "DeleteLayer"        /**< Dataset capability for layer deletion */
828 #define ODsCCreateGeomFieldAfterCreateLayer   "CreateGeomFieldAfterCreateLayer" /**< Dataset capability for geometry field creation support */
829 #define ODsCCurveGeometries    "CurveGeometries"    /**< Dataset capability for curve geometries support */
830 #define ODsCTransactions       "Transactions"       /**< Dataset capability for dataset transcations */
831 #define ODsCEmulatedTransactions "EmulatedTransactions" /**< Dataset capability for emulated dataset transactions */
832 #define ODsCMeasuredGeometries "MeasuredGeometries"     /**< Dataset capability for measured geometries support */
833 #define ODsCRandomLayerRead     "RandomLayerRead"   /**< Dataset capability for GetNextFeature() returning features from random layers */
834 /* Note the unfortunate trailing space at the end of the string */
835 #define ODsCRandomLayerWrite    "RandomLayerWrite " /**< Dataset capability for supporting CreateFeature on layer in random order */
836 #define ODsCAddFieldDomain     "AddFieldDomain"    /**< Dataset capability for supporting AddFieldDomain() (at least partially) */
837 
838 #define ODrCCreateDataSource   "CreateDataSource"   /**< Driver capability for datasource creation */
839 #define ODrCDeleteDataSource   "DeleteDataSource"   /**< Driver capability for datasource deletion */
840 
841 /* -------------------------------------------------------------------- */
842 /*      Layer metadata items.                                           */
843 /* -------------------------------------------------------------------- */
844 /** Capability set to YES as metadata on a layer that has features with
845   * 64 bit identifiers.
846   @since GDAL 2.0
847   */
848 #define OLMD_FID64             "OLMD_FID64"
849 
850 /************************************************************************/
851 /*                  ogr_featurestyle.h related definitions.             */
852 /************************************************************************/
853 
854 /**
855  * OGRStyleTool derived class types (returned by GetType()).
856  */
857 
858 typedef enum ogr_style_tool_class_id
859 {
860     OGRSTCNone   = 0, /**< None */
861     OGRSTCPen    = 1, /**< Pen */
862     OGRSTCBrush  = 2, /**< Brush */
863     OGRSTCSymbol = 3, /**< Symbol */
864     OGRSTCLabel  = 4, /**< Label */
865     OGRSTCVector = 5  /**< Vector */
866 } OGRSTClassId;
867 
868 /**
869  * List of units supported by OGRStyleTools.
870  */
871 typedef enum ogr_style_tool_units_id
872 {
873     OGRSTUGround = 0, /**< Ground unit */
874     OGRSTUPixel  = 1, /**< Pixel */
875     OGRSTUPoints = 2, /**< Points */
876     OGRSTUMM     = 3, /**< Millimeter */
877     OGRSTUCM     = 4, /**< Centimeter */
878     OGRSTUInches = 5  /**< Inch */
879 } OGRSTUnitId;
880 
881 /**
882  * List of parameters for use with OGRStylePen.
883  */
884 typedef enum ogr_style_tool_param_pen_id
885 {
886     OGRSTPenColor       = 0, /**< Color */
887     OGRSTPenWidth       = 1, /**< Width */
888     OGRSTPenPattern     = 2, /**< Pattern */
889     OGRSTPenId          = 3, /**< Id */
890     OGRSTPenPerOffset   = 4, /**< Perpendicular offset */
891     OGRSTPenCap         = 5, /**< Cap */
892     OGRSTPenJoin        = 6, /**< Join */
893     OGRSTPenPriority    = 7, /**< Priority */
894 #ifndef DOXYGEN_SKIP
895     OGRSTPenLast        = 8
896 #endif
897 } OGRSTPenParam;
898 
899 /**
900  * List of parameters for use with OGRStyleBrush.
901  */
902 typedef enum ogr_style_tool_param_brush_id
903 {
904     OGRSTBrushFColor    = 0, /**< Foreground color */
905     OGRSTBrushBColor    = 1, /**< Background color */
906     OGRSTBrushId        = 2, /**< Id */
907     OGRSTBrushAngle     = 3, /**< Angle */
908     OGRSTBrushSize      = 4, /**< Size */
909     OGRSTBrushDx        = 5, /**< Dx */
910     OGRSTBrushDy        = 6, /**< Dy */
911     OGRSTBrushPriority  = 7, /**< Priority */
912 #ifndef DOXYGEN_SKIP
913     OGRSTBrushLast      = 8
914 #endif
915 
916 } OGRSTBrushParam;
917 
918 /**
919  * List of parameters for use with OGRStyleSymbol.
920  */
921 typedef enum ogr_style_tool_param_symbol_id
922 {
923     OGRSTSymbolId       = 0, /**< Id */
924     OGRSTSymbolAngle    = 1, /**< Angle */
925     OGRSTSymbolColor    = 2, /**< Color */
926     OGRSTSymbolSize     = 3, /**< Size */
927     OGRSTSymbolDx       = 4, /**< Dx */
928     OGRSTSymbolDy       = 5, /**< Dy */
929     OGRSTSymbolStep     = 6, /**< Step */
930     OGRSTSymbolPerp     = 7, /**< Perpendicular */
931     OGRSTSymbolOffset   = 8, /**< Offset */
932     OGRSTSymbolPriority = 9, /**< Priority */
933     OGRSTSymbolFontName = 10, /**< Font name */
934     OGRSTSymbolOColor   = 11, /**< Outline color */
935 #ifndef DOXYGEN_SKIP
936     OGRSTSymbolLast     = 12
937 #endif
938 } OGRSTSymbolParam;
939 
940 /**
941  * List of parameters for use with OGRStyleLabel.
942  */
943 typedef enum ogr_style_tool_param_label_id
944 {
945     OGRSTLabelFontName  = 0, /**< Font name */
946     OGRSTLabelSize      = 1, /**< Size */
947     OGRSTLabelTextString = 2, /**< Text string */
948     OGRSTLabelAngle     = 3, /**< Angle */
949     OGRSTLabelFColor    = 4, /**< Foreground color */
950     OGRSTLabelBColor    = 5, /**< Background color */
951     OGRSTLabelPlacement = 6, /**< Placement */
952     OGRSTLabelAnchor    = 7, /**< Anchor */
953     OGRSTLabelDx        = 8, /**< Dx */
954     OGRSTLabelDy        = 9, /**< Dy */
955     OGRSTLabelPerp      = 10, /**< Perpendicular */
956     OGRSTLabelBold      = 11, /**< Bold */
957     OGRSTLabelItalic    = 12, /**< Italic */
958     OGRSTLabelUnderline = 13, /**< Underline */
959     OGRSTLabelPriority  = 14, /**< Priority */
960     OGRSTLabelStrikeout = 15, /**< Strike out */
961     OGRSTLabelStretch   = 16, /**< Stretch */
962     OGRSTLabelAdjHor    = 17, /**< OBSOLETE; do not use */
963     OGRSTLabelAdjVert   = 18, /**< OBSOLETE; do not use */
964     OGRSTLabelHColor    = 19, /**< Highlight color */
965     OGRSTLabelOColor    = 20, /**< Outline color */
966 #ifndef DOXYGEN_SKIP
967     OGRSTLabelLast      = 21
968 #endif
969 } OGRSTLabelParam;
970 
971 /* -------------------------------------------------------------------- */
972 /*                          Field domains                               */
973 /* -------------------------------------------------------------------- */
974 
975 /** Associates a code and a value
976  *
977  * @since GDAL 3.3
978  */
979 typedef struct
980 {
981     /** Code. Content should be of the type of the OGRFieldDomain */
982     char* pszCode;
983 
984     /** Value. Might be NULL */
985     char* pszValue;
986 } OGRCodedValue;
987 
988 /** Type of field domain.
989  *
990  * @since GDAL 3.3
991  */
992 typedef enum
993 {
994     /** Coded */
995     OFDT_CODED,
996     /** Range (min/max) */
997     OFDT_RANGE,
998     /** Glob (used by GeoPackage) */
999     OFDT_GLOB
1000 } OGRFieldDomainType;
1001 
1002 /** Split policy for field domains.
1003  *
1004  * When a feature is split in two, defines how the value of attributes
1005  * following the domain are computed.
1006  *
1007  * @since GDAL 3.3
1008  */
1009 typedef enum
1010 {
1011     /** Default value */
1012     OFDSP_DEFAULT_VALUE,
1013     /** Duplicate */
1014     OFDSP_DUPLICATE,
1015     /** New values are computed by the ratio of their area/length compared to the area/length of the original feature */
1016     OFDSP_GEOMETRY_RATIO
1017 } OGRFieldDomainSplitPolicy;
1018 
1019 /** Merge policy for field domains.
1020  *
1021  * When a feature is built by merging two features, defines how the value of
1022  * attributes following the domain are computed.
1023  *
1024  * @since GDAL 3.3
1025  */
1026 typedef enum
1027 {
1028     /** Default value */
1029     OFDMP_DEFAULT_VALUE,
1030     /** Sum */
1031     OFDMP_SUM,
1032     /** New values are computed as the weighted average of the source values. */
1033     OFDMP_GEOMETRY_WEIGHTED
1034 } OGRFieldDomainMergePolicy;
1035 
1036 /* ------------------------------------------------------------------- */
1037 /*                        Version checking                             */
1038 /* -------------------------------------------------------------------- */
1039 
1040 #ifndef DOXYGEN_SKIP
1041 
1042 /* Note to developers : please keep this section in sync with gdal.h */
1043 
1044 #ifndef GDAL_VERSION_INFO_DEFINED
1045 #define GDAL_VERSION_INFO_DEFINED
1046 const char CPL_DLL * CPL_STDCALL GDALVersionInfo( const char * );
1047 #endif
1048 
1049 #ifndef GDAL_CHECK_VERSION
1050 
1051 /** Return TRUE if GDAL library version at runtime matches nVersionMajor.nVersionMinor.
1052 
1053     The purpose of this method is to ensure that calling code will run with the GDAL
1054     version it is compiled for. It is primarily indented for external plugins.
1055 
1056     @param nVersionMajor Major version to be tested against
1057     @param nVersionMinor Minor version to be tested against
1058     @param pszCallingComponentName If not NULL, in case of version mismatch, the method
1059                                    will issue a failure mentioning the name of
1060                                    the calling component.
1061   */
1062 int CPL_DLL CPL_STDCALL GDALCheckVersion( int nVersionMajor, int nVersionMinor,
1063                                           const char* pszCallingComponentName);
1064 
1065 /** Helper macro for GDALCheckVersion */
1066 #define GDAL_CHECK_VERSION(pszCallingComponentName) \
1067  GDALCheckVersion(GDAL_VERSION_MAJOR, GDAL_VERSION_MINOR, pszCallingComponentName)
1068 
1069 #endif
1070 
1071 #endif /* #ifndef DOXYGEN_SKIP */
1072 
1073 CPL_C_END
1074 
1075 #endif /* ndef OGR_CORE_H_INCLUDED */
1076