OGR
|
00001 /****************************************************************************** 00002 * $Id: ogr_core.h 22448 2011-05-28 18:49:54Z rouault $ 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() : MinX(0.0), MaxX(0.0), MinY(0.0), MaxY(0.0) 00051 { 00052 } 00053 double MinX; 00054 double MaxX; 00055 double MinY; 00056 double MaxY; 00057 00058 int IsInit() const { return MinX != 0 || MinY != 0 || MaxX != 0 || MaxY != 0; } 00059 void Merge( OGREnvelope const& sOther ) { 00060 if( IsInit() ) 00061 { 00062 MinX = MIN(MinX,sOther.MinX); 00063 MaxX = MAX(MaxX,sOther.MaxX); 00064 MinY = MIN(MinY,sOther.MinY); 00065 MaxY = MAX(MaxY,sOther.MaxY); 00066 } 00067 else 00068 { 00069 MinX = sOther.MinX; 00070 MaxX = sOther.MaxX; 00071 MinY = sOther.MinY; 00072 MaxY = sOther.MaxY; 00073 } 00074 } 00075 void Merge( double dfX, double dfY ) { 00076 if( IsInit() ) 00077 { 00078 MinX = MIN(MinX,dfX); 00079 MaxX = MAX(MaxX,dfX); 00080 MinY = MIN(MinY,dfY); 00081 MaxY = MAX(MaxY,dfY); 00082 } 00083 else 00084 { 00085 MinX = MaxX = dfX; 00086 MinY = MaxY = dfY; 00087 } 00088 } 00089 00090 void Intersect( OGREnvelope const& sOther ) { 00091 if(Intersects(sOther)) 00092 { 00093 if( IsInit() ) 00094 { 00095 MinX = MAX(MinX,sOther.MinX); 00096 MaxX = MIN(MaxX,sOther.MaxX); 00097 MinY = MAX(MinY,sOther.MinY); 00098 MaxY = MIN(MaxY,sOther.MaxY); 00099 } 00100 else 00101 { 00102 MinX = sOther.MinX; 00103 MaxX = sOther.MaxX; 00104 MinY = sOther.MinY; 00105 MaxY = sOther.MaxY; 00106 } 00107 } 00108 else 00109 { 00110 MinX = 0; 00111 MaxX = 0; 00112 MinY = 0; 00113 MaxY = 0; 00114 } 00115 } 00116 00117 int Intersects(OGREnvelope const& other) const 00118 { 00119 return MinX <= other.MaxX && MaxX >= other.MinX && 00120 MinY <= other.MaxY && MaxY >= other.MinY; 00121 } 00122 00123 int Contains(OGREnvelope const& other) const 00124 { 00125 return MinX <= other.MinX && MinY <= other.MinY && 00126 MaxX >= other.MaxX && MaxY >= other.MaxY; 00127 } 00128 }; 00129 #else 00130 typedef struct 00131 { 00132 double MinX; 00133 double MaxX; 00134 double MinY; 00135 double MaxY; 00136 } OGREnvelope; 00137 #endif 00138 00139 00144 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS) 00145 class CPL_DLL OGREnvelope3D : public OGREnvelope 00146 { 00147 public: 00148 OGREnvelope3D() : OGREnvelope(), MinZ(0.0), MaxZ(0.0) 00149 { 00150 } 00151 00152 double MinZ; 00153 double MaxZ; 00154 00155 int IsInit() const { return MinX != 0 || MinY != 0 || MaxX != 0 || MaxY != 0 || MinZ != 0 || MaxZ != 0; } 00156 void Merge( OGREnvelope3D const& sOther ) { 00157 if( IsInit() ) 00158 { 00159 MinX = MIN(MinX,sOther.MinX); 00160 MaxX = MAX(MaxX,sOther.MaxX); 00161 MinY = MIN(MinY,sOther.MinY); 00162 MaxY = MAX(MaxY,sOther.MaxY); 00163 MinZ = MIN(MinZ,sOther.MinZ); 00164 MaxZ = MAX(MaxZ,sOther.MaxZ); 00165 } 00166 else 00167 { 00168 MinX = sOther.MinX; 00169 MaxX = sOther.MaxX; 00170 MinY = sOther.MinY; 00171 MaxY = sOther.MaxY; 00172 MinZ = sOther.MinZ; 00173 MaxZ = sOther.MaxZ; 00174 } 00175 } 00176 void Merge( double dfX, double dfY, double dfZ ) { 00177 if( IsInit() ) 00178 { 00179 MinX = MIN(MinX,dfX); 00180 MaxX = MAX(MaxX,dfX); 00181 MinY = MIN(MinY,dfY); 00182 MaxY = MAX(MaxY,dfY); 00183 MinZ = MIN(MinZ,dfZ); 00184 MaxZ = MAX(MaxZ,dfZ); 00185 } 00186 else 00187 { 00188 MinX = MaxX = dfX; 00189 MinY = MaxY = dfY; 00190 MinZ = MaxZ = dfZ; 00191 } 00192 } 00193 00194 void Intersect( OGREnvelope3D const& sOther ) { 00195 if(Intersects(sOther)) 00196 { 00197 if( IsInit() ) 00198 { 00199 MinX = MAX(MinX,sOther.MinX); 00200 MaxX = MIN(MaxX,sOther.MaxX); 00201 MinY = MAX(MinY,sOther.MinY); 00202 MaxY = MIN(MaxY,sOther.MaxY); 00203 MinZ = MAX(MinZ,sOther.MinZ); 00204 MaxZ = MIN(MaxZ,sOther.MaxZ); 00205 } 00206 else 00207 { 00208 MinX = sOther.MinX; 00209 MaxX = sOther.MaxX; 00210 MinY = sOther.MinY; 00211 MaxY = sOther.MaxY; 00212 MinZ = sOther.MinZ; 00213 MaxZ = sOther.MaxZ; 00214 } 00215 } 00216 else 00217 { 00218 MinX = 0; 00219 MaxX = 0; 00220 MinY = 0; 00221 MaxY = 0; 00222 MinZ = 0; 00223 MaxZ = 0; 00224 } 00225 } 00226 00227 int Intersects(OGREnvelope3D const& other) const 00228 { 00229 return MinX <= other.MaxX && MaxX >= other.MinX && 00230 MinY <= other.MaxY && MaxY >= other.MinY && 00231 MinZ <= other.MaxZ && MaxZ >= other.MinZ; 00232 } 00233 00234 int Contains(OGREnvelope3D const& other) const 00235 { 00236 return MinX <= other.MinX && MinY <= other.MinY && 00237 MaxX >= other.MaxX && MaxY >= other.MaxY && 00238 MaxZ >= other.MaxZ && MaxZ >= other.MaxZ; 00239 } 00240 }; 00241 #else 00242 typedef struct 00243 { 00244 double MinX; 00245 double MaxX; 00246 double MinY; 00247 double MaxY; 00248 double MinZ; 00249 double MaxZ; 00250 } OGREnvelope3D; 00251 #endif 00252 00253 00254 CPL_C_START 00255 00256 void CPL_DLL *OGRMalloc( size_t ); 00257 void CPL_DLL *OGRCalloc( size_t, size_t ); 00258 void CPL_DLL *OGRRealloc( void *, size_t ); 00259 char CPL_DLL *OGRStrdup( const char * ); 00260 void CPL_DLL OGRFree( void * ); 00261 00262 typedef int OGRErr; 00263 00264 #define OGRERR_NONE 0 00265 #define OGRERR_NOT_ENOUGH_DATA 1 /* not enough data to deserialize */ 00266 #define OGRERR_NOT_ENOUGH_MEMORY 2 00267 #define OGRERR_UNSUPPORTED_GEOMETRY_TYPE 3 00268 #define OGRERR_UNSUPPORTED_OPERATION 4 00269 #define OGRERR_CORRUPT_DATA 5 00270 #define OGRERR_FAILURE 6 00271 #define OGRERR_UNSUPPORTED_SRS 7 00272 #define OGRERR_INVALID_HANDLE 8 00273 00274 typedef int OGRBoolean; 00275 00276 /* -------------------------------------------------------------------- */ 00277 /* ogr_geometry.h related definitions. */ 00278 /* -------------------------------------------------------------------- */ 00285 typedef enum 00286 { 00287 wkbUnknown = 0, 00288 wkbPoint = 1, 00289 wkbLineString = 2, 00291 wkbPolygon = 3, 00294 wkbMultiPoint = 4, 00295 wkbMultiLineString = 5, 00296 wkbMultiPolygon = 6, 00297 wkbGeometryCollection = 7, 00299 wkbNone = 100, 00300 wkbLinearRing = 101, 00301 wkbPoint25D = 0x80000001, 00302 wkbLineString25D = 0x80000002, 00303 wkbPolygon25D = 0x80000003, 00304 wkbMultiPoint25D = 0x80000004, 00305 wkbMultiLineString25D = 0x80000005, 00306 wkbMultiPolygon25D = 0x80000006, 00307 wkbGeometryCollection25D = 0x80000007 00308 } OGRwkbGeometryType; 00309 00310 #define wkb25DBit 0x80000000 00311 #define wkbFlatten(x) ((OGRwkbGeometryType) ((x) & (~wkb25DBit))) 00312 00313 #define ogrZMarker 0x21125711 00314 00315 const char CPL_DLL * OGRGeometryTypeToName( OGRwkbGeometryType eType ); 00316 OGRwkbGeometryType CPL_DLL OGRMergeGeometryTypes( OGRwkbGeometryType eMain, 00317 OGRwkbGeometryType eExtra ); 00318 00319 typedef enum 00320 { 00321 wkbXDR = 0, /* MSB/Sun/Motoroloa: Most Significant Byte First */ 00322 wkbNDR = 1 /* LSB/Intel/Vax: Least Significant Byte First */ 00323 } OGRwkbByteOrder; 00324 00325 #ifndef NO_HACK_FOR_IBM_DB2_V72 00326 # define HACK_FOR_IBM_DB2_V72 00327 #endif 00328 00329 #ifdef HACK_FOR_IBM_DB2_V72 00330 # define DB2_V72_FIX_BYTE_ORDER(x) ((((x) & 0x31) == (x)) ? (OGRwkbByteOrder) ((x) & 0x1) : (x)) 00331 # define DB2_V72_UNFIX_BYTE_ORDER(x) ((unsigned char) (OGRGeometry::bGenerate_DB2_V72_BYTE_ORDER ? ((x) | 0x30) : (x))) 00332 #else 00333 # define DB2_V72_FIX_BYTE_ORDER(x) (x) 00334 # define DB2_V72_UNFIX_BYTE_ORDER(x) (x) 00335 #endif 00336 00337 #define ALTER_NAME_FLAG 0x1 00338 #define ALTER_TYPE_FLAG 0x2 00339 #define ALTER_WIDTH_PRECISION_FLAG 0x4 00340 #define ALTER_ALL_FLAG (ALTER_NAME_FLAG | ALTER_TYPE_FLAG | ALTER_WIDTH_PRECISION_FLAG) 00341 00342 /************************************************************************/ 00343 /* ogr_feature.h related definitions. */ 00344 /************************************************************************/ 00345 00352 typedef enum 00353 { OFTInteger = 0, OFTIntegerList = 1, OFTReal = 2, OFTRealList = 3, OFTString = 4, OFTStringList = 5, OFTWideString = 6, OFTWideStringList = 7, OFTBinary = 8, OFTDate = 9, OFTTime = 10, OFTDateTime = 11, 00366 OFTMaxType = 11 00367 } OGRFieldType; 00368 00373 typedef enum 00374 { 00375 OJUndefined = 0, 00376 OJLeft = 1, 00377 OJRight = 2 00378 } OGRJustification; 00379 00380 #define OGRNullFID -1 00381 #define OGRUnsetMarker -21121 00382 00383 /************************************************************************/ 00384 /* OGRField */ 00385 /************************************************************************/ 00386 00391 typedef union { 00392 int Integer; 00393 double Real; 00394 char *String; 00395 00396 struct { 00397 int nCount; 00398 int *paList; 00399 } IntegerList; 00400 00401 struct { 00402 int nCount; 00403 double *paList; 00404 } RealList; 00405 00406 struct { 00407 int nCount; 00408 char **paList; 00409 } StringList; 00410 00411 struct { 00412 int nCount; 00413 GByte *paData; 00414 } Binary; 00415 00416 struct { 00417 int nMarker1; 00418 int nMarker2; 00419 } Set; 00420 00421 struct { 00422 GInt16 Year; 00423 GByte Month; 00424 GByte Day; 00425 GByte Hour; 00426 GByte Minute; 00427 GByte Second; 00428 GByte TZFlag; /* 0=unknown, 1=localtime(ambiguous), 00429 100=GMT, 104=GMT+1, 80=GMT-5, etc */ 00430 } Date; 00431 } OGRField; 00432 00433 int CPL_DLL OGRParseDate( const char *pszInput, OGRField *psOutput, 00434 int nOptions ); 00435 00436 /* -------------------------------------------------------------------- */ 00437 /* Constants from ogrsf_frmts.h for capabilities. */ 00438 /* -------------------------------------------------------------------- */ 00439 #define OLCRandomRead "RandomRead" 00440 #define OLCSequentialWrite "SequentialWrite" 00441 #define OLCRandomWrite "RandomWrite" 00442 #define OLCFastSpatialFilter "FastSpatialFilter" 00443 #define OLCFastFeatureCount "FastFeatureCount" 00444 #define OLCFastGetExtent "FastGetExtent" 00445 #define OLCCreateField "CreateField" 00446 #define OLCDeleteField "DeleteField" 00447 #define OLCReorderFields "ReorderFields" 00448 #define OLCAlterFieldDefn "AlterFieldDefn" 00449 #define OLCTransactions "Transactions" 00450 #define OLCDeleteFeature "DeleteFeature" 00451 #define OLCFastSetNextByIndex "FastSetNextByIndex" 00452 #define OLCStringsAsUTF8 "StringsAsUTF8" 00453 #define OLCIgnoreFields "IgnoreFields" 00454 00455 #define ODsCCreateLayer "CreateLayer" 00456 #define ODsCDeleteLayer "DeleteLayer" 00457 00458 #define ODrCCreateDataSource "CreateDataSource" 00459 #define ODrCDeleteDataSource "DeleteDataSource" 00460 00461 00462 /************************************************************************/ 00463 /* ogr_featurestyle.h related definitions. */ 00464 /************************************************************************/ 00465 00470 typedef enum ogr_style_tool_class_id 00471 { 00472 OGRSTCNone = 0, 00473 OGRSTCPen = 1, 00474 OGRSTCBrush = 2, 00475 OGRSTCSymbol = 3, 00476 OGRSTCLabel = 4, 00477 OGRSTCVector = 5 00478 } OGRSTClassId; 00479 00483 typedef enum ogr_style_tool_units_id 00484 { 00485 OGRSTUGround = 0, 00486 OGRSTUPixel = 1, 00487 OGRSTUPoints = 2, 00488 OGRSTUMM = 3, 00489 OGRSTUCM = 4, 00490 OGRSTUInches = 5 00491 } OGRSTUnitId; 00492 00496 typedef enum ogr_style_tool_param_pen_id 00497 { 00498 OGRSTPenColor = 0, 00499 OGRSTPenWidth = 1, 00500 OGRSTPenPattern = 2, 00501 OGRSTPenId = 3, 00502 OGRSTPenPerOffset = 4, 00503 OGRSTPenCap = 5, 00504 OGRSTPenJoin = 6, 00505 OGRSTPenPriority = 7, 00506 OGRSTPenLast = 8 00507 00508 } OGRSTPenParam; 00509 00513 typedef enum ogr_style_tool_param_brush_id 00514 { 00515 OGRSTBrushFColor = 0, 00516 OGRSTBrushBColor = 1, 00517 OGRSTBrushId = 2, 00518 OGRSTBrushAngle = 3, 00519 OGRSTBrushSize = 4, 00520 OGRSTBrushDx = 5, 00521 OGRSTBrushDy = 6, 00522 OGRSTBrushPriority = 7, 00523 OGRSTBrushLast = 8 00524 00525 } OGRSTBrushParam; 00526 00527 00531 typedef enum ogr_style_tool_param_symbol_id 00532 { 00533 OGRSTSymbolId = 0, 00534 OGRSTSymbolAngle = 1, 00535 OGRSTSymbolColor = 2, 00536 OGRSTSymbolSize = 3, 00537 OGRSTSymbolDx = 4, 00538 OGRSTSymbolDy = 5, 00539 OGRSTSymbolStep = 6, 00540 OGRSTSymbolPerp = 7, 00541 OGRSTSymbolOffset = 8, 00542 OGRSTSymbolPriority = 9, 00543 OGRSTSymbolFontName = 10, 00544 OGRSTSymbolOColor = 11, 00545 OGRSTSymbolLast = 12 00546 00547 } OGRSTSymbolParam; 00548 00552 typedef enum ogr_style_tool_param_label_id 00553 { 00554 OGRSTLabelFontName = 0, 00555 OGRSTLabelSize = 1, 00556 OGRSTLabelTextString = 2, 00557 OGRSTLabelAngle = 3, 00558 OGRSTLabelFColor = 4, 00559 OGRSTLabelBColor = 5, 00560 OGRSTLabelPlacement = 6, 00561 OGRSTLabelAnchor = 7, 00562 OGRSTLabelDx = 8, 00563 OGRSTLabelDy = 9, 00564 OGRSTLabelPerp = 10, 00565 OGRSTLabelBold = 11, 00566 OGRSTLabelItalic = 12, 00567 OGRSTLabelUnderline = 13, 00568 OGRSTLabelPriority = 14, 00569 OGRSTLabelStrikeout = 15, 00570 OGRSTLabelStretch = 16, 00571 OGRSTLabelAdjHor = 17, 00572 OGRSTLabelAdjVert = 18, 00573 OGRSTLabelHColor = 19, 00574 OGRSTLabelOColor = 20, 00575 OGRSTLabelLast = 21 00576 00577 } OGRSTLabelParam; 00578 00579 /* ------------------------------------------------------------------- */ 00580 /* Version checking */ 00581 /* -------------------------------------------------------------------- */ 00582 00583 /* Note to developers : please keep this section in sync with gdal.h */ 00584 00585 #ifndef GDAL_VERSION_INFO_DEFINED 00586 #define GDAL_VERSION_INFO_DEFINED 00587 const char CPL_DLL * CPL_STDCALL GDALVersionInfo( const char * ); 00588 #endif 00589 00590 #ifndef GDAL_CHECK_VERSION 00591 00603 int CPL_DLL CPL_STDCALL GDALCheckVersion( int nVersionMajor, int nVersionMinor, 00604 const char* pszCallingComponentName); 00605 00607 #define GDAL_CHECK_VERSION(pszCallingComponentName) \ 00608 GDALCheckVersion(GDAL_VERSION_MAJOR, GDAL_VERSION_MINOR, pszCallingComponentName) 00609 00610 #endif 00611 00612 CPL_C_END 00613 00614 #endif /* ndef OGR_CORE_H_INCLUDED */