Coverage Report

Created: 2025-06-13 06:29

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