Coverage Report

Created: 2025-11-16 06:25

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