OGR
|
00001 /****************************************************************************** 00002 * $Id: ogr_core.h 20885 2010-10-19 00:16:08Z warmerdam $ 00003 * 00004 * Project: OpenGIS Simple Features Reference Implementation 00005 * Purpose: Define some core portability services for cross-platform OGR code. 00006 * Author: Frank Warmerdam, warmerdam@pobox.com 00007 * 00008 ****************************************************************************** 00009 * Copyright (c) 1999, Frank Warmerdam 00010 * 00011 * Permission is hereby granted, free of charge, to any person obtaining a 00012 * copy of this software and associated documentation files (the "Software"), 00013 * to deal in the Software without restriction, including without limitation 00014 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00015 * and/or sell copies of the Software, and to permit persons to whom the 00016 * Software is furnished to do so, subject to the following conditions: 00017 * 00018 * The above copyright notice and this permission notice shall be included 00019 * in all copies or substantial portions of the Software. 00020 * 00021 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00022 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00023 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00024 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00025 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00026 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00027 * DEALINGS IN THE SOFTWARE. 00028 ****************************************************************************/ 00029 00030 #ifndef OGR_CORE_H_INCLUDED 00031 #define OGR_CORE_H_INCLUDED 00032 00033 #include "cpl_port.h" 00034 #include "gdal_version.h" 00035 00046 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS) 00047 class CPL_DLL OGREnvelope 00048 { 00049 public: 00050 OGREnvelope() 00051 { 00052 MinX = MaxX = MinY = MaxY = 0; 00053 } 00054 double MinX; 00055 double MaxX; 00056 double MinY; 00057 double MaxY; 00058 00059 int IsInit() const { return MinX != 0 || MinY != 0 || MaxX != 0 || MaxY != 0; } 00060 void Merge( OGREnvelope const& sOther ) { 00061 if( IsInit() ) 00062 { 00063 MinX = MIN(MinX,sOther.MinX); 00064 MaxX = MAX(MaxX,sOther.MaxX); 00065 MinY = MIN(MinY,sOther.MinY); 00066 MaxY = MAX(MaxY,sOther.MaxY); 00067 } 00068 else 00069 { 00070 MinX = sOther.MinX; 00071 MaxX = sOther.MaxX; 00072 MinY = sOther.MinY; 00073 MaxY = sOther.MaxY; 00074 } 00075 } 00076 void Merge( double dfX, double dfY ) { 00077 if( IsInit() ) 00078 { 00079 MinX = MIN(MinX,dfX); 00080 MaxX = MAX(MaxX,dfX); 00081 MinY = MIN(MinY,dfY); 00082 MaxY = MAX(MaxY,dfY); 00083 } 00084 else 00085 { 00086 MinX = MaxX = dfX; 00087 MinY = MaxY = dfY; 00088 } 00089 } 00090 00091 void Intersect( OGREnvelope const& sOther ) { 00092 if(Intersects(sOther)) 00093 { 00094 if( IsInit() ) 00095 { 00096 MinX = MAX(MinX,sOther.MinX); 00097 MaxX = MIN(MaxX,sOther.MaxX); 00098 MinY = MAX(MinY,sOther.MinY); 00099 MaxY = MIN(MaxY,sOther.MaxY); 00100 } 00101 else 00102 { 00103 MinX = sOther.MinX; 00104 MaxX = sOther.MaxX; 00105 MinY = sOther.MinY; 00106 MaxY = sOther.MaxY; 00107 } 00108 } 00109 else 00110 { 00111 MinX = 0; 00112 MaxX = 0; 00113 MinY = 0; 00114 MaxY = 0; 00115 } 00116 } 00117 00118 int Intersects(OGREnvelope const& other) const 00119 { 00120 return MinX <= other.MaxX && MaxX >= other.MinX && 00121 MinY <= other.MaxY && MaxY >= other.MinY; 00122 } 00123 00124 int Contains(OGREnvelope const& other) const 00125 { 00126 return MinX <= other.MinX && MinY <= other.MinY && 00127 MaxX >= other.MaxX && MaxY >= other.MaxY; 00128 } 00129 }; 00130 #else 00131 typedef struct 00132 { 00133 double MinX; 00134 double MaxX; 00135 double MinY; 00136 double MaxY; 00137 } OGREnvelope; 00138 #endif 00139 00140 CPL_C_START 00141 00142 void CPL_DLL *OGRMalloc( size_t ); 00143 void CPL_DLL *OGRCalloc( size_t, size_t ); 00144 void CPL_DLL *OGRRealloc( void *, size_t ); 00145 char CPL_DLL *OGRStrdup( const char * ); 00146 void CPL_DLL OGRFree( void * ); 00147 00148 typedef int OGRErr; 00149 00150 #define OGRERR_NONE 0 00151 #define OGRERR_NOT_ENOUGH_DATA 1 /* not enough data to deserialize */ 00152 #define OGRERR_NOT_ENOUGH_MEMORY 2 00153 #define OGRERR_UNSUPPORTED_GEOMETRY_TYPE 3 00154 #define OGRERR_UNSUPPORTED_OPERATION 4 00155 #define OGRERR_CORRUPT_DATA 5 00156 #define OGRERR_FAILURE 6 00157 #define OGRERR_UNSUPPORTED_SRS 7 00158 #define OGRERR_INVALID_HANDLE 8 00159 00160 typedef int OGRBoolean; 00161 00162 /* -------------------------------------------------------------------- */ 00163 /* ogr_geometry.h related definitions. */ 00164 /* -------------------------------------------------------------------- */ 00171 typedef enum 00172 { 00173 wkbUnknown = 0, 00174 wkbPoint = 1, 00175 wkbLineString = 2, 00177 wkbPolygon = 3, 00180 wkbMultiPoint = 4, 00181 wkbMultiLineString = 5, 00182 wkbMultiPolygon = 6, 00183 wkbGeometryCollection = 7, 00185 wkbNone = 100, 00186 wkbLinearRing = 101, 00187 wkbPoint25D = 0x80000001, 00188 wkbLineString25D = 0x80000002, 00189 wkbPolygon25D = 0x80000003, 00190 wkbMultiPoint25D = 0x80000004, 00191 wkbMultiLineString25D = 0x80000005, 00192 wkbMultiPolygon25D = 0x80000006, 00193 wkbGeometryCollection25D = 0x80000007 00194 } OGRwkbGeometryType; 00195 00196 #define wkb25DBit 0x80000000 00197 #define wkbFlatten(x) ((OGRwkbGeometryType) ((x) & (~wkb25DBit))) 00198 00199 #define ogrZMarker 0x21125711 00200 00201 const char CPL_DLL * OGRGeometryTypeToName( OGRwkbGeometryType eType ); 00202 OGRwkbGeometryType CPL_DLL OGRMergeGeometryTypes( OGRwkbGeometryType eMain, 00203 OGRwkbGeometryType eExtra ); 00204 00205 typedef enum 00206 { 00207 wkbXDR = 0, /* MSB/Sun/Motoroloa: Most Significant Byte First */ 00208 wkbNDR = 1 /* LSB/Intel/Vax: Least Significant Byte First */ 00209 } OGRwkbByteOrder; 00210 00211 #ifndef NO_HACK_FOR_IBM_DB2_V72 00212 # define HACK_FOR_IBM_DB2_V72 00213 #endif 00214 00215 #ifdef HACK_FOR_IBM_DB2_V72 00216 # define DB2_V72_FIX_BYTE_ORDER(x) ((((x) & 0x31) == (x)) ? (OGRwkbByteOrder) ((x) & 0x1) : (x)) 00217 # define DB2_V72_UNFIX_BYTE_ORDER(x) ((unsigned char) (OGRGeometry::bGenerate_DB2_V72_BYTE_ORDER ? ((x) | 0x30) : (x))) 00218 #else 00219 # define DB2_V72_FIX_BYTE_ORDER(x) (x) 00220 # define DB2_V72_UNFIX_BYTE_ORDER(x) (x) 00221 #endif 00222 00223 /************************************************************************/ 00224 /* ogr_feature.h related definitions. */ 00225 /************************************************************************/ 00226 00233 typedef enum 00234 { OFTInteger = 0, OFTIntegerList = 1, OFTReal = 2, OFTRealList = 3, OFTString = 4, OFTStringList = 5, OFTWideString = 6, OFTWideStringList = 7, OFTBinary = 8, OFTDate = 9, OFTTime = 10, OFTDateTime = 11, 00247 OFTMaxType = 11 00248 } OGRFieldType; 00249 00254 typedef enum 00255 { 00256 OJUndefined = 0, 00257 OJLeft = 1, 00258 OJRight = 2 00259 } OGRJustification; 00260 00261 #define OGRNullFID -1 00262 #define OGRUnsetMarker -21121 00263 00264 /************************************************************************/ 00265 /* OGRField */ 00266 /************************************************************************/ 00267 00272 typedef union { 00273 int Integer; 00274 double Real; 00275 char *String; 00276 00277 struct { 00278 int nCount; 00279 int *paList; 00280 } IntegerList; 00281 00282 struct { 00283 int nCount; 00284 double *paList; 00285 } RealList; 00286 00287 struct { 00288 int nCount; 00289 char **paList; 00290 } StringList; 00291 00292 struct { 00293 int nCount; 00294 GByte *paData; 00295 } Binary; 00296 00297 struct { 00298 int nMarker1; 00299 int nMarker2; 00300 } Set; 00301 00302 struct { 00303 GInt16 Year; 00304 GByte Month; 00305 GByte Day; 00306 GByte Hour; 00307 GByte Minute; 00308 GByte Second; 00309 GByte TZFlag; /* 0=unknown, 1=localtime(ambiguous), 00310 100=GMT, 104=GMT+1, 80=GMT-5, etc */ 00311 } Date; 00312 } OGRField; 00313 00314 int CPL_DLL OGRParseDate( const char *pszInput, OGRField *psOutput, 00315 int nOptions ); 00316 00317 /* -------------------------------------------------------------------- */ 00318 /* Constants from ogrsf_frmts.h for capabilities. */ 00319 /* -------------------------------------------------------------------- */ 00320 #define OLCRandomRead "RandomRead" 00321 #define OLCSequentialWrite "SequentialWrite" 00322 #define OLCRandomWrite "RandomWrite" 00323 #define OLCFastSpatialFilter "FastSpatialFilter" 00324 #define OLCFastFeatureCount "FastFeatureCount" 00325 #define OLCFastGetExtent "FastGetExtent" 00326 #define OLCCreateField "CreateField" 00327 #define OLCTransactions "Transactions" 00328 #define OLCDeleteFeature "DeleteFeature" 00329 #define OLCFastSetNextByIndex "FastSetNextByIndex" 00330 #define OLCStringsAsUTF8 "StringsAsUTF8" 00331 #define OLCIgnoreFields "IgnoreFields" 00332 00333 #define ODsCCreateLayer "CreateLayer" 00334 #define ODsCDeleteLayer "DeleteLayer" 00335 00336 #define ODrCCreateDataSource "CreateDataSource" 00337 #define ODrCDeleteDataSource "DeleteDataSource" 00338 00339 00340 /************************************************************************/ 00341 /* ogr_featurestyle.h related definitions. */ 00342 /************************************************************************/ 00343 00348 typedef enum ogr_style_tool_class_id 00349 { 00350 OGRSTCNone = 0, 00351 OGRSTCPen = 1, 00352 OGRSTCBrush = 2, 00353 OGRSTCSymbol = 3, 00354 OGRSTCLabel = 4, 00355 OGRSTCVector = 5 00356 } OGRSTClassId; 00357 00361 typedef enum ogr_style_tool_units_id 00362 { 00363 OGRSTUGround = 0, 00364 OGRSTUPixel = 1, 00365 OGRSTUPoints = 2, 00366 OGRSTUMM = 3, 00367 OGRSTUCM = 4, 00368 OGRSTUInches = 5 00369 } OGRSTUnitId; 00370 00374 typedef enum ogr_style_tool_param_pen_id 00375 { 00376 OGRSTPenColor = 0, 00377 OGRSTPenWidth = 1, 00378 OGRSTPenPattern = 2, 00379 OGRSTPenId = 3, 00380 OGRSTPenPerOffset = 4, 00381 OGRSTPenCap = 5, 00382 OGRSTPenJoin = 6, 00383 OGRSTPenPriority = 7, 00384 OGRSTPenLast = 8 00385 00386 } OGRSTPenParam; 00387 00391 typedef enum ogr_style_tool_param_brush_id 00392 { 00393 OGRSTBrushFColor = 0, 00394 OGRSTBrushBColor = 1, 00395 OGRSTBrushId = 2, 00396 OGRSTBrushAngle = 3, 00397 OGRSTBrushSize = 4, 00398 OGRSTBrushDx = 5, 00399 OGRSTBrushDy = 6, 00400 OGRSTBrushPriority = 7, 00401 OGRSTBrushLast = 8 00402 00403 } OGRSTBrushParam; 00404 00405 00409 typedef enum ogr_style_tool_param_symbol_id 00410 { 00411 OGRSTSymbolId = 0, 00412 OGRSTSymbolAngle = 1, 00413 OGRSTSymbolColor = 2, 00414 OGRSTSymbolSize = 3, 00415 OGRSTSymbolDx = 4, 00416 OGRSTSymbolDy = 5, 00417 OGRSTSymbolStep = 6, 00418 OGRSTSymbolPerp = 7, 00419 OGRSTSymbolOffset = 8, 00420 OGRSTSymbolPriority = 9, 00421 OGRSTSymbolFontName = 10, 00422 OGRSTSymbolOColor = 11, 00423 OGRSTSymbolLast = 12 00424 00425 } OGRSTSymbolParam; 00426 00430 typedef enum ogr_style_tool_param_label_id 00431 { 00432 OGRSTLabelFontName = 0, 00433 OGRSTLabelSize = 1, 00434 OGRSTLabelTextString = 2, 00435 OGRSTLabelAngle = 3, 00436 OGRSTLabelFColor = 4, 00437 OGRSTLabelBColor = 5, 00438 OGRSTLabelPlacement = 6, 00439 OGRSTLabelAnchor = 7, 00440 OGRSTLabelDx = 8, 00441 OGRSTLabelDy = 9, 00442 OGRSTLabelPerp = 10, 00443 OGRSTLabelBold = 11, 00444 OGRSTLabelItalic = 12, 00445 OGRSTLabelUnderline = 13, 00446 OGRSTLabelPriority = 14, 00447 OGRSTLabelStrikeout = 15, 00448 OGRSTLabelStretch = 16, 00449 OGRSTLabelAdjHor = 17, 00450 OGRSTLabelAdjVert = 18, 00451 OGRSTLabelHColor = 19, 00452 OGRSTLabelOColor = 20, 00453 OGRSTLabelLast = 21 00454 00455 } OGRSTLabelParam; 00456 00457 /* ------------------------------------------------------------------- */ 00458 /* Version checking */ 00459 /* -------------------------------------------------------------------- */ 00460 00461 /* Note to developers : please keep this section in sync with gdal.h */ 00462 00463 #ifndef GDAL_VERSION_INFO_DEFINED 00464 #define GDAL_VERSION_INFO_DEFINED 00465 const char CPL_DLL * CPL_STDCALL GDALVersionInfo( const char * ); 00466 #endif 00467 00468 #ifndef GDAL_CHECK_VERSION 00469 00481 int CPL_DLL CPL_STDCALL GDALCheckVersion( int nVersionMajor, int nVersionMinor, 00482 const char* pszCallingComponentName); 00483 00485 #define GDAL_CHECK_VERSION(pszCallingComponentName) \ 00486 GDALCheckVersion(GDAL_VERSION_MAJOR, GDAL_VERSION_MINOR, pszCallingComponentName) 00487 00488 #endif 00489 00490 CPL_C_END 00491 00492 #endif /* ndef OGR_CORE_H_INCLUDED */