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
76 const char CPL_DLL *OGRWktReadToken(
const char *pszInput,
char *pszToken);
78 const char CPL_DLL *OGRWktReadPoints(
const char *pszInput,
80 int *pnMaxPoints,
int *pnReadPoints);
83 OGRWktReadPointsM(
const char *pszInput,
OGRRawPoint **ppaoPoints,
84 double **ppadfZ,
double **ppadfM,
87 int *pnMaxPoints,
int *pnReadPoints);
89 void CPL_DLL OGRMakeWktCoordinate(
char *,
double,
double,
double,
int);
90 std::string CPL_DLL OGRMakeWktCoordinate(
double,
double,
double,
int,
92 void CPL_DLL OGRMakeWktCoordinateM(
char *,
double,
double,
double,
double,
94 std::string CPL_DLL OGRMakeWktCoordinateM(
double,
double,
double,
double,
100 void 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
105 std::string CPL_DLL OGRFormatDouble(
double val,
const OGRWktOptions &opts,
109 int OGRFormatFloat(
char *pszBuffer,
int nBufferLen,
float fVal,
int nPrecision,
110 char chConversionSpecifier);
119 int CPL_DLL OGRTimezoneToTZFlag(
const char *pszTZ,
120 bool bEmitErrorIfUnhandledFormat);
121 std::string CPL_DLL OGRTZFlagToTimezone(
int nTZFlag,
122 const char *pszUTCRepresentation);
124 int CPL_DLL OGRGetDayOfWeek(
int day,
int month,
int year);
125 int CPL_DLL OGRParseXMLDateTime(
const char *pszXMLDateTime,
OGRField *psField);
126 int CPL_DLL OGRParseRFC822DateTime(
const char *pszRFC822DateTime,
128 char CPL_DLL *OGRGetRFC822DateTime(
const OGRField *psField);
129 char CPL_DLL *OGRGetXMLDateTime(
const OGRField *psField);
130 char CPL_DLL *OGRGetXMLDateTime(
const OGRField *psField,
131 bool bAlwaysMillisecond);
133 #define OGR_SIZEOF_ISO8601_DATETIME_BUFFER 30
135 OGRGetISO8601DateTime(
const OGRField *psField,
bool bAlwaysMillisecond,
136 char szBuffer[OGR_SIZEOF_ISO8601_DATETIME_BUFFER]);
139 enum class OGRISO8601Precision
160 char szBuffer[OGR_SIZEOF_ISO8601_DATETIME_BUFFER]);
161 char CPL_DLL *OGRGetXML_UTF8_EscapedString(
const char *pszString);
162 bool CPL_DLL OGRParseDateTimeYYYYMMDDTHHMMZ(
const char *pszInput,
size_t nLen,
164 bool CPL_DLL OGRParseDateTimeYYYYMMDDTHHMMSSZ(
const char *pszInput,
size_t nLen,
166 bool CPL_DLL OGRParseDateTimeYYYYMMDDTHHMMSSsssZ(
const char *pszInput,
170 int OGRCompareDate(
const OGRField *psFirstTuple,
175 int 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
188 extern const char *
const SpecialFieldNames[SPECIAL_FIELD_COUNT];
194 OGRErr CPL_DLL OSRGetEllipsoidInfo(
int,
char **,
double *,
double *);
197 double OGRFastAtof(
const char *pszStr);
199 OGRErr 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);
216 OGRGeometry CPL_DLL *OGRGeometryFromHexEWKB(
const char *pszBytea,
int *pnSRID,
217 int bIsPostGIS1_EWKB);
218 char CPL_DLL *OGRGeometryToHexEWKB(
OGRGeometry *poGeometry,
int nSRSId,
219 int nPostGISMajor,
int nPostGISMinor);
225 OGRErr CPL_DLL OGRReadWKBGeometryType(
const unsigned char *pabyData,
233 OGRErr CPL_DLL OGRReadWKTGeometryType(
const char *pszWKT,
255 inline uint64_t OGRRoundValueIEEE754(uint64_t nVal,
258 inline 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 >>= nNullifiedBits;
280 nVal <<= nNullifiedBits;
292 template <
int SPACING>
293 inline void OGRRoundCoordinatesIEEE754XYValues(
int nBitsPrecision,
294 GByte *pabyBase,
size_t nPoints)
298 if (nBitsPrecision != INT_MIN)
300 for (
size_t i = 0; i < nPoints; i++)
304 memcpy(&nVal, pabyBase + SPACING * i,
sizeof(uint64_t));
305 nVal = OGRRoundValueIEEE754(nVal, nBitsPrecision);
306 memcpy(pabyBase + SPACING * i, &nVal,
sizeof(uint64_t));
308 memcpy(&nVal, pabyBase +
sizeof(uint64_t) + SPACING * i,
310 nVal = OGRRoundValueIEEE754(nVal, nBitsPrecision);
311 memcpy(pabyBase +
sizeof(uint64_t) + SPACING * i, &nVal,
325 template <
int SPACING>
326 inline void OGRRoundCoordinatesIEEE754(
int nBitsPrecision,
GByte *pabyBase,
329 if (nBitsPrecision != INT_MIN)
331 for (
size_t i = 0; i < nPoints; i++)
335 memcpy(&nVal, pabyBase + SPACING * i,
sizeof(uint64_t));
336 nVal = OGRRoundValueIEEE754(nVal, nBitsPrecision);
337 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