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