OGR
ogr_core.h
Go to the documentation of this file.
00001 /******************************************************************************
00002  * $Id: ogr_core.h 17722 2009-10-01 16:40:26Z 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 
00332 #define ODsCCreateLayer        "CreateLayer"
00333 #define ODsCDeleteLayer        "DeleteLayer"
00334 
00335 #define ODrCCreateDataSource   "CreateDataSource"
00336 #define ODrCDeleteDataSource   "DeleteDataSource"
00337 
00338 
00339 /************************************************************************/
00340 /*                  ogr_featurestyle.h related definitions.             */
00341 /************************************************************************/
00342 
00347 typedef enum ogr_style_tool_class_id
00348 {
00349     OGRSTCNone   = 0,
00350     OGRSTCPen    = 1,
00351     OGRSTCBrush  = 2,
00352     OGRSTCSymbol = 3,
00353     OGRSTCLabel  = 4,
00354     OGRSTCVector = 5
00355 } OGRSTClassId;
00356 
00360 typedef enum ogr_style_tool_units_id
00361 {
00362     OGRSTUGround = 0,
00363     OGRSTUPixel  = 1,
00364     OGRSTUPoints = 2,
00365     OGRSTUMM     = 3,
00366     OGRSTUCM     = 4,
00367     OGRSTUInches = 5
00368 } OGRSTUnitId;
00369 
00373 typedef enum ogr_style_tool_param_pen_id
00374 {  
00375     OGRSTPenColor       = 0,                   
00376     OGRSTPenWidth       = 1,                   
00377     OGRSTPenPattern     = 2,
00378     OGRSTPenId          = 3,
00379     OGRSTPenPerOffset   = 4,
00380     OGRSTPenCap         = 5,
00381     OGRSTPenJoin        = 6,
00382     OGRSTPenPriority    = 7,
00383     OGRSTPenLast        = 8
00384               
00385 } OGRSTPenParam;
00386 
00390 typedef enum ogr_style_tool_param_brush_id
00391 {  
00392     OGRSTBrushFColor    = 0,                   
00393     OGRSTBrushBColor    = 1,                   
00394     OGRSTBrushId        = 2,
00395     OGRSTBrushAngle     = 3,                   
00396     OGRSTBrushSize      = 4,
00397     OGRSTBrushDx        = 5,
00398     OGRSTBrushDy        = 6,
00399     OGRSTBrushPriority  = 7,
00400     OGRSTBrushLast      = 8
00401               
00402 } OGRSTBrushParam;
00403 
00404 
00408 typedef enum ogr_style_tool_param_symbol_id
00409 {  
00410     OGRSTSymbolId       = 0,
00411     OGRSTSymbolAngle    = 1,
00412     OGRSTSymbolColor    = 2,
00413     OGRSTSymbolSize     = 3,
00414     OGRSTSymbolDx       = 4,
00415     OGRSTSymbolDy       = 5,
00416     OGRSTSymbolStep     = 6,
00417     OGRSTSymbolPerp     = 7,
00418     OGRSTSymbolOffset   = 8,
00419     OGRSTSymbolPriority = 9,
00420     OGRSTSymbolFontName = 10,
00421     OGRSTSymbolOColor   = 11,
00422     OGRSTSymbolLast     = 12
00423               
00424 } OGRSTSymbolParam;
00425 
00429 typedef enum ogr_style_tool_param_label_id
00430 {  
00431     OGRSTLabelFontName  = 0,
00432     OGRSTLabelSize      = 1,
00433     OGRSTLabelTextString = 2,
00434     OGRSTLabelAngle     = 3,
00435     OGRSTLabelFColor    = 4,
00436     OGRSTLabelBColor    = 5,
00437     OGRSTLabelPlacement = 6,
00438     OGRSTLabelAnchor    = 7,
00439     OGRSTLabelDx        = 8,
00440     OGRSTLabelDy        = 9,
00441     OGRSTLabelPerp      = 10,
00442     OGRSTLabelBold      = 11,
00443     OGRSTLabelItalic    = 12,
00444     OGRSTLabelUnderline = 13,
00445     OGRSTLabelPriority  = 14,
00446     OGRSTLabelStrikeout = 15,
00447     OGRSTLabelStretch   = 16,
00448     OGRSTLabelAdjHor    = 17,
00449     OGRSTLabelAdjVert   = 18,
00450     OGRSTLabelHColor    = 19,
00451     OGRSTLabelOColor    = 20,
00452     OGRSTLabelLast      = 21
00453               
00454 } OGRSTLabelParam;
00455 
00456 /* ------------------------------------------------------------------- */
00457 /*                        Version checking                             */
00458 /* -------------------------------------------------------------------- */
00459 
00460 /* Note to developers : please keep this section in sync with gdal.h */
00461 
00462 #ifndef GDAL_VERSION_INFO_DEFINED
00463 #define GDAL_VERSION_INFO_DEFINED
00464 const char CPL_DLL * CPL_STDCALL GDALVersionInfo( const char * );
00465 #endif
00466 
00467 #ifndef GDAL_CHECK_VERSION
00468 
00480 int CPL_DLL CPL_STDCALL GDALCheckVersion( int nVersionMajor, int nVersionMinor,
00481                                           const char* pszCallingComponentName);
00482 
00484 #define GDAL_CHECK_VERSION(pszCallingComponentName) \
00485  GDALCheckVersion(GDAL_VERSION_MAJOR, GDAL_VERSION_MINOR, pszCallingComponentName)
00486 
00487 #endif
00488 
00489 CPL_C_END
00490 
00491 #endif /* ndef OGR_CORE_H_INCLUDED */

Generated for GDAL by doxygen 1.7.4.