14#ifndef OGR_P_H_INCLUDED
15#define OGR_P_H_INCLUDED
35#define OGR_GEOMETRY_DEFAULT_NON_EMPTY_NAME "_ogr_geometry_"
38#define OGR_SWAP(x) (x == wkbNDR)
40#define OGR_SWAP(x) (x == wkbXDR)
44#define POSTGIS15_CURVEPOLYGON 13
45#define POSTGIS15_MULTICURVE 14
46#define POSTGIS15_MULTISURFACE 15
49#ifdef GDAL_COMPILATION
50#define wkb25DBitInternalUse 0x80000000
57#ifdef OGR_GEOMETRY_H_INCLUDED
58#define OGR_WKT_TOKEN_MAX 64
60const char CPL_DLL *OGRWktReadToken(
const char *pszInput,
char *pszToken);
62const char CPL_DLL *OGRWktReadPoints(
const char *pszInput,
64 int *pnMaxPoints,
int *pnReadPoints);
67OGRWktReadPointsM(
const char *pszInput,
OGRRawPoint **ppaoPoints,
68 double **ppadfZ,
double **ppadfM,
71 int *pnMaxPoints,
int *pnReadPoints);
73void CPL_DLL OGRMakeWktCoordinate(
char *,
double,
double,
double,
int);
74std::string CPL_DLL OGRMakeWktCoordinate(
double,
double,
double,
int,
76void CPL_DLL OGRMakeWktCoordinateM(
char *,
double,
double,
double,
double,
78std::string CPL_DLL OGRMakeWktCoordinateM(
double,
double,
double,
double,
84void CPL_DLL OGRFormatDouble(
char *pszBuffer,
int nBufferLen,
double dfVal,
85 char chDecimalSep,
int nPrecision = 15,
86 char chConversionSpecifier =
'f');
88#ifdef OGR_GEOMETRY_H_INCLUDED
89std::string CPL_DLL OGRFormatDouble(
double val,
const OGRWktOptions &opts,
93int OGRFormatFloat(
char *pszBuffer,
int nBufferLen,
float fVal,
int nPrecision,
94 char chConversionSpecifier);
103int CPL_DLL OGRTimezoneToTZFlag(
const char *pszTZ,
104 bool bEmitErrorIfUnhandledFormat);
105std::string CPL_DLL OGRTZFlagToTimezone(
int nTZFlag,
106 const char *pszUTCRepresentation);
108int CPL_DLL OGRGetDayOfWeek(
int day,
int month,
int year);
109int CPL_DLL OGRParseXMLDateTime(
const char *pszXMLDateTime,
OGRField *psField);
110int CPL_DLL OGRParseRFC822DateTime(
const char *pszRFC822DateTime,
112char CPL_DLL *OGRGetRFC822DateTime(
const OGRField *psField);
113char CPL_DLL *OGRGetXMLDateTime(
const OGRField *psField);
114char CPL_DLL *OGRGetXMLDateTime(
const OGRField *psField,
115 bool bAlwaysMillisecond);
117#define OGR_SIZEOF_ISO8601_DATETIME_BUFFER 30
119OGRGetISO8601DateTime(
const OGRField *psField,
bool bAlwaysMillisecond,
120 char szBuffer[OGR_SIZEOF_ISO8601_DATETIME_BUFFER]);
123enum class OGRISO8601Precision
144 char szBuffer[OGR_SIZEOF_ISO8601_DATETIME_BUFFER]);
145char CPL_DLL *OGRGetXML_UTF8_EscapedString(
const char *pszString);
147#ifdef GDAL_COMPILATION
148bool CPL_DLL OGRParseDateTimeYYYYMMDDTHHMMZ(std::string_view sInput,
150bool CPL_DLL OGRParseDateTimeYYYYMMDDTHHMMSSZ(std::string_view sInput,
152bool CPL_DLL OGRParseDateTimeYYYYMMDDTHHMMSSsssZ(std::string_view sInput,
156int OGRCompareDate(
const OGRField *psFirstTuple,
161int CPL_DLL OGRGeneralCmdLineProcessor(
int nArgc,
char ***ppapszArgv,
168#define SPF_OGR_GEOMETRY 1
169#define SPF_OGR_STYLE 2
170#define SPF_OGR_GEOM_WKT 3
171#define SPF_OGR_GEOM_AREA 4
172#define SPECIAL_FIELD_COUNT 5
174extern const char *
const SpecialFieldNames[SPECIAL_FIELD_COUNT];
180OGRErr CPL_DLL OSRGetEllipsoidInfo(
int,
char **,
double *,
double *);
183double OGRFastAtof(
const char *pszStr);
185OGRErr CPL_DLL OGRCheckPermutation(
const int *panPermutation,
int nSize);
192 int *pnSRID,
int bIsPostGIS1_EWKB);
193OGRGeometry CPL_DLL *OGRGeometryFromHexEWKB(
const char *pszBytea,
int *pnSRID,
194 int bIsPostGIS1_EWKB);
195char CPL_DLL *OGRGeometryToHexEWKB(
OGRGeometry *poGeometry,
int nSRSId,
196 int nPostGISMajor,
int nPostGISMinor);
202OGRErr CPL_DLL OGRReadWKBGeometryType(
const unsigned char *pabyData,
210OGRErr CPL_DLL OGRReadWKTGeometryType(
const char *pszWKT,
232inline uint64_t OGRRoundValueIEEE754(uint64_t nVal,
235inline uint64_t OGRRoundValueIEEE754(uint64_t nVal,
int nBitsPrecision)
237 constexpr int MANTISSA_SIZE = std::numeric_limits<double>::digits - 1;
238 constexpr int MAX_EXPONENT = std::numeric_limits<double>::max_exponent;
239#if __cplusplus >= 201703L
240 static_assert(MANTISSA_SIZE == 52);
241 static_assert(MAX_EXPONENT == 1024);
244 const int nExponent =
245 ((nVal >> MANTISSA_SIZE) & (2 * MAX_EXPONENT - 1)) - (MAX_EXPONENT - 1);
247 const int nBitsRequired = 1 + nExponent + nBitsPrecision;
249 int nNullifiedBits = MANTISSA_SIZE - nBitsRequired;
252 if (nNullifiedBits <= 0)
254 if (nNullifiedBits >= MANTISSA_SIZE)
255 nNullifiedBits = MANTISSA_SIZE;
256 nVal >>= nNullifiedBits;
257 nVal <<= nNullifiedBits;
269template <
int SPACING>
270inline void OGRRoundCoordinatesIEEE754XYValues(
int nBitsPrecision,
271 GByte *pabyBase,
size_t nPoints)
275 if (nBitsPrecision != INT_MIN)
277 for (
size_t i = 0; i < nPoints; i++)
281 memcpy(&nVal, pabyBase + SPACING * i,
sizeof(uint64_t));
282 nVal = OGRRoundValueIEEE754(nVal, nBitsPrecision);
283 memcpy(pabyBase + SPACING * i, &nVal,
sizeof(uint64_t));
285 memcpy(&nVal, pabyBase +
sizeof(uint64_t) + SPACING * i,
287 nVal = OGRRoundValueIEEE754(nVal, nBitsPrecision);
288 memcpy(pabyBase +
sizeof(uint64_t) + SPACING * i, &nVal,
302template <
int SPACING>
303inline void OGRRoundCoordinatesIEEE754(
int nBitsPrecision,
GByte *pabyBase,
306 if (nBitsPrecision != INT_MIN)
308 for (
size_t i = 0; i < nPoints; i++)
312 memcpy(&nVal, pabyBase + SPACING * i,
sizeof(uint64_t));
313 nVal = OGRRoundValueIEEE754(nVal, nBitsPrecision);
314 memcpy(pabyBase + SPACING * i, &nVal,
sizeof(uint64_t));
326std::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
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
OGRFeature field attribute value union.
Definition ogr_core.h:886