Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

ogr_core.h

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

Generated on Mon Aug 29 04:05:42 2005 for OGR by doxygen 1.3.6