31#ifndef OGR_P_H_INCLUDED
32#define OGR_P_H_INCLUDED
51#define OGR_GEOMETRY_DEFAULT_NON_EMPTY_NAME "_ogr_geometry_"
54#define OGR_SWAP(x) (x == wkbNDR)
56#define OGR_SWAP(x) (x == wkbXDR)
60#define POSTGIS15_CURVEPOLYGON 13
61#define POSTGIS15_MULTICURVE 14
62#define POSTGIS15_MULTISURFACE 15
65#ifdef GDAL_COMPILATION
66#define wkb25DBitInternalUse 0x80000000
73#ifdef OGR_GEOMETRY_H_INCLUDED
74#define OGR_WKT_TOKEN_MAX 64
76const char CPL_DLL *OGRWktReadToken(
const char *pszInput,
char *pszToken);
78const char CPL_DLL *OGRWktReadPoints(
const char *pszInput,
80 int *pnMaxPoints,
int *pnReadPoints);
83OGRWktReadPointsM(
const char *pszInput,
OGRRawPoint **ppaoPoints,
84 double **ppadfZ,
double **ppadfM,
87 int *pnMaxPoints,
int *pnReadPoints);
89void CPL_DLL OGRMakeWktCoordinate(
char *,
double,
double,
double,
int);
90std::string CPL_DLL OGRMakeWktCoordinate(
double,
double,
double,
int,
92void CPL_DLL OGRMakeWktCoordinateM(
char *,
double,
double,
double,
double,
94std::string CPL_DLL OGRMakeWktCoordinateM(
double,
double,
double,
double,
100void CPL_DLL OGRFormatDouble(
char *pszBuffer,
int nBufferLen,
double dfVal,
101 char chDecimalSep,
int nPrecision = 15,
102 char chConversionSpecifier =
'f');
104#ifdef OGR_GEOMETRY_H_INCLUDED
105std::string CPL_DLL OGRFormatDouble(
double val,
const OGRWktOptions &opts,
109int OGRFormatFloat(
char *pszBuffer,
int nBufferLen,
float fVal,
int nPrecision,
110 char chConversionSpecifier);
119int CPL_DLL OGRTimezoneToTZFlag(
const char *pszTZ,
120 bool bEmitErrorIfUnhandledFormat);
121std::string CPL_DLL OGRTZFlagToTimezone(
int nTZFlag,
122 const char *pszUTCRepresentation);
124int CPL_DLL OGRGetDayOfWeek(
int day,
int month,
int year);
125int CPL_DLL OGRParseXMLDateTime(
const char *pszXMLDateTime,
OGRField *psField);
126int CPL_DLL OGRParseRFC822DateTime(
const char *pszRFC822DateTime,
128char CPL_DLL *OGRGetRFC822DateTime(
const OGRField *psField);
129char CPL_DLL *OGRGetXMLDateTime(
const OGRField *psField);
130char CPL_DLL *OGRGetXMLDateTime(
const OGRField *psField,
131 bool bAlwaysMillisecond);
133#define OGR_SIZEOF_ISO8601_DATETIME_BUFFER 30
135OGRGetISO8601DateTime(
const OGRField *psField,
bool bAlwaysMillisecond,
136 char szBuffer[OGR_SIZEOF_ISO8601_DATETIME_BUFFER]);
139enum class OGRISO8601Precision
160 char szBuffer[OGR_SIZEOF_ISO8601_DATETIME_BUFFER]);
161char CPL_DLL *OGRGetXML_UTF8_EscapedString(
const char *pszString);
162bool CPL_DLL OGRParseDateTimeYYYYMMDDTHHMMZ(
const char *pszInput,
size_t nLen,
164bool CPL_DLL OGRParseDateTimeYYYYMMDDTHHMMSSZ(
const char *pszInput,
size_t nLen,
166bool CPL_DLL OGRParseDateTimeYYYYMMDDTHHMMSSsssZ(
const char *pszInput,
170int OGRCompareDate(
const OGRField *psFirstTuple,
175int CPL_DLL OGRGeneralCmdLineProcessor(
int nArgc,
char ***ppapszArgv,
182#define SPF_OGR_GEOMETRY 1
183#define SPF_OGR_STYLE 2
184#define SPF_OGR_GEOM_WKT 3
185#define SPF_OGR_GEOM_AREA 4
186#define SPECIAL_FIELD_COUNT 5
188extern const char *
const SpecialFieldNames[SPECIAL_FIELD_COUNT];
194OGRErr CPL_DLL OSRGetEllipsoidInfo(
int,
char **,
double *,
double *);
197double OGRFastAtof(
const char *pszStr);
199OGRErr CPL_DLL OGRCheckPermutation(
const int *panPermutation,
int nSize);
204 int nPseudoBoolGetSecondaryGeometryOption,
205 int nRecLevel = 0,
int nSRSDimension = 0,
206 bool bIgnoreGSG =
false,
207 bool bOrientation =
true,
208 bool bFaceHoleNegative =
false);
215 int *pnSRID,
int bIsPostGIS1_EWKB);
216OGRGeometry CPL_DLL *OGRGeometryFromHexEWKB(
const char *pszBytea,
int *pnSRID,
217 int bIsPostGIS1_EWKB);
218char CPL_DLL *OGRGeometryToHexEWKB(
OGRGeometry *poGeometry,
int nSRSId,
219 int nPostGISMajor,
int nPostGISMinor);
225OGRErr CPL_DLL OGRReadWKBGeometryType(
const unsigned char *pabyData,
233OGRErr CPL_DLL OGRReadWKTGeometryType(
const char *pszWKT,
255inline uint64_t OGRRoundValueIEEE754(uint64_t nVal,
258inline uint64_t OGRRoundValueIEEE754(uint64_t nVal,
int nBitsPrecision)
260 constexpr int MANTISSA_SIZE = std::numeric_limits<double>::digits - 1;
261 constexpr int MAX_EXPONENT = std::numeric_limits<double>::max_exponent;
262#if __cplusplus >= 201703L
263 static_assert(MANTISSA_SIZE == 52);
264 static_assert(MAX_EXPONENT == 1024);
267 const int nExponent =
268 ((nVal >> MANTISSA_SIZE) & (2 * MAX_EXPONENT - 1)) - (MAX_EXPONENT - 1);
270 const int nBitsRequired = 1 + nExponent + nBitsPrecision;
272 int nNullifiedBits = MANTISSA_SIZE - nBitsRequired;
275 if (nNullifiedBits <= 0)
277 if (nNullifiedBits >= MANTISSA_SIZE)
278 nNullifiedBits = MANTISSA_SIZE;
279 nVal &= std::numeric_limits<uint64_t>::max() << 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));
Definition of an attribute of an OGRFeatureDefn.
Definition ogr_feature.h:111
Abstract base class for all geometry classes.
Definition ogr_geometry.h:377
Simple container for a position.
Definition ogr_geometry.h:106
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:976
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:185
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:404
OGRFieldSubType
List of field subtypes.
Definition ogr_core.h:821
OGRwkbVariant
Output variants of WKB we support.
Definition ogr_core.h:550
OGRFieldType
List of feature field types.
Definition ogr_core.h:793
OGRwkbGeometryType
List of well known binary geometry types.
Definition ogr_core.h:416
int OGRErr
Type for a OGR error.
Definition ogr_core.h:387
Document node structure.
Definition cpl_minixml.h:71
Options for formatting WKT output.
Definition ogr_geometry.h:72
OGRFeature field attribute value union.
Definition ogr_core.h:910