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