GDAL
ogr_p.h
1 /******************************************************************************
2  * $Id$
3  *
4  * Project: OpenGIS Simple Features Reference Implementation
5  * Purpose: Some private helper functions and stuff for OGR implementation.
6  * Author: Frank Warmerdam, warmerdam@pobox.com
7  *
8  ******************************************************************************
9  * Copyright (c) 1999, Frank Warmerdam
10  * Copyright (c) 2008-2014, Even Rouault <even dot rouault at spatialys.com>
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a
13  * copy of this software and associated documentation files (the "Software"),
14  * to deal in the Software without restriction, including without limitation
15  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16  * and/or sell copies of the Software, and to permit persons to whom the
17  * Software is furnished to do so, subject to the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be included
20  * in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28  * DEALINGS IN THE SOFTWARE.
29  ****************************************************************************/
30 
31 #ifndef OGR_P_H_INCLUDED
32 #define OGR_P_H_INCLUDED
33 
34 /* -------------------------------------------------------------------- */
35 /* Include the common portability library ... lets us do lots */
36 /* of stuff easily. */
37 /* -------------------------------------------------------------------- */
38 
39 #include "cpl_string.h"
40 #include "cpl_conv.h"
41 #include "cpl_minixml.h"
42 
43 #include "ogr_core.h"
44 #include "ogr_geometry.h"
45 #include "ogr_feature.h"
46 
47 /* A default name for the default geometry column, instead of '' */
48 #define OGR_GEOMETRY_DEFAULT_NON_EMPTY_NAME "_ogr_geometry_"
49 
50 #ifdef CPL_MSB
51 #define OGR_SWAP(x) (x == wkbNDR)
52 #else
53 #define OGR_SWAP(x) (x == wkbXDR)
54 #endif
55 
56 /* PostGIS 1.X has non standard codes for the following geometry types */
57 #define POSTGIS15_CURVEPOLYGON 13 /* instead of 10 */
58 #define POSTGIS15_MULTICURVE 14 /* instead of 11 */
59 #define POSTGIS15_MULTISURFACE 15 /* instead of 12 */
60 
61 /* Has been deprecated. Can only be used in very specific circumstances */
62 #ifdef GDAL_COMPILATION
63 #define wkb25DBitInternalUse 0x80000000
64 #endif
65 
66 /* -------------------------------------------------------------------- */
67 /* helper function for parsing well known text format vector objects.*/
68 /* -------------------------------------------------------------------- */
69 
70 #ifdef OGR_GEOMETRY_H_INCLUDED
71 #define OGR_WKT_TOKEN_MAX 64
72 
73 const char CPL_DLL *OGRWktReadToken(const char *pszInput, char *pszToken);
74 
75 const char CPL_DLL *OGRWktReadPoints(const char *pszInput,
76  OGRRawPoint **ppaoPoints, double **ppadfZ,
77  int *pnMaxPoints, int *pnReadPoints);
78 
79 const char CPL_DLL *
80 OGRWktReadPointsM(const char *pszInput, OGRRawPoint **ppaoPoints,
81  double **ppadfZ, double **ppadfM,
82  int *flags, /* geometry flags, are we expecting Z, M, or both;
83  may change due to input */
84  int *pnMaxPoints, int *pnReadPoints);
85 
86 void CPL_DLL OGRMakeWktCoordinate(char *, double, double, double, int);
87 std::string CPL_DLL OGRMakeWktCoordinate(double, double, double, int,
88  OGRWktOptions opts);
89 void CPL_DLL OGRMakeWktCoordinateM(char *, double, double, double, double,
91 std::string CPL_DLL OGRMakeWktCoordinateM(double, double, double, double,
93  OGRWktOptions opts);
94 
95 #endif
96 
97 void CPL_DLL OGRFormatDouble(char *pszBuffer, int nBufferLen, double dfVal,
98  char chDecimalSep, int nPrecision = 15,
99  char chConversionSpecifier = 'f');
100 std::string CPL_DLL OGRFormatDouble(double val, const OGRWktOptions &opts);
101 
102 int OGRFormatFloat(char *pszBuffer, int nBufferLen, float fVal, int nPrecision,
103  char chConversionSpecifier);
104 
105 /* -------------------------------------------------------------------- */
106 /* Date-time parsing and processing functions */
107 /* -------------------------------------------------------------------- */
108 
109 /* Internal use by OGR drivers only, CPL_DLL is just there in case */
110 /* they are compiled as plugins */
111 int CPL_DLL OGRGetDayOfWeek(int day, int month, int year);
112 int CPL_DLL OGRParseXMLDateTime(const char *pszXMLDateTime, OGRField *psField);
113 int CPL_DLL OGRParseRFC822DateTime(const char *pszRFC822DateTime,
114  OGRField *psField);
115 char CPL_DLL *OGRGetRFC822DateTime(const OGRField *psField);
116 char CPL_DLL *OGRGetXMLDateTime(const OGRField *psField);
117 char CPL_DLL *OGRGetXMLDateTime(const OGRField *psField,
118  bool bAlwaysMillisecond);
119 // 30 = strlen("YYYY-MM-DDThh:mm:ss.sss+hh:mm") + 1
120 #define OGR_SIZEOF_ISO8601_DATETIME_BUFFER 30
121 int CPL_DLL
122 OGRGetISO8601DateTime(const OGRField *psField, bool bAlwaysMillisecond,
123  char szBuffer[OGR_SIZEOF_ISO8601_DATETIME_BUFFER]);
124 char CPL_DLL *OGRGetXML_UTF8_EscapedString(const char *pszString);
125 bool CPL_DLL OGRParseDateTimeYYYYMMDDTHHMMSSZ(const char *pszInput, size_t nLen,
126  OGRField *psField);
127 bool CPL_DLL OGRParseDateTimeYYYYMMDDTHHMMSSsssZ(const char *pszInput,
128  size_t nLen,
129  OGRField *psField);
130 
131 int OGRCompareDate(const OGRField *psFirstTuple,
132  const OGRField *psSecondTuple); /* used by ogr_gensql.cpp and
133  ogrfeaturequery.cpp */
134 
135 /* General utility option processing. */
136 int CPL_DLL OGRGeneralCmdLineProcessor(int nArgc, char ***ppapszArgv,
137  int nOptions);
138 
139 /************************************************************************/
140 /* Support for special attributes (feature query and selection) */
141 /************************************************************************/
142 #define SPF_FID 0
143 #define SPF_OGR_GEOMETRY 1
144 #define SPF_OGR_STYLE 2
145 #define SPF_OGR_GEOM_WKT 3
146 #define SPF_OGR_GEOM_AREA 4
147 #define SPECIAL_FIELD_COUNT 5
148 
149 extern const char *const SpecialFieldNames[SPECIAL_FIELD_COUNT];
150 
151 #ifdef SWQ_H_INCLUDED_
152 extern const swq_field_type SpecialFieldTypes[SPECIAL_FIELD_COUNT];
153 #endif
154 
155 /************************************************************************/
156 /* Some SRS related stuff, search in SRS data files. */
157 /************************************************************************/
158 
159 OGRErr CPL_DLL OSRGetEllipsoidInfo(int, char **, double *, double *);
160 
161 /* Fast atof function */
162 double OGRFastAtof(const char *pszStr);
163 
164 OGRErr CPL_DLL OGRCheckPermutation(const int *panPermutation, int nSize);
165 
166 /* GML related */
167 
168 OGRGeometry *GML2OGRGeometry_XMLNode(const CPLXMLNode *psNode,
169  int nPseudoBoolGetSecondaryGeometryOption,
170  int nRecLevel = 0, int nSRSDimension = 0,
171  bool bIgnoreGSG = false,
172  bool bOrientation = true,
173  bool bFaceHoleNegative = false);
174 
175 /************************************************************************/
176 /* PostGIS EWKB encoding */
177 /************************************************************************/
178 
179 OGRGeometry CPL_DLL *OGRGeometryFromEWKB(GByte *pabyWKB, int nLength,
180  int *pnSRID, int bIsPostGIS1_EWKB);
181 OGRGeometry CPL_DLL *OGRGeometryFromHexEWKB(const char *pszBytea, int *pnSRID,
182  int bIsPostGIS1_EWKB);
183 char CPL_DLL *OGRGeometryToHexEWKB(OGRGeometry *poGeometry, int nSRSId,
184  int nPostGISMajor, int nPostGISMinor);
185 
186 /************************************************************************/
187 /* WKB Type Handling encoding */
188 /************************************************************************/
189 
190 OGRErr CPL_DLL OGRReadWKBGeometryType(const unsigned char *pabyData,
191  OGRwkbVariant wkbVariant,
192  OGRwkbGeometryType *eGeometryType);
193 
194 /************************************************************************/
195 /* WKT Type Handling encoding */
196 /************************************************************************/
197 
198 OGRErr CPL_DLL OGRReadWKTGeometryType(const char *pszWKT,
199  OGRwkbGeometryType *peGeometryType);
200 
201 /************************************************************************/
202 /* Other */
203 /************************************************************************/
204 
205 void CPL_DLL OGRUpdateFieldType(OGRFieldDefn *poFDefn, OGRFieldType eNewType,
206  OGRFieldSubType eNewSubType);
207 
208 #endif /* ndef OGR_P_H_INCLUDED */
GByte
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:205
cpl_minixml.h
OGRGeometry
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:334
ogr_geometry.h
CPLXMLNode
Document node structure.
Definition: cpl_minixml.h:69
OGRBoolean
int OGRBoolean
Type for a OGR boolean.
Definition: ogr_core.h:395
OGRRawPoint
Simple container for a position.
Definition: ogr_geometry.h:104
OGRField
OGRFeature field attribute value union.
Definition: ogr_core.h:877
OGRFieldDefn
Definition of an attribute of an OGRFeatureDefn.
Definition: ogr_feature.h:103
ogr_feature.h
cpl_conv.h
cpl_string.h
OGRErr
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:378
OGRwkbGeometryType
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:406
OGRFieldSubType
OGRFieldSubType
List of field subtypes.
Definition: ogr_core.h:811
OGRFieldType
OGRFieldType
List of feature field types.
Definition: ogr_core.h:783
OGRWktOptions
Options for formatting WKT output.
Definition: ogr_geometry.h:69
ogr_core.h
OGRwkbVariant
OGRwkbVariant
Output variants of WKB we support.
Definition: ogr_core.h:540