14#ifndef OGR_P_H_INCLUDED
15#define OGR_P_H_INCLUDED
24#ifdef OGR_P_WITH_SRS_CACHE
25#include "cpl_mem_cache.h"
40#define OGR_GEOMETRY_DEFAULT_NON_EMPTY_NAME "_ogr_geometry_"
43#define OGR_SWAP(x) (x == wkbNDR)
45#define OGR_SWAP(x) (x == wkbXDR)
49#define POSTGIS15_CURVEPOLYGON 13
50#define POSTGIS15_MULTICURVE 14
51#define POSTGIS15_MULTISURFACE 15
54#ifdef GDAL_COMPILATION
55#define wkb25DBitInternalUse 0x80000000
62#ifdef OGR_GEOMETRY_H_INCLUDED
63#define OGR_WKT_TOKEN_MAX 64
65const char CPL_DLL *OGRWktReadToken(
const char *pszInput,
char *pszToken);
67const char CPL_DLL *OGRWktReadPoints(
const char *pszInput,
69 int *pnMaxPoints,
int *pnReadPoints);
72OGRWktReadPointsM(
const char *pszInput,
OGRRawPoint **ppaoPoints,
73 double **ppadfZ,
double **ppadfM,
76 int *pnMaxPoints,
int *pnReadPoints);
78void CPL_DLL OGRMakeWktCoordinate(
char *,
double,
double,
double,
int);
79std::string CPL_DLL OGRMakeWktCoordinate(
double,
double,
double,
int,
81void CPL_DLL OGRMakeWktCoordinateM(
char *,
double,
double,
double,
double,
83std::string CPL_DLL OGRMakeWktCoordinateM(
double,
double,
double,
double,
89void CPL_DLL OGRFormatDouble(
char *pszBuffer,
int nBufferLen,
double dfVal,
90 char chDecimalSep,
int nPrecision = 15,
91 char chConversionSpecifier =
'f');
93#ifdef OGR_GEOMETRY_H_INCLUDED
94std::string CPL_DLL OGRFormatDouble(
double val,
const OGRWktOptions &opts,
98int OGRFormatFloat(
char *pszBuffer,
int nBufferLen,
float fVal,
int nPrecision,
99 char chConversionSpecifier);
108int CPL_DLL OGRTimezoneToTZFlag(
const char *pszTZ,
109 bool bEmitErrorIfUnhandledFormat);
110std::string CPL_DLL OGRTZFlagToTimezone(
int nTZFlag,
111 const char *pszUTCRepresentation);
113int CPL_DLL OGRGetDayOfWeek(
int day,
int month,
int year);
114int CPL_DLL OGRParseXMLDateTime(
const char *pszXMLDateTime,
OGRField *psField);
115int CPL_DLL OGRParseRFC822DateTime(
const char *pszRFC822DateTime,
117char CPL_DLL *OGRGetRFC822DateTime(
const OGRField *psField);
118char CPL_DLL *OGRGetXMLDateTime(
const OGRField *psField);
119char CPL_DLL *OGRGetXMLDateTime(
const OGRField *psField,
120 bool bAlwaysMillisecond);
122#define OGR_SIZEOF_ISO8601_DATETIME_BUFFER 30
124OGRGetISO8601DateTime(
const OGRField *psField,
bool bAlwaysMillisecond,
125 char szBuffer[OGR_SIZEOF_ISO8601_DATETIME_BUFFER]);
128enum class OGRISO8601Precision
149 char szBuffer[OGR_SIZEOF_ISO8601_DATETIME_BUFFER]);
150char CPL_DLL *OGRGetXML_UTF8_EscapedString(
const char *pszString);
152#ifdef GDAL_COMPILATION
153bool CPL_DLL OGRParseDateTimeYYYYMMDDTHHMMZ(std::string_view sInput,
155bool CPL_DLL OGRParseDateTimeYYYYMMDDTHHMMSSZ(std::string_view sInput,
157bool CPL_DLL OGRParseDateTimeYYYYMMDDTHHMMSSsssZ(std::string_view sInput,
161int OGRCompareDate(
const OGRField *psFirstTuple,
166int CPL_DLL OGRGeneralCmdLineProcessor(
int nArgc,
char ***ppapszArgv,
173#define SPF_OGR_GEOMETRY 1
174#define SPF_OGR_STYLE 2
175#define SPF_OGR_GEOM_WKT 3
176#define SPF_OGR_GEOM_AREA 4
177#define SPECIAL_FIELD_COUNT 5
179extern const char *
const SpecialFieldNames[SPECIAL_FIELD_COUNT];
185OGRErr CPL_DLL OSRGetEllipsoidInfo(
int,
char **,
double *,
double *);
188double OGRFastAtof(
const char *pszStr);
190OGRErr CPL_DLL OGRCheckPermutation(
const int *panPermutation,
int nSize);
195 const CPLXMLNode *psNode,
int nPseudoBoolGetSecondaryGeometryOption,
196 int nRecLevel = 0,
int nSRSDimension = 0,
bool bIgnoreGSG =
false,
197 bool bOrientation =
true,
bool bFaceHoleNegative =
false,
198 const char *pszId =
nullptr);
200#ifdef OGR_P_WITH_SRS_CACHE
202 const CPLXMLNode *psNode,
int nPseudoBoolGetSecondaryGeometryOption,
203 lru11::Cache<std::string, std::shared_ptr<OGRSpatialReference>> &oSRSCache,
204 int nRecLevel = 0,
int nSRSDimension = 0,
bool bIgnoreGSG =
false,
205 bool bOrientation =
true,
bool bFaceHoleNegative =
false,
206 const char *pszId =
nullptr);
214 int *pnSRID,
int bIsPostGIS1_EWKB);
215OGRGeometry CPL_DLL *OGRGeometryFromHexEWKB(
const char *pszBytea,
int *pnSRID,
216 int bIsPostGIS1_EWKB);
217char CPL_DLL *OGRGeometryToHexEWKB(
OGRGeometry *poGeometry,
int nSRSId,
218 int nPostGISMajor,
int nPostGISMinor);
224OGRErr CPL_DLL OGRReadWKBGeometryType(
const unsigned char *pabyData,
232OGRErr CPL_DLL OGRReadWKTGeometryType(
const char *pszWKT,
254inline uint64_t OGRRoundValueIEEE754(uint64_t nVal,
257inline uint64_t OGRRoundValueIEEE754(uint64_t nVal,
int nBitsPrecision)
259 constexpr int MANTISSA_SIZE = std::numeric_limits<double>::digits - 1;
260 constexpr int MAX_EXPONENT = std::numeric_limits<double>::max_exponent;
261#if __cplusplus >= 201703L
262 static_assert(MANTISSA_SIZE == 52);
263 static_assert(MAX_EXPONENT == 1024);
266 const int nExponent =
267 ((nVal >> MANTISSA_SIZE) & (2 * MAX_EXPONENT - 1)) - (MAX_EXPONENT - 1);
269 const int nBitsRequired = 1 + nExponent + nBitsPrecision;
271 int nNullifiedBits = MANTISSA_SIZE - nBitsRequired;
274 if (nNullifiedBits <= 0)
276 if (nNullifiedBits >= MANTISSA_SIZE)
277 nNullifiedBits = MANTISSA_SIZE;
278 nVal >>= nNullifiedBits;
279 nVal <<= nNullifiedBits;
291template <
int SPACING>
292inline void OGRRoundCoordinatesIEEE754XYValues(
int nBitsPrecision,
293 GByte *pabyBase,
size_t nPoints)
297 if (nBitsPrecision != INT_MIN)
299 for (
size_t i = 0; i < nPoints; i++)
303 memcpy(&nVal, pabyBase + SPACING * i,
sizeof(uint64_t));
304 nVal = OGRRoundValueIEEE754(nVal, nBitsPrecision);
305 memcpy(pabyBase + SPACING * i, &nVal,
sizeof(uint64_t));
307 memcpy(&nVal, pabyBase +
sizeof(uint64_t) + SPACING * i,
309 nVal = OGRRoundValueIEEE754(nVal, nBitsPrecision);
310 memcpy(pabyBase +
sizeof(uint64_t) + SPACING * i, &nVal,
324template <
int SPACING>
325inline void OGRRoundCoordinatesIEEE754(
int nBitsPrecision,
GByte *pabyBase,
328 if (nBitsPrecision != INT_MIN)
330 for (
size_t i = 0; i < nPoints; i++)
334 memcpy(&nVal, pabyBase + SPACING * i,
sizeof(uint64_t));
335 nVal = OGRRoundValueIEEE754(nVal, nBitsPrecision);
336 memcpy(pabyBase + SPACING * i, &nVal,
sizeof(uint64_t));
348std::string CPL_DLL OGRDuplicateCharacter(
const std::string &osStr,
char ch);
Definition of an attribute of an OGRFeatureDefn.
Definition ogr_feature.h:69
Abstract base class for all geometry classes.
Definition ogr_geometry.h:357
Simple container for a position.
Definition ogr_geometry.h:89
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition ogr_spatialref.h:152
Options for formatting WKT output.
Definition ogr_geometry.h:46
Various convenience functions for CPL.
Definitions for CPL mini XML Parser/Serializer.
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition cpl_port.h:870
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:175
Various convenience functions for working with strings and string lists.
Core portability services for cross-platform OGR code.
int OGRBoolean
Type for a OGR boolean.
Definition ogr_core.h:386
OGRFieldSubType
List of field subtypes.
Definition ogr_core.h:799
OGRwkbVariant
Output variants of WKB we support.
Definition ogr_core.h:540
OGRFieldType
List of feature field types.
Definition ogr_core.h:772
OGRwkbGeometryType
List of well known binary geometry types.
Definition ogr_core.h:405
int OGRErr
Type for a OGR error.
Definition ogr_core.h:370
Document node structure.
Definition cpl_minixml.h:54
OGRFeature field attribute value union.
Definition ogr_core.h:886