Coverage Report

Created: 2025-12-31 06:48

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