ogr_core.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  * $Id: ogr_core.h 13339 2007-12-14 18:10:05Z 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     int Intersects(OGREnvelope const& other) const
00092     {
00093         return MinX <= other.MaxX && MaxX >= other.MinX && 
00094                MinY <= other.MaxY && MaxY >= other.MinY;
00095     }
00096 
00097     int Contains(OGREnvelope const& other) const
00098     {
00099         return MinX <= other.MinX && MinY <= other.MinY &&
00100                MaxX >= other.MaxX && MaxY >= other.MaxY;
00101     }
00102 };
00103 #else
00104 typedef struct
00105 {
00106     double      MinX;
00107     double      MaxX;
00108     double      MinY;
00109     double      MaxY;
00110 } OGREnvelope;
00111 #endif
00112 
00113 CPL_C_START
00114 
00115 void CPL_DLL *OGRMalloc( size_t );
00116 void CPL_DLL *OGRCalloc( size_t, size_t );
00117 void CPL_DLL *OGRRealloc( void *, size_t );
00118 char CPL_DLL *OGRStrdup( const char * );
00119 void CPL_DLL OGRFree( void * );
00120 
00121 typedef int OGRErr;
00122 
00123 #define OGRERR_NONE                0
00124 #define OGRERR_NOT_ENOUGH_DATA     1    /* not enough data to deserialize */
00125 #define OGRERR_NOT_ENOUGH_MEMORY   2
00126 #define OGRERR_UNSUPPORTED_GEOMETRY_TYPE 3
00127 #define OGRERR_UNSUPPORTED_OPERATION 4
00128 #define OGRERR_CORRUPT_DATA        5
00129 #define OGRERR_FAILURE             6
00130 #define OGRERR_UNSUPPORTED_SRS     7
00131 #define OGRERR_INVALID_HANDLE      8
00132 
00133 typedef int     OGRBoolean;
00134 
00135 /* -------------------------------------------------------------------- */
00136 /*      ogr_geometry.h related definitions.                             */
00137 /* -------------------------------------------------------------------- */
00144 typedef enum 
00145 {
00146     wkbUnknown = 0,         
00147     wkbPoint = 1,           
00148     wkbLineString = 2,      
00150     wkbPolygon = 3,         
00153     wkbMultiPoint = 4,      
00154     wkbMultiLineString = 5, 
00155     wkbMultiPolygon = 6,    
00156     wkbGeometryCollection = 7, 
00158     wkbNone = 100,          
00159     wkbLinearRing = 101,    
00160     wkbPoint25D = 0x80000001, 
00161     wkbLineString25D = 0x80000002, 
00162     wkbPolygon25D = 0x80000003, 
00163     wkbMultiPoint25D = 0x80000004, 
00164     wkbMultiLineString25D = 0x80000005, 
00165     wkbMultiPolygon25D = 0x80000006, 
00166     wkbGeometryCollection25D = 0x80000007 
00167 } OGRwkbGeometryType;
00168 
00169 #define wkb25DBit 0x80000000
00170 #define wkbFlatten(x)  ((OGRwkbGeometryType) ((x) & (~wkb25DBit)))
00171 
00172 #define ogrZMarker 0x21125711
00173 
00174 const char CPL_DLL * OGRGeometryTypeToName( OGRwkbGeometryType eType );
00175 
00176 typedef enum 
00177 {
00178     wkbXDR = 0,         /* MSB/Sun/Motoroloa: Most Significant Byte First   */
00179     wkbNDR = 1          /* LSB/Intel/Vax: Least Significant Byte First      */
00180 } OGRwkbByteOrder;
00181 
00182 #ifndef NO_HACK_FOR_IBM_DB2_V72
00183 #  define HACK_FOR_IBM_DB2_V72
00184 #endif
00185 
00186 #ifdef HACK_FOR_IBM_DB2_V72
00187 #  define DB2_V72_FIX_BYTE_ORDER(x) ((((x) & 0x31) == (x)) ? (OGRwkbByteOrder) ((x) & 0x1) : (x))
00188 #  define DB2_V72_UNFIX_BYTE_ORDER(x) ((unsigned char) (OGRGeometry::bGenerate_DB2_V72_BYTE_ORDER ? ((x) | 0x30) : (x)))
00189 #else
00190 #  define DB2_V72_FIX_BYTE_ORDER(x) (x)
00191 #  define DB2_V72_UNFIX_BYTE_ORDER(x) (x)
00192 #endif
00193 
00194 /************************************************************************/
00195 /*                  ogr_feature.h related definitions.                  */
00196 /************************************************************************/
00197 
00204 typedef enum 
00205 {                   OFTInteger = 0,                 OFTIntegerList = 1,        OFTReal = 2,                        OFTRealList = 3,                  OFTString = 4,                       OFTStringList = 5,       OFTWideString = 6,     OFTWideStringList = 7,                        OFTBinary = 8,                                   OFTDate = 9,                                   OFTTime = 10,                          OFTDateTime = 11
00218 } OGRFieldType;
00219 
00224 typedef enum 
00225 {
00226     OJUndefined = 0,
00227     OJLeft = 1,
00228     OJRight = 2
00229 } OGRJustification;
00230 
00231 #define OGRNullFID            -1
00232 #define OGRUnsetMarker        -21121
00233 
00234 /************************************************************************/
00235 /*                               OGRField                               */
00236 /************************************************************************/
00237 
00242 typedef union {
00243     int         Integer;
00244     double      Real;
00245     char       *String;
00246     /* wchar    *WideString; */
00247     
00248     struct {
00249         int     nCount;
00250         int     *paList;
00251     } IntegerList;
00252     
00253     struct {
00254         int     nCount;
00255         double  *paList;
00256     } RealList;
00257     
00258     struct {
00259         int     nCount;
00260         char    **paList;
00261     } StringList;
00262 
00263     /*
00264     union {
00265         int   nCount;
00266         wchar *paList;
00267     } WideStringList;
00268     */
00269 
00270     struct {
00271         int     nCount;
00272         GByte   *paData;
00273     } Binary;
00274     
00275     struct {
00276         int     nMarker1;
00277         int     nMarker2;
00278     } Set;
00279 
00280     struct {
00281         GInt16  Year;
00282         GByte   Month;
00283         GByte   Day;
00284         GByte   Hour;
00285         GByte   Minute;
00286         GByte   Second;
00287         GByte   TZFlag; /* 0=unknown, 1=localtime(ambiguous), 
00288                            100=GMT, 104=GMT+1, 80=GMT-5, etc */
00289     } Date;
00290 } OGRField;
00291 
00292 int CPL_DLL OGRParseDate( const char *pszInput, OGRField *psOutput, 
00293                           int nOptions );
00294 
00295 /* -------------------------------------------------------------------- */
00296 /*      Constants from ogrsf_frmts.h for capabilities.                  */
00297 /* -------------------------------------------------------------------- */
00298 #define OLCRandomRead          "RandomRead"
00299 #define OLCSequentialWrite     "SequentialWrite"
00300 #define OLCRandomWrite         "RandomWrite"
00301 #define OLCFastSpatialFilter   "FastSpatialFilter"
00302 #define OLCFastFeatureCount    "FastFeatureCount"
00303 #define OLCFastGetExtent       "FastGetExtent"
00304 #define OLCCreateField         "CreateField"
00305 #define OLCTransactions        "Transactions"
00306 #define OLCDeleteFeature       "DeleteFeature"
00307 #define OLCFastSetNextByIndex  "FastSetNextByIndex"
00308 
00309 #define ODsCCreateLayer        "CreateLayer"
00310 #define ODsCDeleteLayer        "DeleteLayer"
00311 
00312 #define ODrCCreateDataSource   "CreateDataSource"
00313 #define ODrCDeleteDataSource   "DeleteDataSource"
00314 
00315 
00316 /************************************************************************/
00317 /*                  ogr_featurestyle.h related definitions.             */
00318 /************************************************************************/
00319 
00324 typedef enum ogr_style_tool_class_id
00325 {
00326     OGRSTCNone   = 0,
00327     OGRSTCPen    = 1,
00328     OGRSTCBrush  = 2,
00329     OGRSTCSymbol = 3,
00330     OGRSTCLabel  = 4,
00331     OGRSTCVector = 5
00332 } OGRSTClassId;
00333 
00337 typedef enum ogr_style_tool_units_id
00338 {
00339     OGRSTUGround = 0,
00340     OGRSTUPixel  = 1,
00341     OGRSTUPoints = 2,
00342     OGRSTUMM     = 3,
00343     OGRSTUCM     = 4,
00344     OGRSTUInches = 5
00345 } OGRSTUnitId;
00346 
00350 typedef enum ogr_style_tool_param_pen_id
00351 {  
00352     OGRSTPenColor       = 0,                   
00353     OGRSTPenWidth       = 1,                   
00354     OGRSTPenPattern     = 2,
00355     OGRSTPenId          = 3,
00356     OGRSTPenPerOffset   = 4,
00357     OGRSTPenCap         = 5,
00358     OGRSTPenJoin        = 6,
00359     OGRSTPenPriority    = 7,
00360     OGRSTPenLast        = 8
00361               
00362 } OGRSTPenParam;
00363 
00367 typedef enum ogr_style_tool_param_brush_id
00368 {  
00369     OGRSTBrushFColor    = 0,                   
00370     OGRSTBrushBColor    = 1,                   
00371     OGRSTBrushId        = 2,
00372     OGRSTBrushAngle     = 3,                   
00373     OGRSTBrushSize      = 4,
00374     OGRSTBrushDx        = 5,
00375     OGRSTBrushDy        = 6,
00376     OGRSTBrushPriority  = 7,
00377     OGRSTBrushLast      = 8
00378               
00379 } OGRSTBrushParam;
00380 
00381 
00385 typedef enum ogr_style_tool_param_symbol_id
00386 {  
00387     OGRSTSymbolId       = 0,
00388     OGRSTSymbolAngle    = 1,
00389     OGRSTSymbolColor    = 2,
00390     OGRSTSymbolSize     = 3,
00391     OGRSTSymbolDx       = 4,
00392     OGRSTSymbolDy       = 5,
00393     OGRSTSymbolStep     = 6,
00394     OGRSTSymbolPerp     = 7,
00395     OGRSTSymbolOffset   = 8,
00396     OGRSTSymbolPriority = 9,
00397     OGRSTSymbolFontName = 10,
00398     OGRSTSymbolLast     = 11
00399               
00400 } OGRSTSymbolParam;
00401 
00405 typedef enum ogr_style_tool_param_label_id
00406 {  
00407     OGRSTLabelFontName  = 0,
00408     OGRSTLabelSize      = 1,
00409     OGRSTLabelTextString = 2,
00410     OGRSTLabelAngle     = 3,
00411     OGRSTLabelFColor    = 4,
00412     OGRSTLabelBColor    = 5,
00413     OGRSTLabelPlacement = 6,
00414     OGRSTLabelAnchor    = 7,
00415     OGRSTLabelDx        = 8,
00416     OGRSTLabelDy        = 9,
00417     OGRSTLabelPerp      = 10,
00418     OGRSTLabelBold      = 11,
00419     OGRSTLabelItalic    = 12,
00420     OGRSTLabelUnderline = 13,
00421     OGRSTLabelPriority  = 14,
00422     OGRSTLabelStrikeout = 15,
00423     OGRSTLabelStretch   = 16,
00424     OGRSTLabelAdjHor    = 17,
00425     OGRSTLabelAdjVert   = 18,
00426     OGRSTLabelHColor    = 19,
00427     OGRSTLabelLast      = 20
00428               
00429 } OGRSTLabelParam;
00430 
00431 /* ------------------------------------------------------------------- */
00432 /*                        Version checking                             */
00433 /* -------------------------------------------------------------------- */
00434 
00435 #ifndef GDAL_CHECK_VERSION
00436 
00448 int CPL_DLL CPL_STDCALL GDALCheckVersion( int nVersionMajor, int nVersionMinor,
00449                                           const char* pszCallingComponentName);
00450 
00452 #define GDAL_CHECK_VERSION(pszCallingComponentName) \
00453  GDALCheckVersion(GDAL_VERSION_MAJOR, GDAL_VERSION_MINOR, pszCallingComponentName)
00454 
00455 #endif
00456 
00457 CPL_C_END
00458 
00459 #endif /* ndef OGR_CORE_H_INCLUDED */

Generated for GDAL by doxygen 1.5.1.