ogr_core.h

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

Generated on Mon Jan 9 18:03:31 2006 for OGR by  doxygen 1.4.6