ogr_p.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /******************************************************************************
  2. * $Id: ogr_p.h 28900 2015-04-14 09:40:34Z rouault $
  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 mines-paris dot org>
  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. #ifndef OGR_P_H_INCLUDED
  31. #define OGR_P_H_INCLUDED
  32. /* -------------------------------------------------------------------- */
  33. /* Include the common portability library ... lets us do lots */
  34. /* of stuff easily. */
  35. /* -------------------------------------------------------------------- */
  36. #include "cpl_string.h"
  37. #include "cpl_conv.h"
  38. #include "cpl_minixml.h"
  39. #include "ogr_core.h"
  40. #include "ogr_geometry.h"
  41. /* A default name for the default geometry column, instead of '' */
  42. #define OGR_GEOMETRY_DEFAULT_NON_EMPTY_NAME "_ogr_geometry_"
  43. #ifdef CPL_MSB
  44. # define OGR_SWAP(x) (x == wkbNDR)
  45. #else
  46. # define OGR_SWAP(x) (x == wkbXDR)
  47. #endif
  48. /* PostGIS 1.X has non standard codes for the following geometry types */
  49. #define POSTGIS15_CURVEPOLYGON 13 /* instead of 10 */
  50. #define POSTGIS15_MULTICURVE 14 /* instead of 11 */
  51. #define POSTGIS15_MULTISURFACE 15 /* instead of 12 */
  52. /* Has been deprecated. Can only be used in very specific circumstances */
  53. #ifdef GDAL_COMPILATION
  54. #define wkb25DBitInternalUse 0x80000000
  55. #endif
  56. /* -------------------------------------------------------------------- */
  57. /* helper function for parsing well known text format vector objects.*/
  58. /* -------------------------------------------------------------------- */
  59. #ifdef _OGR_GEOMETRY_H_INCLUDED
  60. #define OGR_WKT_TOKEN_MAX 64
  61. const char CPL_DLL * OGRWktReadToken( const char * pszInput, char * pszToken );
  62. const char CPL_DLL * OGRWktReadPoints( const char * pszInput,
  63. OGRRawPoint **ppaoPoints,
  64. double **ppadfZ,
  65. int * pnMaxPoints,
  66. int * pnReadPoints );
  67. void CPL_DLL OGRMakeWktCoordinate( char *, double, double, double, int );
  68. #endif
  69. void OGRFormatDouble( char *pszBuffer, int nBufferLen, double dfVal, char chDecimalSep, int nPrecision = 15 );
  70. /* -------------------------------------------------------------------- */
  71. /* Date-time parsing and processing functions */
  72. /* -------------------------------------------------------------------- */
  73. /* Internal use by OGR drivers only, CPL_DLL is just there in case */
  74. /* they are compiled as plugins */
  75. int CPL_DLL OGRGetDayOfWeek(int day, int month, int year);
  76. int CPL_DLL OGRParseXMLDateTime( const char* pszXMLDateTime,
  77. OGRField* psField );
  78. int CPL_DLL OGRParseRFC822DateTime( const char* pszRFC822DateTime,
  79. OGRField* psField );
  80. char CPL_DLL * OGRGetRFC822DateTime(const OGRField* psField);
  81. char CPL_DLL * OGRGetXMLDateTime(const OGRField* psField);
  82. char CPL_DLL * OGRGetXML_UTF8_EscapedString(const char* pszString);
  83. int OGRCompareDate( OGRField *psFirstTuple,
  84. OGRField *psSecondTuple ); /* used by ogr_gensql.cpp and ogrfeaturequery.cpp */
  85. /* General utility option processing. */
  86. int CPL_DLL OGRGeneralCmdLineProcessor( int nArgc, char ***ppapszArgv, int nOptions );
  87. /************************************************************************/
  88. /* Support for special attributes (feature query and selection) */
  89. /************************************************************************/
  90. #define SPF_FID 0
  91. #define SPF_OGR_GEOMETRY 1
  92. #define SPF_OGR_STYLE 2
  93. #define SPF_OGR_GEOM_WKT 3
  94. #define SPF_OGR_GEOM_AREA 4
  95. #define SPECIAL_FIELD_COUNT 5
  96. extern const char* SpecialFieldNames[SPECIAL_FIELD_COUNT];
  97. #ifdef _SWQ_H_INCLUDED_
  98. extern const swq_field_type SpecialFieldTypes[SPECIAL_FIELD_COUNT];
  99. #endif
  100. /************************************************************************/
  101. /* Some SRS related stuff, search in SRS data files. */
  102. /************************************************************************/
  103. OGRErr CPL_DLL OSRGetEllipsoidInfo( int, char **, double *, double *);
  104. /* Fast atof function */
  105. double OGRFastAtof(const char* pszStr);
  106. OGRErr CPL_DLL OGRCheckPermutation(int* panPermutation, int nSize);
  107. /* GML related */
  108. OGRGeometry *GML2OGRGeometry_XMLNode( const CPLXMLNode *psNode,
  109. int bGetSecondaryGeometryOption,
  110. int nRecLevel = 0,
  111. int nSRSDimension = 0,
  112. int bIgnoreGSG = FALSE,
  113. int bOrientation = TRUE,
  114. int bFaceHoleNegative = FALSE);
  115. /************************************************************************/
  116. /* PostGIS EWKB encoding */
  117. /************************************************************************/
  118. OGRGeometry CPL_DLL *OGRGeometryFromEWKB( GByte *pabyWKB, int nLength, int* pnSRID,
  119. int bIsPostGIS1_EWKB );
  120. OGRGeometry CPL_DLL *OGRGeometryFromHexEWKB( const char *pszBytea, int* pnSRID,
  121. int bIsPostGIS1_EWKB );
  122. char CPL_DLL * OGRGeometryToHexEWKB( OGRGeometry * poGeometry, int nSRSId,
  123. int bIsPostGIS1_EWKB );
  124. /************************************************************************/
  125. /* WKB Type Handling encoding */
  126. /************************************************************************/
  127. OGRErr OGRReadWKBGeometryType( unsigned char * pabyData,
  128. OGRwkbVariant wkbVariant,
  129. OGRwkbGeometryType *eGeometryType, OGRBoolean *b3D );
  130. #endif /* ndef OGR_P_H_INCLUDED */