LTP GCOV extension - code coverage report
Current view: directory - ogr - ogr_core.h
Test: gdal_filtered.info
Date: 2010-07-12 Instrumented lines: 28
Code covered: 92.9 % Executed lines: 26

       1                 : /******************************************************************************
       2                 :  * $Id: ogr_core.h 17722 2009-10-01 16:40:26Z warmerdam $
       3                 :  *
       4                 :  * Project:  OpenGIS Simple Features Reference Implementation
       5                 :  * Purpose:  Define some core portability services for cross-platform OGR code.
       6                 :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 1999, Frank Warmerdam
      10                 :  *
      11                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      12                 :  * copy of this software and associated documentation files (the "Software"),
      13                 :  * to deal in the Software without restriction, including without limitation
      14                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      15                 :  * and/or sell copies of the Software, and to permit persons to whom the
      16                 :  * Software is furnished to do so, subject to the following conditions:
      17                 :  *
      18                 :  * The above copyright notice and this permission notice shall be included
      19                 :  * in all copies or substantial portions of the Software.
      20                 :  *
      21                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      22                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      23                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      24                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      25                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      26                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      27                 :  * DEALINGS IN THE SOFTWARE.
      28                 :  ****************************************************************************/
      29                 : 
      30                 : #ifndef OGR_CORE_H_INCLUDED
      31                 : #define OGR_CORE_H_INCLUDED
      32                 : 
      33                 : #include "cpl_port.h"
      34                 : #include "gdal_version.h"
      35                 : 
      36                 : /**
      37                 :  * \file
      38                 :  *
      39                 :  * Core portability services for cross-platform OGR code.
      40                 :  */
      41                 : 
      42                 : /**
      43                 :  * Simple container for a bounding region.
      44                 :  */
      45                 : 
      46                 : #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
      47                 : class CPL_DLL OGREnvelope
      48                 : {
      49                 :   public:
      50            6615 :         OGREnvelope()
      51                 :         {
      52            6615 :                 MinX = MaxX = MinY = MaxY = 0;
      53            6615 :         }
      54                 :     double      MinX;
      55                 :     double      MaxX;
      56                 :     double      MinY;
      57                 :     double      MaxY;
      58                 : 
      59             256 :     int  IsInit() const { return MinX != 0 || MinY != 0 || MaxX != 0 || MaxY != 0; }
      60               9 :     void Merge( OGREnvelope const& sOther ) {
      61               9 :         if( IsInit() )
      62                 :         {
      63               8 :             MinX = MIN(MinX,sOther.MinX);
      64               8 :             MaxX = MAX(MaxX,sOther.MaxX);
      65               8 :             MinY = MIN(MinY,sOther.MinY);
      66               8 :             MaxY = MAX(MaxY,sOther.MaxY);
      67                 :         }
      68                 :         else
      69                 :         {
      70               1 :             MinX = sOther.MinX;
      71               1 :             MaxX = sOther.MaxX;
      72               1 :             MinY = sOther.MinY;
      73               1 :             MaxY = sOther.MaxY;
      74                 :         }
      75               9 :     }
      76             245 :     void Merge( double dfX, double dfY ) {
      77             245 :         if( IsInit() )
      78                 :         {
      79             244 :             MinX = MIN(MinX,dfX);
      80             244 :             MaxX = MAX(MaxX,dfX);
      81             244 :             MinY = MIN(MinY,dfY);
      82             244 :             MaxY = MAX(MaxY,dfY);
      83                 :         }
      84                 :         else
      85                 :         {
      86               1 :             MinX = MaxX = dfX;
      87               1 :             MinY = MaxY = dfY;
      88                 :         }
      89             245 :     }
      90                 :     
      91                 :     void Intersect( OGREnvelope const& sOther ) {
      92                 :         if(Intersects(sOther))
      93                 :         {
      94                 :             if( IsInit() )
      95                 :             {
      96                 :                 MinX = MAX(MinX,sOther.MinX);
      97                 :                 MaxX = MIN(MaxX,sOther.MaxX);
      98                 :                 MinY = MAX(MinY,sOther.MinY);
      99                 :                 MaxY = MIN(MaxY,sOther.MaxY);
     100                 :             }
     101                 :             else
     102                 :             {
     103                 :                 MinX = sOther.MinX;
     104                 :                 MaxX = sOther.MaxX;
     105                 :                 MinY = sOther.MinY;
     106                 :                 MaxY = sOther.MaxY;
     107                 :             }
     108                 :         }
     109                 :         else
     110                 :         {
     111                 :             MinX = 0;
     112                 :             MaxX = 0;
     113                 :             MinY = 0;
     114                 :             MaxY = 0;
     115                 :         }
     116                 :     }
     117                 :  
     118               0 :     int Intersects(OGREnvelope const& other) const
     119                 :     {
     120                 :         return MinX <= other.MaxX && MaxX >= other.MinX && 
     121               0 :                MinY <= other.MaxY && MaxY >= other.MinY;
     122                 :     }
     123                 : 
     124             368 :     int Contains(OGREnvelope const& other) const
     125                 :     {
     126                 :         return MinX <= other.MinX && MinY <= other.MinY &&
     127             368 :                MaxX >= other.MaxX && MaxY >= other.MaxY;
     128                 :     }
     129                 : };
     130                 : #else
     131                 : typedef struct
     132                 : {
     133                 :     double      MinX;
     134                 :     double      MaxX;
     135                 :     double      MinY;
     136                 :     double      MaxY;
     137                 : } OGREnvelope;
     138                 : #endif
     139                 : 
     140                 : CPL_C_START
     141                 : 
     142                 : void CPL_DLL *OGRMalloc( size_t );
     143                 : void CPL_DLL *OGRCalloc( size_t, size_t );
     144                 : void CPL_DLL *OGRRealloc( void *, size_t );
     145                 : char CPL_DLL *OGRStrdup( const char * );
     146                 : void CPL_DLL OGRFree( void * );
     147                 : 
     148                 : typedef int OGRErr;
     149                 : 
     150                 : #define OGRERR_NONE                0
     151                 : #define OGRERR_NOT_ENOUGH_DATA     1    /* not enough data to deserialize */
     152                 : #define OGRERR_NOT_ENOUGH_MEMORY   2
     153                 : #define OGRERR_UNSUPPORTED_GEOMETRY_TYPE 3
     154                 : #define OGRERR_UNSUPPORTED_OPERATION 4
     155                 : #define OGRERR_CORRUPT_DATA        5
     156                 : #define OGRERR_FAILURE             6
     157                 : #define OGRERR_UNSUPPORTED_SRS     7
     158                 : #define OGRERR_INVALID_HANDLE      8
     159                 : 
     160                 : typedef int     OGRBoolean;
     161                 : 
     162                 : /* -------------------------------------------------------------------- */
     163                 : /*      ogr_geometry.h related definitions.                             */
     164                 : /* -------------------------------------------------------------------- */
     165                 : /**
     166                 :  * List of well known binary geometry types.  These are used within the BLOBs
     167                 :  * but are also returned from OGRGeometry::getGeometryType() to identify the
     168                 :  * type of a geometry object.
     169                 :  */
     170                 : 
     171                 : typedef enum 
     172                 : {
     173                 :     wkbUnknown = 0,         /**< unknown type, non-standard */
     174                 :     wkbPoint = 1,           /**< 0-dimensional geometric object, standard WKB */
     175                 :     wkbLineString = 2,      /**< 1-dimensional geometric object with linear
     176                 :                              *   interpolation between Points, standard WKB */
     177                 :     wkbPolygon = 3,         /**< planar 2-dimensional geometric object defined
     178                 :                              *   by 1 exterior boundary and 0 or more interior
     179                 :                              *   boundaries, standard WKB */
     180                 :     wkbMultiPoint = 4,      /**< GeometryCollection of Points, standard WKB */
     181                 :     wkbMultiLineString = 5, /**< GeometryCollection of LineStrings, standard WKB */
     182                 :     wkbMultiPolygon = 6,    /**< GeometryCollection of Polygons, standard WKB */
     183                 :     wkbGeometryCollection = 7, /**< geometric object that is a collection of 1
     184                 :                                     or more geometric objects, standard WKB */
     185                 :     wkbNone = 100,          /**< non-standard, for pure attribute records */
     186                 :     wkbLinearRing = 101,    /**< non-standard, just for createGeometry() */
     187                 :     wkbPoint25D = 0x80000001, /**< 2.5D extension as per 99-402 */
     188                 :     wkbLineString25D = 0x80000002, /**< 2.5D extension as per 99-402 */
     189                 :     wkbPolygon25D = 0x80000003, /**< 2.5D extension as per 99-402 */
     190                 :     wkbMultiPoint25D = 0x80000004, /**< 2.5D extension as per 99-402 */
     191                 :     wkbMultiLineString25D = 0x80000005, /**< 2.5D extension as per 99-402 */
     192                 :     wkbMultiPolygon25D = 0x80000006, /**< 2.5D extension as per 99-402 */
     193                 :     wkbGeometryCollection25D = 0x80000007 /**< 2.5D extension as per 99-402 */
     194                 : } OGRwkbGeometryType;
     195                 : 
     196                 : #define wkb25DBit 0x80000000
     197                 : #define wkbFlatten(x)  ((OGRwkbGeometryType) ((x) & (~wkb25DBit)))
     198                 : 
     199                 : #define ogrZMarker 0x21125711
     200                 : 
     201                 : const char CPL_DLL * OGRGeometryTypeToName( OGRwkbGeometryType eType );
     202                 : OGRwkbGeometryType CPL_DLL OGRMergeGeometryTypes( OGRwkbGeometryType eMain,
     203                 :                                                   OGRwkbGeometryType eExtra );
     204                 : 
     205                 : typedef enum 
     206                 : {
     207                 :     wkbXDR = 0,         /* MSB/Sun/Motoroloa: Most Significant Byte First   */
     208                 :     wkbNDR = 1          /* LSB/Intel/Vax: Least Significant Byte First      */
     209                 : } OGRwkbByteOrder;
     210                 : 
     211                 : #ifndef NO_HACK_FOR_IBM_DB2_V72
     212                 : #  define HACK_FOR_IBM_DB2_V72
     213                 : #endif
     214                 : 
     215                 : #ifdef HACK_FOR_IBM_DB2_V72
     216                 : #  define DB2_V72_FIX_BYTE_ORDER(x) ((((x) & 0x31) == (x)) ? (OGRwkbByteOrder) ((x) & 0x1) : (x))
     217                 : #  define DB2_V72_UNFIX_BYTE_ORDER(x) ((unsigned char) (OGRGeometry::bGenerate_DB2_V72_BYTE_ORDER ? ((x) | 0x30) : (x)))
     218                 : #else
     219                 : #  define DB2_V72_FIX_BYTE_ORDER(x) (x)
     220                 : #  define DB2_V72_UNFIX_BYTE_ORDER(x) (x)
     221                 : #endif
     222                 : 
     223                 : /************************************************************************/
     224                 : /*                  ogr_feature.h related definitions.                  */
     225                 : /************************************************************************/
     226                 : 
     227                 : /**
     228                 :  * List of feature field types.  This list is likely to be extended in the
     229                 :  * future ... avoid coding applications based on the assumption that all
     230                 :  * field types can be known.
     231                 :  */
     232                 : 
     233                 : typedef enum 
     234                 : {
     235                 :   /** Simple 32bit integer */                   OFTInteger = 0,
     236                 :   /** List of 32bit integers */                 OFTIntegerList = 1,
     237                 :   /** Double Precision floating point */        OFTReal = 2,
     238                 :   /** List of doubles */                        OFTRealList = 3,
     239                 :   /** String of ASCII chars */                  OFTString = 4,
     240                 :   /** Array of strings */                       OFTStringList = 5,
     241                 :   /** deprecated */                             OFTWideString = 6,
     242                 :   /** deprecated */                             OFTWideStringList = 7,
     243                 :   /** Raw Binary data */                        OFTBinary = 8,
     244                 :   /** Date */                                   OFTDate = 9,
     245                 :   /** Time */                                   OFTTime = 10,
     246                 :   /** Date and Time */                          OFTDateTime = 11,
     247                 :                                                 OFTMaxType = 11
     248                 : } OGRFieldType;
     249                 : 
     250                 : /**
     251                 :  * Display justification for field values.
     252                 :  */
     253                 : 
     254                 : typedef enum 
     255                 : {
     256                 :     OJUndefined = 0,
     257                 :     OJLeft = 1,
     258                 :     OJRight = 2
     259                 : } OGRJustification;
     260                 : 
     261                 : #define OGRNullFID            -1
     262                 : #define OGRUnsetMarker        -21121
     263                 : 
     264                 : /************************************************************************/
     265                 : /*                               OGRField                               */
     266                 : /************************************************************************/
     267                 : 
     268                 : /**
     269                 :  * OGRFeature field attribute value union.
     270                 :  */
     271                 : 
     272                 : typedef union {
     273                 :     int         Integer;
     274                 :     double      Real;
     275                 :     char       *String;
     276                 :     
     277                 :     struct {
     278                 :         int     nCount;
     279                 :         int     *paList;
     280                 :     } IntegerList;
     281                 :     
     282                 :     struct {
     283                 :         int     nCount;
     284                 :         double  *paList;
     285                 :     } RealList;
     286                 :     
     287                 :     struct {
     288                 :         int     nCount;
     289                 :         char    **paList;
     290                 :     } StringList;
     291                 : 
     292                 :     struct {
     293                 :         int     nCount;
     294                 :         GByte   *paData;
     295                 :     } Binary;
     296                 :     
     297                 :     struct {
     298                 :         int     nMarker1;
     299                 :         int     nMarker2;
     300                 :     } Set;
     301                 : 
     302                 :     struct {
     303                 :         GInt16  Year;
     304                 :         GByte   Month;
     305                 :         GByte   Day;
     306                 :         GByte   Hour;
     307                 :         GByte   Minute;
     308                 :         GByte   Second;
     309                 :         GByte   TZFlag; /* 0=unknown, 1=localtime(ambiguous), 
     310                 :                            100=GMT, 104=GMT+1, 80=GMT-5, etc */
     311                 :     } Date;
     312                 : } OGRField;
     313                 : 
     314                 : int CPL_DLL OGRParseDate( const char *pszInput, OGRField *psOutput, 
     315                 :                           int nOptions );
     316                 : 
     317                 : /* -------------------------------------------------------------------- */
     318                 : /*      Constants from ogrsf_frmts.h for capabilities.                  */
     319                 : /* -------------------------------------------------------------------- */
     320                 : #define OLCRandomRead          "RandomRead"
     321                 : #define OLCSequentialWrite     "SequentialWrite"
     322                 : #define OLCRandomWrite         "RandomWrite"
     323                 : #define OLCFastSpatialFilter   "FastSpatialFilter"
     324                 : #define OLCFastFeatureCount    "FastFeatureCount"
     325                 : #define OLCFastGetExtent       "FastGetExtent"
     326                 : #define OLCCreateField         "CreateField"
     327                 : #define OLCTransactions        "Transactions"
     328                 : #define OLCDeleteFeature       "DeleteFeature"
     329                 : #define OLCFastSetNextByIndex  "FastSetNextByIndex"
     330                 : #define OLCStringsAsUTF8       "StringsAsUTF8"
     331                 : 
     332                 : #define ODsCCreateLayer        "CreateLayer"
     333                 : #define ODsCDeleteLayer        "DeleteLayer"
     334                 : 
     335                 : #define ODrCCreateDataSource   "CreateDataSource"
     336                 : #define ODrCDeleteDataSource   "DeleteDataSource"
     337                 : 
     338                 : 
     339                 : /************************************************************************/
     340                 : /*                  ogr_featurestyle.h related definitions.             */
     341                 : /************************************************************************/
     342                 : 
     343                 : /**
     344                 :  * OGRStyleTool derived class types (returned by GetType()).
     345                 :  */
     346                 : 
     347                 : typedef enum ogr_style_tool_class_id
     348                 : {
     349                 :     OGRSTCNone   = 0,
     350                 :     OGRSTCPen    = 1,
     351                 :     OGRSTCBrush  = 2,
     352                 :     OGRSTCSymbol = 3,
     353                 :     OGRSTCLabel  = 4,
     354                 :     OGRSTCVector = 5
     355                 : } OGRSTClassId;
     356                 : 
     357                 : /**
     358                 :  * List of units supported by OGRStyleTools.
     359                 :  */
     360                 : typedef enum ogr_style_tool_units_id
     361                 : {
     362                 :     OGRSTUGround = 0,
     363                 :     OGRSTUPixel  = 1,
     364                 :     OGRSTUPoints = 2,
     365                 :     OGRSTUMM     = 3,
     366                 :     OGRSTUCM     = 4,
     367                 :     OGRSTUInches = 5
     368                 : } OGRSTUnitId;
     369                 : 
     370                 : /**
     371                 :  * List of parameters for use with OGRStylePen.
     372                 :  */
     373                 : typedef enum ogr_style_tool_param_pen_id
     374                 : {  
     375                 :     OGRSTPenColor       = 0,                   
     376                 :     OGRSTPenWidth       = 1,                   
     377                 :     OGRSTPenPattern     = 2,
     378                 :     OGRSTPenId          = 3,
     379                 :     OGRSTPenPerOffset   = 4,
     380                 :     OGRSTPenCap         = 5,
     381                 :     OGRSTPenJoin        = 6,
     382                 :     OGRSTPenPriority    = 7,
     383                 :     OGRSTPenLast        = 8
     384                 :               
     385                 : } OGRSTPenParam;
     386                 : 
     387                 : /**
     388                 :  * List of parameters for use with OGRStyleBrush.
     389                 :  */
     390                 : typedef enum ogr_style_tool_param_brush_id
     391                 : {  
     392                 :     OGRSTBrushFColor    = 0,                   
     393                 :     OGRSTBrushBColor    = 1,                   
     394                 :     OGRSTBrushId        = 2,
     395                 :     OGRSTBrushAngle     = 3,                   
     396                 :     OGRSTBrushSize      = 4,
     397                 :     OGRSTBrushDx        = 5,
     398                 :     OGRSTBrushDy        = 6,
     399                 :     OGRSTBrushPriority  = 7,
     400                 :     OGRSTBrushLast      = 8
     401                 :               
     402                 : } OGRSTBrushParam;
     403                 : 
     404                 : 
     405                 : /**
     406                 :  * List of parameters for use with OGRStyleSymbol.
     407                 :  */
     408                 : typedef enum ogr_style_tool_param_symbol_id
     409                 : {  
     410                 :     OGRSTSymbolId       = 0,
     411                 :     OGRSTSymbolAngle    = 1,
     412                 :     OGRSTSymbolColor    = 2,
     413                 :     OGRSTSymbolSize     = 3,
     414                 :     OGRSTSymbolDx       = 4,
     415                 :     OGRSTSymbolDy       = 5,
     416                 :     OGRSTSymbolStep     = 6,
     417                 :     OGRSTSymbolPerp     = 7,
     418                 :     OGRSTSymbolOffset   = 8,
     419                 :     OGRSTSymbolPriority = 9,
     420                 :     OGRSTSymbolFontName = 10,
     421                 :     OGRSTSymbolOColor   = 11,
     422                 :     OGRSTSymbolLast     = 12
     423                 :               
     424                 : } OGRSTSymbolParam;
     425                 : 
     426                 : /**
     427                 :  * List of parameters for use with OGRStyleLabel.
     428                 :  */
     429                 : typedef enum ogr_style_tool_param_label_id
     430                 : {  
     431                 :     OGRSTLabelFontName  = 0,
     432                 :     OGRSTLabelSize      = 1,
     433                 :     OGRSTLabelTextString = 2,
     434                 :     OGRSTLabelAngle     = 3,
     435                 :     OGRSTLabelFColor    = 4,
     436                 :     OGRSTLabelBColor    = 5,
     437                 :     OGRSTLabelPlacement = 6,
     438                 :     OGRSTLabelAnchor    = 7,
     439                 :     OGRSTLabelDx        = 8,
     440                 :     OGRSTLabelDy        = 9,
     441                 :     OGRSTLabelPerp      = 10,
     442                 :     OGRSTLabelBold      = 11,
     443                 :     OGRSTLabelItalic    = 12,
     444                 :     OGRSTLabelUnderline = 13,
     445                 :     OGRSTLabelPriority  = 14,
     446                 :     OGRSTLabelStrikeout = 15,
     447                 :     OGRSTLabelStretch   = 16,
     448                 :     OGRSTLabelAdjHor    = 17,
     449                 :     OGRSTLabelAdjVert   = 18,
     450                 :     OGRSTLabelHColor    = 19,
     451                 :     OGRSTLabelOColor    = 20,
     452                 :     OGRSTLabelLast      = 21
     453                 :               
     454                 : } OGRSTLabelParam;
     455                 : 
     456                 : /* ------------------------------------------------------------------- */
     457                 : /*                        Version checking                             */
     458                 : /* -------------------------------------------------------------------- */
     459                 : 
     460                 : /* Note to developers : please keep this section in sync with gdal.h */
     461                 : 
     462                 : #ifndef GDAL_VERSION_INFO_DEFINED
     463                 : #define GDAL_VERSION_INFO_DEFINED
     464                 : const char CPL_DLL * CPL_STDCALL GDALVersionInfo( const char * );
     465                 : #endif
     466                 : 
     467                 : #ifndef GDAL_CHECK_VERSION
     468                 : 
     469                 : /** Return TRUE if GDAL library version at runtime matches nVersionMajor.nVersionMinor.
     470                 : 
     471                 :     The purpose of this method is to ensure that calling code will run with the GDAL
     472                 :     version it is compiled for. It is primarly intented for external plugins.
     473                 : 
     474                 :     @param nVersionMajor Major version to be tested against
     475                 :     @param nVersionMinor Minor version to be tested against
     476                 :     @param pszCallingComponentName If not NULL, in case of version mismatch, the method
     477                 :                                    will issue a failure mentionning the name of
     478                 :                                    the calling component.
     479                 :   */
     480                 : int CPL_DLL CPL_STDCALL GDALCheckVersion( int nVersionMajor, int nVersionMinor,
     481                 :                                           const char* pszCallingComponentName);
     482                 : 
     483                 : /** Helper macro for GDALCheckVersion */
     484                 : #define GDAL_CHECK_VERSION(pszCallingComponentName) \
     485                 :  GDALCheckVersion(GDAL_VERSION_MAJOR, GDAL_VERSION_MINOR, pszCallingComponentName)
     486                 : 
     487                 : #endif
     488                 : 
     489                 : CPL_C_END
     490                 : 
     491                 : #endif /* ndef OGR_CORE_H_INCLUDED */

Generated by: LTP GCOV extension version 1.5