- Main Page
- Classes
- Files
- Directories
- Related Pages

- File List
- File Members

# ogr_feature.h

Go to the documentation of this file.

    00001 /******************************************************************************
    00002  * $Id: ogr_feature.h 10645 2007-01-18 02:22:39Z warmerdam $
    00003  *
    00004  * Project:  OpenGIS Simple Features Reference Implementation
    00005  * Purpose:  Class for representing a whole feature, and layer schemas.
    00006  * Author:   Frank Warmerdam, warmerdam@pobox.com
    00007  *
    00008  ******************************************************************************
    00009  * Copyright (c) 1999,  Les Technologies SoftMap Inc.
    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 #ifndef _OGR_FEATURE_H_INCLUDED
    00031 #define _OGR_FEATURE_H_INCLUDED
    00032
    00033 #include "ogr_geometry.h"
    00034 #include "ogr_featurestyle.h"
    00035
    00042 /************************************************************************/
    00043 /*                             OGRFieldDefn                             */
    00044 /************************************************************************/
    00045
    00050 class CPL_DLL OGRFieldDefn
    00051 {
    00052   private:
    00053     char                *pszName;
    00054     OGRFieldType        eType;
    00055     OGRJustification    eJustify;
    00056     int                 nWidth;                 /* zero is variable */
    00057     int                 nPrecision;
    00058     OGRField            uDefault;
    00059
    00060     void                Initialize( const char *, OGRFieldType );
    00061
    00062   public:
    00063                         OGRFieldDefn( const char *, OGRFieldType );
    00064                         OGRFieldDefn( OGRFieldDefn * );
    00065                         ~OGRFieldDefn();
    00066
    00067     void                SetName( const char * );
    00068     const char         *GetNameRef() { return pszName; }
    00069
    00070     OGRFieldType        GetType() { return eType; }
    00071     void                SetType( OGRFieldType eTypeIn ) { eType = eTypeIn;}
    00072     static const char  *GetFieldTypeName( OGRFieldType );
    00073
    00074     OGRJustification    GetJustify() { return eJustify; }
    00075     void                SetJustify( OGRJustification eJustifyIn )
    00076                                                 { eJustify = eJustifyIn; }
    00077
    00078     int                 GetWidth() { return nWidth; }
    00079     void                SetWidth( int nWidthIn ) { nWidth = MAX(0,nWidthIn); }
    00080
    00081     int                 GetPrecision() { return nPrecision; }
    00082     void                SetPrecision( int nPrecisionIn )
    00083                                                 { nPrecision = nPrecisionIn; }
    00084
    00085     void                Set( const char *, OGRFieldType, int = 0, int = 0,
    00086                              OGRJustification = OJUndefined );
    00087
    00088     void                SetDefault( const OGRField * );
    00089     const OGRField     *GetDefaultRef() { return &uDefault; }
    00090 };
    00091
    00092 /************************************************************************/
    00093 /*                            OGRFeatureDefn                            */
    00094 /************************************************************************/
    00095
    00112 class CPL_DLL OGRFeatureDefn
    00113 {
    00114   private:
    00115     int         nRefCount;
    00116
    00117     int         nFieldCount;
    00118     OGRFieldDefn **papoFieldDefn;
    00119
    00120     OGRwkbGeometryType eGeomType;
    00121
    00122     char        *pszFeatureClassName;
    00123
    00124   public:
    00125                 OGRFeatureDefn( const char * pszName = NULL );
    00126     virtual    ~OGRFeatureDefn();
    00127
    00128     const char  *GetName() { return pszFeatureClassName; }
    00129
    00130     int         GetFieldCount() { return nFieldCount; }
    00131     OGRFieldDefn *GetFieldDefn( int i );
    00132     int         GetFieldIndex( const char * );
    00133
    00134     void        AddFieldDefn( OGRFieldDefn * );
    00135
    00136     OGRwkbGeometryType GetGeomType() { return eGeomType; }
    00137     void        SetGeomType( OGRwkbGeometryType );
    00138
    00139     OGRFeatureDefn *Clone();
    00140
    00141     int         Reference() { return ++nRefCount; }
    00142     int         Dereference() { return --nRefCount; }
    00143     int         GetReferenceCount() { return nRefCount; }
    00144     void        Release();
    00145
    00146     static OGRFeatureDefn  *CreateFeatureDefn( const char *pszName = NULL );
    00147     static void         DestroyFeatureDefn( OGRFeatureDefn * );
    00148 };
    00149
    00150 /************************************************************************/
    00151 /*                              OGRFeature                              */
    00152 /************************************************************************/
    00153
    00158 class CPL_DLL OGRFeature
    00159 {
    00160   private:
    00161
    00162     long                nFID;
    00163     OGRFeatureDefn      *poDefn;
    00164     OGRGeometry         *poGeometry;
    00165     OGRField            *pauFields;
    00166
    00167   protected:
    00168     char *              m_pszStyleString;
    00169     OGRStyleTable       *m_poStyleTable;
    00170     char *              m_pszTmpFieldValue;
    00171
    00172   public:
    00173                         OGRFeature( OGRFeatureDefn * );
    00174     virtual            ~OGRFeature();
    00175
    00176     OGRFeatureDefn     *GetDefnRef() { return poDefn; }
    00177
    00178     OGRErr              SetGeometryDirectly( OGRGeometry * );
    00179     OGRErr              SetGeometry( OGRGeometry * );
    00180     OGRGeometry        *GetGeometryRef() { return poGeometry; }
    00181     OGRGeometry        *StealGeometry();
    00182
    00183     OGRFeature         *Clone();
    00184     virtual OGRBoolean  Equal( OGRFeature * poFeature );
    00185
    00186     int                 GetFieldCount() { return poDefn->GetFieldCount(); }
    00187     OGRFieldDefn       *GetFieldDefnRef( int iField )
    00188                                       { return poDefn->GetFieldDefn(iField); }
    00189     int                 GetFieldIndex( const char * pszName)
    00190                                       { return poDefn->GetFieldIndex(pszName);}
    00191
    00192     int                 IsFieldSet( int iField ) const
    00193                         { return
    00194                               pauFields[iField].Set.nMarker1 != OGRUnsetMarker
    00195                            || pauFields[iField].Set.nMarker2 != OGRUnsetMarker;
    00196                               }
    00197
    00198     void                UnsetField( int iField );
    00199
    00200     OGRField           *GetRawFieldRef( int i ) { return pauFields + i; }
    00201
    00202     int                 GetFieldAsInteger( int i );
    00203     double              GetFieldAsDouble( int i );
    00204     const char         *GetFieldAsString( int i );
    00205     const int          *GetFieldAsIntegerList( int i, int *pnCount );
    00206     const double       *GetFieldAsDoubleList( int i, int *pnCount );
    00207     char              **GetFieldAsStringList( int i ) const;
    00208     GByte              *GetFieldAsBinary( int i, int *pnCount );
    00209     int                 GetFieldAsDateTime( int i,
    00210                                      int *pnYear, int *pnMonth, int *pnDay,
    00211                                      int *pnHour, int *pnMinute, int *pnSecond,
    00212                                      int *pnTZFlag );
    00213
    00214     int                 GetFieldAsInteger( const char *pszFName )
    00215                       { return GetFieldAsInteger( GetFieldIndex(pszFName) ); }
    00216     double              GetFieldAsDouble( const char *pszFName )
    00217                       { return GetFieldAsDouble( GetFieldIndex(pszFName) ); }
    00218     const char         *GetFieldAsString( const char *pszFName )
    00219                       { return GetFieldAsString( GetFieldIndex(pszFName) ); }
    00220     const int          *GetFieldAsIntegerList( const char *pszFName,
    00221                                                int *pnCount )
    00222                       { return GetFieldAsIntegerList( GetFieldIndex(pszFName),
    00223                                                       pnCount ); }
    00224     const double       *GetFieldAsDoubleList( const char *pszFName,
    00225                                               int *pnCount )
    00226                       { return GetFieldAsDoubleList( GetFieldIndex(pszFName),
    00227                                                      pnCount ); }
    00228     char              **GetFieldAsStringList( const char *pszFName )
    00229                       { return GetFieldAsStringList(GetFieldIndex(pszFName)); }
    00230
    00231     void                SetField( int i, int nValue );
    00232     void                SetField( int i, double dfValue );
    00233     void                SetField( int i, const char * pszValue );
    00234     void                SetField( int i, int nCount, int * panValues );
    00235     void                SetField( int i, int nCount, double * padfValues );
    00236     void                SetField( int i, char ** papszValues );
    00237     void                SetField( int i, OGRField * puValue );
    00238     void                SetField( int i, int nCount, GByte * pabyBinary );
    00239     void                SetField( int i, int nYear, int nMonth, int nDay,
    00240                                   int nHour=0, int nMinute=0, int nSecond=0,
    00241                                   int nTZFlag = 0 );
    00242
    00243     void                SetField( const char *pszFName, int nValue )
    00244                            { SetField( GetFieldIndex(pszFName), nValue ); }
    00245     void                SetField( const char *pszFName, double dfValue )
    00246                            { SetField( GetFieldIndex(pszFName), dfValue ); }
    00247     void                SetField( const char *pszFName, const char * pszValue)
    00248                            { SetField( GetFieldIndex(pszFName), pszValue ); }
    00249     void                SetField( const char *pszFName, int nCount,
    00250                                   int * panValues )
    00251                          { SetField(GetFieldIndex(pszFName),nCount,panValues);}
    00252     void                SetField( const char *pszFName, int nCount,
    00253                                   double * padfValues )
    00254                          {SetField(GetFieldIndex(pszFName),nCount,padfValues);}
    00255     void                SetField( const char *pszFName, char ** papszValues )
    00256                            { SetField( GetFieldIndex(pszFName), papszValues); }
    00257     void                SetField( const char *pszFName, OGRField * puValue )
    00258                            { SetField( GetFieldIndex(pszFName), puValue ); }
    00259     void                SetField( const char *pszFName,
    00260                                   int nYear, int nMonth, int nDay,
    00261                                   int nHour=0, int nMinute=0, int nSecond=0,
    00262                                   int nTZFlag = 0 )
    00263                            { SetField( GetFieldIndex(pszFName),
    00264                                        nYear, nMonth, nDay,
    00265                                        nHour, nMinute, nSecond, nTZFlag ); }
    00266
    00267     long                GetFID() { return nFID; }
    00268     virtual OGRErr      SetFID( long nFID );
    00269
    00270     void                DumpReadable( FILE * );
    00271
    00272     OGRErr              SetFrom( OGRFeature *, int = TRUE);
    00273
    00274     OGRErr              RemapFields( OGRFeatureDefn *poNewDefn,
    00275                                      int *panRemapSource );
    00276
    00277     virtual const char *GetStyleString();
    00278     virtual void        SetStyleString( const char * );
    00279     virtual void        SetStyleStringDirectly( char * );
    00280     virtual OGRStyleTable *GetStyleTable() { return m_poStyleTable; }
    00281     virtual void        SetStyleTable(OGRStyleTable *poStyleTable);
    00282     virtual void        SetStyleTableDirectly(OGRStyleTable *poStyleTable)
    00283                             { if ( m_poStyleTable ) delete m_poStyleTable;
    00284                               m_poStyleTable = poStyleTable; }
    00285
    00286     static OGRFeature  *CreateFeature( OGRFeatureDefn * );
    00287     static void         DestroyFeature( OGRFeature * );
    00288 };
    00289
    00290 /************************************************************************/
    00291 /*                           OGRFeatureQuery                            */
    00292 /************************************************************************/
    00293
    00294 class OGRLayer;
    00295
    00296 class CPL_DLL OGRFeatureQuery
    00297 {
    00298   private:
    00299     OGRFeatureDefn *poTargetDefn;
    00300     void           *pSWQExpr;
    00301
    00302     char          **FieldCollector( void *, char ** );
    00303
    00304   public:
    00305                 OGRFeatureQuery();
    00306                 ~OGRFeatureQuery();
    00307
    00308     OGRErr      Compile( OGRFeatureDefn *, const char * );
    00309     int         Evaluate( OGRFeature * );
    00310
    00311     long       *EvaluateAgainstIndices( OGRLayer *, OGRErr * );
    00312
    00313     char      **GetUsedFields();
    00314
    00315     void       *GetSWGExpr() { return pSWQExpr; }
    00316 };
    00317
    00318 #endif /* ndef _OGR_FEATURE_H_INCLUDED */

Generated for GDAL by 1.5.1.