ogr_core.h

00001 /******************************************************************************
00002  * $Id: ogr_core.h,v 1.30 2006/04/02 18:25:59 fwarmerdam Exp $
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  * $Log: ogr_core.h,v $
00031  * Revision 1.30  2006/04/02 18:25:59  fwarmerdam
00032  * added OFTDateTime, and OFTTime support
00033  *
00034  * Revision 1.29  2006/02/15 04:25:37  fwarmerdam
00035  * added date support
00036  *
00037  * Revision 1.28  2005/08/30 23:52:35  fwarmerdam
00038  * implement preliminary OFTBinary support
00039  *
00040  * Revision 1.27  2005/07/29 15:54:07  fwarmerdam
00041  * ogrmakewktcoordinate defined in ogr_p.h
00042  *
00043  * Revision 1.26  2005/07/29 04:12:47  fwarmerdam
00044  * expose OGRMakeWktCoordinates
00045  *
00046  * Revision 1.25  2005/02/02 19:59:47  fwarmerdam
00047  * added SetNextByIndex support
00048  *
00049  * Revision 1.24  2003/10/09 15:27:41  warmerda
00050  * added OGRLayer::DeleteFeature() support
00051  *
00052  * Revision 1.23  2003/09/11 19:59:41  warmerda
00053  * avoid casting issue with UNFIX macro
00054  *
00055  * Revision 1.22  2003/08/27 15:40:37  warmerda
00056  * added support for generating DB2 V7.2 compatible WKB
00057  *
00058  * Revision 1.21  2003/08/11 03:28:04  warmerda
00059  * Export OGREnvelope C++ class with CPL_DLL as per bug 378.
00060  *
00061  * Revision 1.20  2003/06/09 13:48:54  warmerda
00062  * added DB2 V7.2 byte order hack
00063  *
00064  * Revision 1.19  2003/05/08 13:27:22  warmerda
00065  * dont use C++ comments in this c includable file
00066  *
00067  * Revision 1.18  2003/04/29 19:03:58  warmerda
00068  * removed extra comma
00069  *
00070  * Revision 1.17  2003/03/03 05:05:54  warmerda
00071  * added support for DeleteDataSource and DeleteLayer
00072  *
00073  * Revision 1.16  2003/02/19 02:57:49  warmerda
00074  * added wkbLinearRing support
00075  *
00076  * Revision 1.15  2003/01/14 20:08:49  warmerda
00077  * fixed another bug in OGREnvelope.Merge
00078  *
00079  * Revision 1.14  2003/01/07 17:51:55  warmerda
00080  * fixed OGREnvelope.Merge()
00081  *
00082  * Revision 1.13  2003/01/06 17:56:03  warmerda
00083  * Added Merge and IsInit() method on OGREnvelope
00084  *
00085  * Revision 1.12  2002/11/08 18:25:45  warmerda
00086  * remove extranious comma in enum, confuses HPUX compiler
00087  *
00088  * Revision 1.11  2002/11/08 15:42:41  warmerda
00089  * ensure type correctness of wkbFlatten
00090  *
00091  * Revision 1.10  2002/10/24 20:53:02  warmerda
00092  * expand tabs
00093  *
00094  * Revision 1.9  2002/09/26 18:13:17  warmerda
00095  * moved some defs to ogr_core.h for sharing with ogr_api.h
00096  *
00097  * Revision 1.8  2000/07/11 20:15:12  warmerda
00098  * apply CPL_DLL to OGR functions
00099  *
00100  * Revision 1.7  2000/07/09 20:47:35  warmerda
00101  * added CPL_START/END
00102  *
00103  * Revision 1.6  1999/11/18 19:02:19  warmerda
00104  * expanded tabs
00105  *
00106  * Revision 1.5  1999/07/07 04:23:07  danmo
00107  * Fixed typo in  #define _OGR_..._H_INCLUDED  line
00108  *
00109  * Revision 1.4  1999/07/05 18:56:52  warmerda
00110  * now includes cpl_port.h
00111  *
00112  * Revision 1.3  1999/07/05 17:19:03  warmerda
00113  * added OGRERR_UNSUPPORTED_SRS
00114  *
00115  * Revision 1.2  1999/05/31 15:00:37  warmerda
00116  * added generic OGRERR_FAILURE error code.
00117  *
00118  * Revision 1.1  1999/05/20 14:35:00  warmerda
00119  * New
00120  *
00121  */
00122 
00123 #ifndef _OGR_CORE_H_INCLUDED
00124 #define _OGR_CORE_H_INCLUDED
00125 
00126 #include "cpl_port.h"
00127 
00132 #ifdef __cplusplus
00133 class CPL_DLL OGREnvelope
00134 {
00135   public:
00136         OGREnvelope()
00137         {
00138                 MinX = MaxX = MinY = MaxY = 0;
00139         }
00140     double      MinX;
00141     double      MaxX;
00142     double      MinY;
00143     double      MaxY;
00144 
00145     int  IsInit() { return MinX != 0 || MinY != 0 || MaxX != 0 || MaxY != 0; }
00146     void Merge( OGREnvelope & sOther ) {
00147         if( IsInit() )
00148         {
00149             MinX = MIN(MinX,sOther.MinX);
00150             MaxX = MAX(MaxX,sOther.MaxX);
00151             MinY = MIN(MinY,sOther.MinY);
00152             MaxY = MAX(MaxY,sOther.MaxY);
00153         }
00154         else
00155         {
00156             MinX = sOther.MinX;
00157             MaxX = sOther.MaxX;
00158             MinY = sOther.MinY;
00159             MaxY = sOther.MaxY;
00160         }
00161     }
00162 };
00163 #else
00164 typedef struct
00165 {
00166     double      MinX;
00167     double      MaxX;
00168     double      MinY;
00169     double      MaxY;
00170 } OGREnvelope;
00171 #endif
00172 
00173 CPL_C_START
00174 
00175 void CPL_DLL *OGRMalloc( size_t );
00176 void CPL_DLL *OGRCalloc( size_t, size_t );
00177 void CPL_DLL *OGRRealloc( void *, size_t );
00178 char CPL_DLL *OGRStrdup( const char * );
00179 void CPL_DLL OGRFree( void * );
00180 
00181 typedef int OGRErr;
00182 
00183 #define OGRERR_NONE                0
00184 #define OGRERR_NOT_ENOUGH_DATA     1    /* not enough data to deserialize */
00185 #define OGRERR_NOT_ENOUGH_MEMORY   2
00186 #define OGRERR_UNSUPPORTED_GEOMETRY_TYPE 3
00187 #define OGRERR_UNSUPPORTED_OPERATION 4
00188 #define OGRERR_CORRUPT_DATA        5
00189 #define OGRERR_FAILURE             6
00190 #define OGRERR_UNSUPPORTED_SRS     7
00191 
00192 typedef int     OGRBoolean;
00193 
00194 /* -------------------------------------------------------------------- */
00195 /*      ogr_geometry.h related definitions.                             */
00196 /* -------------------------------------------------------------------- */
00203 typedef enum 
00204 {
00205     wkbUnknown = 0,             /* non-standard */
00206     wkbPoint = 1,               /* rest are standard WKB type codes */
00207     wkbLineString = 2,
00208     wkbPolygon = 3,
00209     wkbMultiPoint = 4,
00210     wkbMultiLineString = 5,
00211     wkbMultiPolygon = 6,
00212     wkbGeometryCollection = 7,
00213     wkbNone = 100,              /* non-standard, for pure attribute records */
00214     wkbLinearRing = 101,        /* non-standard, just for createGeometry() */
00215     wkbPoint25D = 0x80000001,   /* 2.5D extensions as per 99-402 */
00216     wkbLineString25D = 0x80000002,
00217     wkbPolygon25D = 0x80000003,
00218     wkbMultiPoint25D = 0x80000004,
00219     wkbMultiLineString25D = 0x80000005,
00220     wkbMultiPolygon25D = 0x80000006,
00221     wkbGeometryCollection25D = 0x80000007
00222 } OGRwkbGeometryType;
00223 
00224 #define wkb25DBit 0x80000000
00225 #define wkbFlatten(x)  ((OGRwkbGeometryType) ((x) & (~wkb25DBit)))
00226 
00227 #define ogrZMarker 0x21125711
00228 
00229 const char CPL_DLL * OGRGeometryTypeToName( OGRwkbGeometryType eType );
00230 
00231 typedef enum 
00232 {
00233     wkbXDR = 0,         /* MSB/Sun/Motoroloa: Most Significant Byte First   */
00234     wkbNDR = 1          /* LSB/Intel/Vax: Least Significant Byte First      */
00235 } OGRwkbByteOrder;
00236 
00237 #ifndef NO_HACK_FOR_IBM_DB2_V72
00238 #  define HACK_FOR_IBM_DB2_V72
00239 #endif
00240 
00241 #ifdef HACK_FOR_IBM_DB2_V72
00242 #  define DB2_V72_FIX_BYTE_ORDER(x) ((((x) & 0x31) == (x)) ? (OGRwkbByteOrder) ((x) & 0x1) : (x))
00243 #  define DB2_V72_UNFIX_BYTE_ORDER(x) ((unsigned char) (OGRGeometry::bGenerate_DB2_V72_BYTE_ORDER ? ((x) | 0x30) : (x)))
00244 #else
00245 #  define DB2_V72_FIX_BYTE_ORDER(x) (x)
00246 #  define DB2_V72_UNFIX_BYTE_ORDER(x) (x)
00247 #endif
00248 
00249 /************************************************************************/
00250 /*                  ogr_feature.h related definitions.                  */
00251 /************************************************************************/
00252 
00259 typedef enum 
00260 {                   OFTInteger = 0,                 OFTIntegerList = 1,        OFTReal = 2,                        OFTRealList = 3,                  OFTString = 4,                       OFTStringList = 5,       OFTWideString = 6,     OFTWideStringList = 7,                        OFTBinary = 8,                                   OFTDate = 9,                                   OFTTime = 10,                          OFTDateTime = 11
00273 } OGRFieldType;
00274 
00279 typedef enum 
00280 {
00281     OJUndefined = 0,
00282     OJLeft = 1,
00283     OJRight = 2
00284 } OGRJustification;
00285 
00286 #define OGRNullFID            -1
00287 #define OGRUnsetMarker        -21121
00288 
00289 /************************************************************************/
00290 /*                               OGRField                               */
00291 /************************************************************************/
00292 
00297 typedef union {
00298     int         Integer;
00299     double      Real;
00300     char       *String;
00301     /* wchar    *WideString; */
00302     
00303     struct {
00304         int     nCount;
00305         int     *paList;
00306     } IntegerList;
00307     
00308     struct {
00309         int     nCount;
00310         double  *paList;
00311     } RealList;
00312     
00313     struct {
00314         int     nCount;
00315         char    **paList;
00316     } StringList;
00317 
00318     /*
00319     union {
00320         int   nCount;
00321         wchar *paList;
00322     } WideStringList;
00323     */
00324 
00325     struct {
00326         int     nCount;
00327         GByte   *paData;
00328     } Binary;
00329     
00330     struct {
00331         int     nMarker1;
00332         int     nMarker2;
00333     } Set;
00334 
00335     struct {
00336         GInt16  Year;
00337         GByte   Month;
00338         GByte   Day;
00339         GByte   Hour;
00340         GByte   Minute;
00341         GByte   Second;
00342         GByte   TZFlag; /* 0=unknown, 1=localtime(ambiguous), 
00343                            100=GMT, 104=GMT+1, 80=GMT-5, etc */
00344     } Date;
00345 } OGRField;
00346 
00347 int CPL_DLL OGRParseDate( const char *pszInput, OGRField *psOutput, 
00348                           int nOptions );
00349 
00350 /* -------------------------------------------------------------------- */
00351 /*      Constants from ogrsf_frmts.h for capabilities.                  */
00352 /* -------------------------------------------------------------------- */
00353 #define OLCRandomRead          "RandomRead"
00354 #define OLCSequentialWrite     "SequentialWrite"
00355 #define OLCRandomWrite         "RandomWrite"
00356 #define OLCFastSpatialFilter   "FastSpatialFilter"
00357 #define OLCFastFeatureCount    "FastFeatureCount"
00358 #define OLCFastGetExtent       "FastGetExtent"
00359 #define OLCCreateField         "CreateField"
00360 #define OLCTransactions        "Transactions"
00361 #define OLCDeleteFeature       "DeleteFeature"
00362 #define OLCFastSetNextByIndex  "FastSetNextByIndex"
00363 
00364 #define ODsCCreateLayer        "CreateLayer"
00365 #define ODsCDeleteLayer        "DeleteLayer"
00366 
00367 #define ODrCCreateDataSource   "CreateDataSource"
00368 #define ODrCDeleteDataSource   "DeleteDataSource"
00369 
00370 CPL_C_END
00371 
00372 #endif /* ndef _OGR_CORE_H_INCLUDED */
00373 

Generated for GDAL by doxygen 1.5.1.