00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef OGR_CORE_H_INCLUDED
00032 #define OGR_CORE_H_INCLUDED
00033
00034 #include "cpl_port.h"
00035 #include "gdal_version.h"
00036
00047 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
00048 class CPL_DLL OGREnvelope
00049 {
00050 public:
00051 OGREnvelope() : MinX(0.0), MaxX(0.0), MinY(0.0), MaxY(0.0)
00052 {
00053 }
00054
00055 OGREnvelope(const OGREnvelope& oOther) :
00056 MinX(oOther.MinX),MaxX(oOther.MaxX), MinY(oOther.MinY), MaxY(oOther.MaxY)
00057 {
00058 }
00059
00060 double MinX;
00061 double MaxX;
00062 double MinY;
00063 double MaxY;
00064
00065
00066 #if (__GNUC__ == 4 && __GNUC_MINOR__ >= 6 && !defined(_MSC_VER))
00067 #pragma GCC diagnostic ignored "-Wfloat-equal"
00068 #pragma GCC diagnostic push
00069 #endif
00070 int IsInit() const { return MinX != 0 || MinY != 0 || MaxX != 0 || MaxY != 0; }
00071
00072 #if (__GNUC__ == 4 && __GNUC_MINOR__ >= 6 && !defined(_MSC_VER))
00073 #pragma GCC diagnostic pop
00074 #endif
00075
00076 void Merge( OGREnvelope const& sOther ) {
00077 if( IsInit() )
00078 {
00079 MinX = MIN(MinX,sOther.MinX);
00080 MaxX = MAX(MaxX,sOther.MaxX);
00081 MinY = MIN(MinY,sOther.MinY);
00082 MaxY = MAX(MaxY,sOther.MaxY);
00083 }
00084 else
00085 {
00086 MinX = sOther.MinX;
00087 MaxX = sOther.MaxX;
00088 MinY = sOther.MinY;
00089 MaxY = sOther.MaxY;
00090 }
00091 }
00092 void Merge( double dfX, double dfY ) {
00093 if( IsInit() )
00094 {
00095 MinX = MIN(MinX,dfX);
00096 MaxX = MAX(MaxX,dfX);
00097 MinY = MIN(MinY,dfY);
00098 MaxY = MAX(MaxY,dfY);
00099 }
00100 else
00101 {
00102 MinX = MaxX = dfX;
00103 MinY = MaxY = dfY;
00104 }
00105 }
00106
00107 void Intersect( OGREnvelope const& sOther ) {
00108 if(Intersects(sOther))
00109 {
00110 if( IsInit() )
00111 {
00112 MinX = MAX(MinX,sOther.MinX);
00113 MaxX = MIN(MaxX,sOther.MaxX);
00114 MinY = MAX(MinY,sOther.MinY);
00115 MaxY = MIN(MaxY,sOther.MaxY);
00116 }
00117 else
00118 {
00119 MinX = sOther.MinX;
00120 MaxX = sOther.MaxX;
00121 MinY = sOther.MinY;
00122 MaxY = sOther.MaxY;
00123 }
00124 }
00125 else
00126 {
00127 MinX = 0;
00128 MaxX = 0;
00129 MinY = 0;
00130 MaxY = 0;
00131 }
00132 }
00133
00134 int Intersects(OGREnvelope const& other) const
00135 {
00136 return MinX <= other.MaxX && MaxX >= other.MinX &&
00137 MinY <= other.MaxY && MaxY >= other.MinY;
00138 }
00139
00140 int Contains(OGREnvelope const& other) const
00141 {
00142 return MinX <= other.MinX && MinY <= other.MinY &&
00143 MaxX >= other.MaxX && MaxY >= other.MaxY;
00144 }
00145 };
00146 #else
00147 typedef struct
00148 {
00149 double MinX;
00150 double MaxX;
00151 double MinY;
00152 double MaxY;
00153 } OGREnvelope;
00154 #endif
00155
00156
00161 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
00162 class CPL_DLL OGREnvelope3D : public OGREnvelope
00163 {
00164 public:
00165 OGREnvelope3D() : OGREnvelope(), MinZ(0.0), MaxZ(0.0)
00166 {
00167 }
00168
00169 OGREnvelope3D(const OGREnvelope3D& oOther) :
00170 OGREnvelope(oOther),
00171 MinZ(oOther.MinZ), MaxZ(oOther.MaxZ)
00172 {
00173 }
00174
00175 double MinZ;
00176 double MaxZ;
00177
00178 int IsInit() const { return MinX != 0 || MinY != 0 || MaxX != 0 || MaxY != 0 || MinZ != 0 || MaxZ != 0; }
00179 void Merge( OGREnvelope3D const& sOther ) {
00180 if( IsInit() )
00181 {
00182 MinX = MIN(MinX,sOther.MinX);
00183 MaxX = MAX(MaxX,sOther.MaxX);
00184 MinY = MIN(MinY,sOther.MinY);
00185 MaxY = MAX(MaxY,sOther.MaxY);
00186 MinZ = MIN(MinZ,sOther.MinZ);
00187 MaxZ = MAX(MaxZ,sOther.MaxZ);
00188 }
00189 else
00190 {
00191 MinX = sOther.MinX;
00192 MaxX = sOther.MaxX;
00193 MinY = sOther.MinY;
00194 MaxY = sOther.MaxY;
00195 MinZ = sOther.MinZ;
00196 MaxZ = sOther.MaxZ;
00197 }
00198 }
00199 void Merge( double dfX, double dfY, double dfZ ) {
00200 if( IsInit() )
00201 {
00202 MinX = MIN(MinX,dfX);
00203 MaxX = MAX(MaxX,dfX);
00204 MinY = MIN(MinY,dfY);
00205 MaxY = MAX(MaxY,dfY);
00206 MinZ = MIN(MinZ,dfZ);
00207 MaxZ = MAX(MaxZ,dfZ);
00208 }
00209 else
00210 {
00211 MinX = MaxX = dfX;
00212 MinY = MaxY = dfY;
00213 MinZ = MaxZ = dfZ;
00214 }
00215 }
00216
00217 void Intersect( OGREnvelope3D const& sOther ) {
00218 if(Intersects(sOther))
00219 {
00220 if( IsInit() )
00221 {
00222 MinX = MAX(MinX,sOther.MinX);
00223 MaxX = MIN(MaxX,sOther.MaxX);
00224 MinY = MAX(MinY,sOther.MinY);
00225 MaxY = MIN(MaxY,sOther.MaxY);
00226 MinZ = MAX(MinZ,sOther.MinZ);
00227 MaxZ = MIN(MaxZ,sOther.MaxZ);
00228 }
00229 else
00230 {
00231 MinX = sOther.MinX;
00232 MaxX = sOther.MaxX;
00233 MinY = sOther.MinY;
00234 MaxY = sOther.MaxY;
00235 MinZ = sOther.MinZ;
00236 MaxZ = sOther.MaxZ;
00237 }
00238 }
00239 else
00240 {
00241 MinX = 0;
00242 MaxX = 0;
00243 MinY = 0;
00244 MaxY = 0;
00245 MinZ = 0;
00246 MaxZ = 0;
00247 }
00248 }
00249
00250 int Intersects(OGREnvelope3D const& other) const
00251 {
00252 return MinX <= other.MaxX && MaxX >= other.MinX &&
00253 MinY <= other.MaxY && MaxY >= other.MinY &&
00254 MinZ <= other.MaxZ && MaxZ >= other.MinZ;
00255 }
00256
00257 int Contains(OGREnvelope3D const& other) const
00258 {
00259 return MinX <= other.MinX && MinY <= other.MinY &&
00260 MaxX >= other.MaxX && MaxY >= other.MaxY &&
00261 MinZ <= other.MinZ && MaxZ >= other.MaxZ;
00262 }
00263 };
00264 #else
00265 typedef struct
00266 {
00267 double MinX;
00268 double MaxX;
00269 double MinY;
00270 double MaxY;
00271 double MinZ;
00272 double MaxZ;
00273 } OGREnvelope3D;
00274 #endif
00275
00276
00277 CPL_C_START
00278
00279 void CPL_DLL *OGRMalloc( size_t );
00280 void CPL_DLL *OGRCalloc( size_t, size_t );
00281 void CPL_DLL *OGRRealloc( void *, size_t );
00282 char CPL_DLL *OGRStrdup( const char * );
00283 void CPL_DLL OGRFree( void * );
00284
00285 typedef int OGRErr;
00286
00287 #define OGRERR_NONE 0
00288 #define OGRERR_NOT_ENOUGH_DATA 1
00289 #define OGRERR_NOT_ENOUGH_MEMORY 2
00290 #define OGRERR_UNSUPPORTED_GEOMETRY_TYPE 3
00291 #define OGRERR_UNSUPPORTED_OPERATION 4
00292 #define OGRERR_CORRUPT_DATA 5
00293 #define OGRERR_FAILURE 6
00294 #define OGRERR_UNSUPPORTED_SRS 7
00295 #define OGRERR_INVALID_HANDLE 8
00296
00297 typedef int OGRBoolean;
00298
00299
00300
00301
00302
00308 typedef enum
00309 {
00310 wkbUnknown = 0,
00311 wkbPoint = 1,
00312 wkbLineString = 2,
00314 wkbPolygon = 3,
00317 wkbMultiPoint = 4,
00318 wkbMultiLineString = 5,
00319 wkbMultiPolygon = 6,
00320 wkbGeometryCollection = 7,
00322 wkbNone = 100,
00323 wkbLinearRing = 101,
00324 wkbPoint25D = 0x80000001,
00325 wkbLineString25D = 0x80000002,
00326 wkbPolygon25D = 0x80000003,
00327 wkbMultiPoint25D = 0x80000004,
00328 wkbMultiLineString25D = 0x80000005,
00329 wkbMultiPolygon25D = 0x80000006,
00330 wkbGeometryCollection25D = 0x80000007
00331 } OGRwkbGeometryType;
00332
00340 typedef enum
00341 {
00342 wkbVariantOgc,
00343 wkbVariantIso
00344 } OGRwkbVariant;
00345
00346 #define wkb25DBit 0x80000000
00347 #define wkbFlatten(x) ((OGRwkbGeometryType) ((x) & (~wkb25DBit)))
00348
00349 #define ogrZMarker 0x21125711
00350
00351 const char CPL_DLL * OGRGeometryTypeToName( OGRwkbGeometryType eType );
00352 OGRwkbGeometryType CPL_DLL OGRMergeGeometryTypes( OGRwkbGeometryType eMain,
00353 OGRwkbGeometryType eExtra );
00354
00355 typedef enum
00356 {
00357 wkbXDR = 0,
00358 wkbNDR = 1
00359 } OGRwkbByteOrder;
00360
00361 #ifndef NO_HACK_FOR_IBM_DB2_V72
00362 # define HACK_FOR_IBM_DB2_V72
00363 #endif
00364
00365 #ifdef HACK_FOR_IBM_DB2_V72
00366 # define DB2_V72_FIX_BYTE_ORDER(x) ((((x) & 0x31) == (x)) ? (OGRwkbByteOrder) ((x) & 0x1) : (x))
00367 # define DB2_V72_UNFIX_BYTE_ORDER(x) ((unsigned char) (OGRGeometry::bGenerate_DB2_V72_BYTE_ORDER ? ((x) | 0x30) : (x)))
00368 #else
00369 # define DB2_V72_FIX_BYTE_ORDER(x) (x)
00370 # define DB2_V72_UNFIX_BYTE_ORDER(x) (x)
00371 #endif
00372
00373 #define ALTER_NAME_FLAG 0x1
00374 #define ALTER_TYPE_FLAG 0x2
00375 #define ALTER_WIDTH_PRECISION_FLAG 0x4
00376 #define ALTER_ALL_FLAG (ALTER_NAME_FLAG | ALTER_TYPE_FLAG | ALTER_WIDTH_PRECISION_FLAG)
00377
00378
00379
00380
00381
00388 typedef enum
00389 { OFTInteger = 0, OFTIntegerList = 1, OFTReal = 2, OFTRealList = 3, OFTString = 4, OFTStringList = 5, OFTWideString = 6, OFTWideStringList = 7, OFTBinary = 8, OFTDate = 9, OFTTime = 10, OFTDateTime = 11,
00402 OFTMaxType = 11
00403 } OGRFieldType;
00404
00409 typedef enum
00410 {
00411 OJUndefined = 0,
00412 OJLeft = 1,
00413 OJRight = 2
00414 } OGRJustification;
00415
00416 #define OGRNullFID -1
00417 #define OGRUnsetMarker -21121
00418
00419
00420
00421
00422
00427 typedef union {
00428 int Integer;
00429 double Real;
00430 char *String;
00431
00432 struct {
00433 int nCount;
00434 int *paList;
00435 } IntegerList;
00436
00437 struct {
00438 int nCount;
00439 double *paList;
00440 } RealList;
00441
00442 struct {
00443 int nCount;
00444 char **paList;
00445 } StringList;
00446
00447 struct {
00448 int nCount;
00449 GByte *paData;
00450 } Binary;
00451
00452 struct {
00453 int nMarker1;
00454 int nMarker2;
00455 } Set;
00456
00457 struct {
00458 GInt16 Year;
00459 GByte Month;
00460 GByte Day;
00461 GByte Hour;
00462 GByte Minute;
00463 GByte Second;
00464 GByte TZFlag;
00465
00466 } Date;
00467 } OGRField;
00468
00469 int CPL_DLL OGRParseDate( const char *pszInput, OGRField *psOutput,
00470 int nOptions );
00471
00472
00473
00474
00475 #define OLCRandomRead "RandomRead"
00476 #define OLCSequentialWrite "SequentialWrite"
00477 #define OLCRandomWrite "RandomWrite"
00478 #define OLCFastSpatialFilter "FastSpatialFilter"
00479 #define OLCFastFeatureCount "FastFeatureCount"
00480 #define OLCFastGetExtent "FastGetExtent"
00481 #define OLCCreateField "CreateField"
00482 #define OLCDeleteField "DeleteField"
00483 #define OLCReorderFields "ReorderFields"
00484 #define OLCAlterFieldDefn "AlterFieldDefn"
00485 #define OLCTransactions "Transactions"
00486 #define OLCDeleteFeature "DeleteFeature"
00487 #define OLCFastSetNextByIndex "FastSetNextByIndex"
00488 #define OLCStringsAsUTF8 "StringsAsUTF8"
00489 #define OLCIgnoreFields "IgnoreFields"
00490 #define OLCCreateGeomField "CreateGeomField"
00491
00492 #define ODsCCreateLayer "CreateLayer"
00493 #define ODsCDeleteLayer "DeleteLayer"
00494 #define ODsCCreateGeomFieldAfterCreateLayer "CreateGeomFieldAfterCreateLayer"
00495
00496 #define ODrCCreateDataSource "CreateDataSource"
00497 #define ODrCDeleteDataSource "DeleteDataSource"
00498
00499
00500
00501
00502
00503
00508 typedef enum ogr_style_tool_class_id
00509 {
00510 OGRSTCNone = 0,
00511 OGRSTCPen = 1,
00512 OGRSTCBrush = 2,
00513 OGRSTCSymbol = 3,
00514 OGRSTCLabel = 4,
00515 OGRSTCVector = 5
00516 } OGRSTClassId;
00517
00521 typedef enum ogr_style_tool_units_id
00522 {
00523 OGRSTUGround = 0,
00524 OGRSTUPixel = 1,
00525 OGRSTUPoints = 2,
00526 OGRSTUMM = 3,
00527 OGRSTUCM = 4,
00528 OGRSTUInches = 5
00529 } OGRSTUnitId;
00530
00534 typedef enum ogr_style_tool_param_pen_id
00535 {
00536 OGRSTPenColor = 0,
00537 OGRSTPenWidth = 1,
00538 OGRSTPenPattern = 2,
00539 OGRSTPenId = 3,
00540 OGRSTPenPerOffset = 4,
00541 OGRSTPenCap = 5,
00542 OGRSTPenJoin = 6,
00543 OGRSTPenPriority = 7,
00544 OGRSTPenLast = 8
00545
00546 } OGRSTPenParam;
00547
00551 typedef enum ogr_style_tool_param_brush_id
00552 {
00553 OGRSTBrushFColor = 0,
00554 OGRSTBrushBColor = 1,
00555 OGRSTBrushId = 2,
00556 OGRSTBrushAngle = 3,
00557 OGRSTBrushSize = 4,
00558 OGRSTBrushDx = 5,
00559 OGRSTBrushDy = 6,
00560 OGRSTBrushPriority = 7,
00561 OGRSTBrushLast = 8
00562
00563 } OGRSTBrushParam;
00564
00565
00569 typedef enum ogr_style_tool_param_symbol_id
00570 {
00571 OGRSTSymbolId = 0,
00572 OGRSTSymbolAngle = 1,
00573 OGRSTSymbolColor = 2,
00574 OGRSTSymbolSize = 3,
00575 OGRSTSymbolDx = 4,
00576 OGRSTSymbolDy = 5,
00577 OGRSTSymbolStep = 6,
00578 OGRSTSymbolPerp = 7,
00579 OGRSTSymbolOffset = 8,
00580 OGRSTSymbolPriority = 9,
00581 OGRSTSymbolFontName = 10,
00582 OGRSTSymbolOColor = 11,
00583 OGRSTSymbolLast = 12
00584
00585 } OGRSTSymbolParam;
00586
00590 typedef enum ogr_style_tool_param_label_id
00591 {
00592 OGRSTLabelFontName = 0,
00593 OGRSTLabelSize = 1,
00594 OGRSTLabelTextString = 2,
00595 OGRSTLabelAngle = 3,
00596 OGRSTLabelFColor = 4,
00597 OGRSTLabelBColor = 5,
00598 OGRSTLabelPlacement = 6,
00599 OGRSTLabelAnchor = 7,
00600 OGRSTLabelDx = 8,
00601 OGRSTLabelDy = 9,
00602 OGRSTLabelPerp = 10,
00603 OGRSTLabelBold = 11,
00604 OGRSTLabelItalic = 12,
00605 OGRSTLabelUnderline = 13,
00606 OGRSTLabelPriority = 14,
00607 OGRSTLabelStrikeout = 15,
00608 OGRSTLabelStretch = 16,
00609 OGRSTLabelAdjHor = 17,
00610 OGRSTLabelAdjVert = 18,
00611 OGRSTLabelHColor = 19,
00612 OGRSTLabelOColor = 20,
00613 OGRSTLabelLast = 21
00614
00615 } OGRSTLabelParam;
00616
00617
00618
00619
00620
00621
00622
00623 #ifndef GDAL_VERSION_INFO_DEFINED
00624 #define GDAL_VERSION_INFO_DEFINED
00625 const char CPL_DLL * CPL_STDCALL GDALVersionInfo( const char * );
00626 #endif
00627
00628 #ifndef GDAL_CHECK_VERSION
00629
00641 int CPL_DLL CPL_STDCALL GDALCheckVersion( int nVersionMajor, int nVersionMinor,
00642 const char* pszCallingComponentName);
00643
00645 #define GDAL_CHECK_VERSION(pszCallingComponentName) \
00646 GDALCheckVersion(GDAL_VERSION_MAJOR, GDAL_VERSION_MINOR, pszCallingComponentName)
00647
00648 #endif
00649
00650 CPL_C_END
00651
00652 #endif