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__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(_MSC_VER))
00067 #pragma GCC diagnostic push
00068 #pragma GCC diagnostic ignored "-Wfloat-equal"
00069 #endif
00070 int IsInit() const { return MinX != 0 || MinY != 0 || MaxX != 0 || MaxY != 0; }
00071
00072 #if ((__GNUC__ > 4 || (__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_SURESS_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 #define OGRERR_NON_EXISTING_FEATURE 9
00297
00298 typedef int OGRBoolean;
00299
00300
00301
00302
00303
00309 typedef enum
00310 {
00311 wkbUnknown = 0,
00313 wkbPoint = 1,
00314 wkbLineString = 2,
00316 wkbPolygon = 3,
00319 wkbMultiPoint = 4,
00320 wkbMultiLineString = 5,
00321 wkbMultiPolygon = 6,
00322 wkbGeometryCollection = 7,
00325 wkbCircularString = 8,
00327 wkbCompoundCurve = 9,
00328 wkbCurvePolygon = 10,
00331 wkbMultiCurve = 11,
00332 wkbMultiSurface = 12,
00334 wkbNone = 100,
00335 wkbLinearRing = 101,
00337 wkbCircularStringZ = 1008,
00338 wkbCompoundCurveZ = 1009,
00339 wkbCurvePolygonZ = 1010,
00340 wkbMultiCurveZ = 1011,
00341 wkbMultiSurfaceZ = 1012,
00343 wkbPoint25D = 0x80000001,
00344 wkbLineString25D = 0x80000002,
00345 wkbPolygon25D = 0x80000003,
00346 wkbMultiPoint25D = 0x80000004,
00347 wkbMultiLineString25D = 0x80000005,
00348 wkbMultiPolygon25D = 0x80000006,
00349 wkbGeometryCollection25D = 0x80000007
00351 } OGRwkbGeometryType;
00352
00353
00354 #define wkbCurve ((OGRwkbGeometryType)13)
00355 #define wkbSurface ((OGRwkbGeometryType)14)
00371 typedef enum
00372 {
00373 wkbVariantOldOgc,
00374 wkbVariantIso,
00375 wkbVariantPostGIS1
00376 } OGRwkbVariant;
00377
00378
00380 #ifndef GDAL_COMPILATION
00381 #define wkb25DBit 0x80000000
00382 #endif
00383
00385 #define wkbFlatten(x) OGR_GT_Flatten((OGRwkbGeometryType)(x))
00386
00390 #define wkbHasZ(x) OGR_GT_HasZ(x)
00391
00395 #define wkbSetZ(x) OGR_GT_SetZ(x)
00396
00397 #define ogrZMarker 0x21125711
00398
00399 const char CPL_DLL * OGRGeometryTypeToName( OGRwkbGeometryType eType );
00400 OGRwkbGeometryType CPL_DLL OGRMergeGeometryTypes( OGRwkbGeometryType eMain,
00401 OGRwkbGeometryType eExtra );
00402 OGRwkbGeometryType CPL_DLL OGRMergeGeometryTypesEx( OGRwkbGeometryType eMain,
00403 OGRwkbGeometryType eExtra,
00404 int bAllowPromotingToCurves );
00405 OGRwkbGeometryType CPL_DLL OGR_GT_Flatten( OGRwkbGeometryType eType );
00406 OGRwkbGeometryType CPL_DLL OGR_GT_SetZ( OGRwkbGeometryType eType );
00407 OGRwkbGeometryType CPL_DLL OGR_GT_SetModifier( OGRwkbGeometryType eType, int bSetZ, int bSetM );
00408 int CPL_DLL OGR_GT_HasZ( OGRwkbGeometryType eType );
00409 int CPL_DLL OGR_GT_IsSubClassOf( OGRwkbGeometryType eType,
00410 OGRwkbGeometryType eSuperType );
00411 int CPL_DLL OGR_GT_IsCurve( OGRwkbGeometryType );
00412 int CPL_DLL OGR_GT_IsSurface( OGRwkbGeometryType );
00413 int CPL_DLL OGR_GT_IsNonLinear( OGRwkbGeometryType );
00414 OGRwkbGeometryType CPL_DLL OGR_GT_GetCollection( OGRwkbGeometryType eType );
00415 OGRwkbGeometryType CPL_DLL OGR_GT_GetCurve( OGRwkbGeometryType eType );
00416 OGRwkbGeometryType CPL_DLL OGR_GT_GetLinear( OGRwkbGeometryType eType );
00417
00418 typedef enum
00419 {
00420 wkbXDR = 0,
00421 wkbNDR = 1
00422 } OGRwkbByteOrder;
00423
00424 #ifndef NO_HACK_FOR_IBM_DB2_V72
00425 # define HACK_FOR_IBM_DB2_V72
00426 #endif
00427
00428 #ifdef HACK_FOR_IBM_DB2_V72
00429 # define DB2_V72_FIX_BYTE_ORDER(x) ((((x) & 0x31) == (x)) ? (OGRwkbByteOrder) ((x) & 0x1) : (x))
00430 # define DB2_V72_UNFIX_BYTE_ORDER(x) ((unsigned char) (OGRGeometry::bGenerate_DB2_V72_BYTE_ORDER ? ((x) | 0x30) : (x)))
00431 #else
00432 # define DB2_V72_FIX_BYTE_ORDER(x) (x)
00433 # define DB2_V72_UNFIX_BYTE_ORDER(x) (x)
00434 #endif
00435
00439 #define ALTER_NAME_FLAG 0x1
00440
00444 #define ALTER_TYPE_FLAG 0x2
00445
00449 #define ALTER_WIDTH_PRECISION_FLAG 0x4
00450
00455 #define ALTER_NULLABLE_FLAG 0x8
00456
00461 #define ALTER_DEFAULT_FLAG 0x10
00462
00466 #define ALTER_ALL_FLAG (ALTER_NAME_FLAG | ALTER_TYPE_FLAG | ALTER_WIDTH_PRECISION_FLAG | ALTER_NULLABLE_FLAG | ALTER_DEFAULT_FLAG)
00467
00468
00473 #define OGR_F_VAL_NULL 0x00000001
00474
00479 #define OGR_F_VAL_GEOM_TYPE 0x00000002
00480
00485 #define OGR_F_VAL_WIDTH 0x00000004
00486
00494 #define OGR_F_VAL_ALLOW_NULL_WHEN_DEFAULT 0x00000008
00495
00500 #define OGR_F_VAL_ALL 0xFFFFFFFF
00501
00502
00503
00504
00505
00512 typedef enum
00513 { OFTInteger = 0, OFTIntegerList = 1, OFTReal = 2, OFTRealList = 3, OFTString = 4, OFTStringList = 5, OFTWideString = 6, OFTWideStringList = 7, OFTBinary = 8, OFTDate = 9, OFTTime = 10, OFTDateTime = 11, OFTInteger64 = 12, OFTInteger64List = 13,
00528 OFTMaxType = 13
00529 } OGRFieldType;
00530
00540 typedef enum
00541 { OFSTNone = 0,
00544 OFSTBoolean = 1,
00546 OFSTInt16 = 2,
00548 OFSTFloat32 = 3,
00549 OFSTMaxSubType = 3
00550 } OGRFieldSubType;
00551
00556 typedef enum
00557 {
00558 OJUndefined = 0,
00559 OJLeft = 1,
00560 OJRight = 2
00561 } OGRJustification;
00562
00563 #define OGRNullFID -1
00564 #define OGRUnsetMarker -21121
00565
00566
00567
00568
00569
00574 typedef union {
00575 int Integer;
00576 GIntBig Integer64;
00577 double Real;
00578 char *String;
00579
00580 struct {
00581 int nCount;
00582 int *paList;
00583 } IntegerList;
00584
00585 struct {
00586 int nCount;
00587 GIntBig *paList;
00588 } Integer64List;
00589
00590 struct {
00591 int nCount;
00592 double *paList;
00593 } RealList;
00594
00595 struct {
00596 int nCount;
00597 char **paList;
00598 } StringList;
00599
00600 struct {
00601 int nCount;
00602 GByte *paData;
00603 } Binary;
00604
00605 struct {
00606 int nMarker1;
00607 int nMarker2;
00608 } Set;
00609
00610 struct {
00611 GInt16 Year;
00612 GByte Month;
00613 GByte Day;
00614 GByte Hour;
00615 GByte Minute;
00616 GByte TZFlag;
00617
00618 GByte Reserved;
00619 float Second;
00620 } Date;
00621 } OGRField;
00622
00623 #define OGR_GET_MS(floatingpoint_sec) (int)(((floatingpoint_sec) - (int)(floatingpoint_sec)) * 1000 + 0.5)
00624
00625 int CPL_DLL OGRParseDate( const char *pszInput, OGRField *psOutput,
00626 int nOptions );
00627
00628
00629
00630
00631 #define OLCRandomRead "RandomRead"
00632 #define OLCSequentialWrite "SequentialWrite"
00633 #define OLCRandomWrite "RandomWrite"
00634 #define OLCFastSpatialFilter "FastSpatialFilter"
00635 #define OLCFastFeatureCount "FastFeatureCount"
00636 #define OLCFastGetExtent "FastGetExtent"
00637 #define OLCCreateField "CreateField"
00638 #define OLCDeleteField "DeleteField"
00639 #define OLCReorderFields "ReorderFields"
00640 #define OLCAlterFieldDefn "AlterFieldDefn"
00641 #define OLCTransactions "Transactions"
00642 #define OLCDeleteFeature "DeleteFeature"
00643 #define OLCFastSetNextByIndex "FastSetNextByIndex"
00644 #define OLCStringsAsUTF8 "StringsAsUTF8"
00645 #define OLCIgnoreFields "IgnoreFields"
00646 #define OLCCreateGeomField "CreateGeomField"
00647 #define OLCCurveGeometries "CurveGeometries"
00648
00649 #define ODsCCreateLayer "CreateLayer"
00650 #define ODsCDeleteLayer "DeleteLayer"
00651 #define ODsCCreateGeomFieldAfterCreateLayer "CreateGeomFieldAfterCreateLayer"
00652 #define ODsCCurveGeometries "CurveGeometries"
00653 #define ODsCTransactions "Transactions"
00654 #define ODsCEmulatedTransactions "EmulatedTransactions"
00655
00656 #define ODrCCreateDataSource "CreateDataSource"
00657 #define ODrCDeleteDataSource "DeleteDataSource"
00658
00659
00660
00661
00666 #define OLMD_FID64 "OLMD_FID64"
00667
00668
00669
00670
00671
00676 typedef enum ogr_style_tool_class_id
00677 {
00678 OGRSTCNone = 0,
00679 OGRSTCPen = 1,
00680 OGRSTCBrush = 2,
00681 OGRSTCSymbol = 3,
00682 OGRSTCLabel = 4,
00683 OGRSTCVector = 5
00684 } OGRSTClassId;
00685
00689 typedef enum ogr_style_tool_units_id
00690 {
00691 OGRSTUGround = 0,
00692 OGRSTUPixel = 1,
00693 OGRSTUPoints = 2,
00694 OGRSTUMM = 3,
00695 OGRSTUCM = 4,
00696 OGRSTUInches = 5
00697 } OGRSTUnitId;
00698
00702 typedef enum ogr_style_tool_param_pen_id
00703 {
00704 OGRSTPenColor = 0,
00705 OGRSTPenWidth = 1,
00706 OGRSTPenPattern = 2,
00707 OGRSTPenId = 3,
00708 OGRSTPenPerOffset = 4,
00709 OGRSTPenCap = 5,
00710 OGRSTPenJoin = 6,
00711 OGRSTPenPriority = 7,
00712 OGRSTPenLast = 8
00713
00714 } OGRSTPenParam;
00715
00719 typedef enum ogr_style_tool_param_brush_id
00720 {
00721 OGRSTBrushFColor = 0,
00722 OGRSTBrushBColor = 1,
00723 OGRSTBrushId = 2,
00724 OGRSTBrushAngle = 3,
00725 OGRSTBrushSize = 4,
00726 OGRSTBrushDx = 5,
00727 OGRSTBrushDy = 6,
00728 OGRSTBrushPriority = 7,
00729 OGRSTBrushLast = 8
00730
00731 } OGRSTBrushParam;
00732
00733
00737 typedef enum ogr_style_tool_param_symbol_id
00738 {
00739 OGRSTSymbolId = 0,
00740 OGRSTSymbolAngle = 1,
00741 OGRSTSymbolColor = 2,
00742 OGRSTSymbolSize = 3,
00743 OGRSTSymbolDx = 4,
00744 OGRSTSymbolDy = 5,
00745 OGRSTSymbolStep = 6,
00746 OGRSTSymbolPerp = 7,
00747 OGRSTSymbolOffset = 8,
00748 OGRSTSymbolPriority = 9,
00749 OGRSTSymbolFontName = 10,
00750 OGRSTSymbolOColor = 11,
00751 OGRSTSymbolLast = 12
00752
00753 } OGRSTSymbolParam;
00754
00758 typedef enum ogr_style_tool_param_label_id
00759 {
00760 OGRSTLabelFontName = 0,
00761 OGRSTLabelSize = 1,
00762 OGRSTLabelTextString = 2,
00763 OGRSTLabelAngle = 3,
00764 OGRSTLabelFColor = 4,
00765 OGRSTLabelBColor = 5,
00766 OGRSTLabelPlacement = 6,
00767 OGRSTLabelAnchor = 7,
00768 OGRSTLabelDx = 8,
00769 OGRSTLabelDy = 9,
00770 OGRSTLabelPerp = 10,
00771 OGRSTLabelBold = 11,
00772 OGRSTLabelItalic = 12,
00773 OGRSTLabelUnderline = 13,
00774 OGRSTLabelPriority = 14,
00775 OGRSTLabelStrikeout = 15,
00776 OGRSTLabelStretch = 16,
00777 OGRSTLabelAdjHor = 17,
00778 OGRSTLabelAdjVert = 18,
00779 OGRSTLabelHColor = 19,
00780 OGRSTLabelOColor = 20,
00781 OGRSTLabelLast = 21
00782
00783 } OGRSTLabelParam;
00784
00785
00786
00787
00788
00789
00790
00791 #ifndef GDAL_VERSION_INFO_DEFINED
00792 #define GDAL_VERSION_INFO_DEFINED
00793 const char CPL_DLL * CPL_STDCALL GDALVersionInfo( const char * );
00794 #endif
00795
00796 #ifndef GDAL_CHECK_VERSION
00797
00809 int CPL_DLL CPL_STDCALL GDALCheckVersion( int nVersionMajor, int nVersionMinor,
00810 const char* pszCallingComponentName);
00811
00813 #define GDAL_CHECK_VERSION(pszCallingComponentName) \
00814 GDALCheckVersion(GDAL_VERSION_MAJOR, GDAL_VERSION_MINOR, pszCallingComponentName)
00815
00816 #endif
00817
00818 CPL_C_END
00819
00820 #endif