ogr_core.h

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

Generated on Sun Jul 2 22:18:21 2006 for OGR by  doxygen 1.4.6