00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119 #ifndef _OGR_FEATURE_H_INCLUDED
00120 #define _OGR_FEATURE_H_INCLUDED
00121
00122 #include "ogr_geometry.h"
00123
00124 class OGRStyleTable;
00125
00132
00133
00134
00135
00140 class CPL_DLL OGRFieldDefn
00141 {
00142 private:
00143 char *pszName;
00144 OGRFieldType eType;
00145 OGRJustification eJustify;
00146 int nWidth;
00147 int nPrecision;
00148 OGRField uDefault;
00149
00150 void Initialize( const char *, OGRFieldType );
00151
00152 public:
00153 OGRFieldDefn( const char *, OGRFieldType );
00154 OGRFieldDefn( OGRFieldDefn * );
00155 ~OGRFieldDefn();
00156
00157 void SetName( const char * );
00158 const char *GetNameRef() { return pszName; }
00159
00160 OGRFieldType GetType() { return eType; }
00161 void SetType( OGRFieldType eTypeIn ) { eType = eTypeIn;}
00162 static const char *GetFieldTypeName( OGRFieldType );
00163
00164 OGRJustification GetJustify() { return eJustify; }
00165 void SetJustify( OGRJustification eJustifyIn )
00166 { eJustify = eJustifyIn; }
00167
00168 int GetWidth() { return nWidth; }
00169 void SetWidth( int nWidthIn ) { nWidth = MAX(0,nWidthIn); }
00170
00171 int GetPrecision() { return nPrecision; }
00172 void SetPrecision( int nPrecisionIn )
00173 { nPrecision = nPrecisionIn; }
00174
00175 void Set( const char *, OGRFieldType, int = 0, int = 0,
00176 OGRJustification = OJUndefined );
00177
00178 void SetDefault( const OGRField * );
00179 const OGRField *GetDefaultRef() { return &uDefault; }
00180 };
00181
00182
00183
00184
00185
00202 class CPL_DLL OGRFeatureDefn
00203 {
00204 private:
00205 int nRefCount;
00206
00207 int nFieldCount;
00208 OGRFieldDefn **papoFieldDefn;
00209
00210 OGRwkbGeometryType eGeomType;
00211
00212 char *pszFeatureClassName;
00213
00214 public:
00215 OGRFeatureDefn( const char * pszName = NULL );
00216 virtual ~OGRFeatureDefn();
00217
00218 const char *GetName() { return pszFeatureClassName; }
00219
00220 int GetFieldCount() { return nFieldCount; }
00221 OGRFieldDefn *GetFieldDefn( int i );
00222 int GetFieldIndex( const char * );
00223
00224 void AddFieldDefn( OGRFieldDefn * );
00225
00226 OGRwkbGeometryType GetGeomType() { return eGeomType; }
00227 void SetGeomType( OGRwkbGeometryType );
00228
00229 OGRFeatureDefn *Clone();
00230
00231 int Reference() { return ++nRefCount; }
00232 int Dereference() { return --nRefCount; }
00233 int GetReferenceCount() { return nRefCount; }
00234
00235 static OGRFeatureDefn *CreateFeatureDefn( const char *pszName = NULL );
00236 static void DestroyFeatureDefn( OGRFeatureDefn * );
00237 };
00238
00239
00240
00241
00242
00247 class CPL_DLL OGRFeature
00248 {
00249 private:
00250
00251 long nFID;
00252 OGRFeatureDefn *poDefn;
00253 OGRGeometry *poGeometry;
00254 OGRField *pauFields;
00255
00256 protected:
00257 char * m_pszStyleString;
00258 OGRStyleTable *m_poStyleTable;
00259
00260
00261 public:
00262 OGRFeature( OGRFeatureDefn * );
00263 virtual ~OGRFeature();
00264
00265 OGRFeatureDefn *GetDefnRef() { return poDefn; }
00266
00267 OGRErr SetGeometryDirectly( OGRGeometry * );
00268 OGRErr SetGeometry( OGRGeometry * );
00269 OGRGeometry *GetGeometryRef() { return poGeometry; }
00270 OGRGeometry *StealGeometry();
00271
00272 OGRFeature *Clone();
00273 virtual OGRBoolean Equal( OGRFeature * poFeature );
00274
00275 int GetFieldCount() { return poDefn->GetFieldCount(); }
00276 OGRFieldDefn *GetFieldDefnRef( int iField )
00277 { return poDefn->GetFieldDefn(iField); }
00278 int GetFieldIndex( const char * pszName)
00279 { return poDefn->GetFieldIndex(pszName);}
00280
00281 int IsFieldSet( int iField )
00282 { return
00283 pauFields[iField].Set.nMarker1 != OGRUnsetMarker
00284 || pauFields[iField].Set.nMarker2 != OGRUnsetMarker;
00285 }
00286
00287 void UnsetField( int iField );
00288
00289 OGRField *GetRawFieldRef( int i ) { return pauFields + i; }
00290
00291 int GetFieldAsInteger( int i );
00292 double GetFieldAsDouble( int i );
00293 const char *GetFieldAsString( int i );
00294 const int *GetFieldAsIntegerList( int i, int *pnCount );
00295 const double *GetFieldAsDoubleList( int i, int *pnCount );
00296 char **GetFieldAsStringList( int i );
00297
00298 int GetFieldAsInteger( const char *pszFName )
00299 { return GetFieldAsInteger( GetFieldIndex(pszFName) ); }
00300 double GetFieldAsDouble( const char *pszFName )
00301 { return GetFieldAsDouble( GetFieldIndex(pszFName) ); }
00302 const char *GetFieldAsString( const char *pszFName )
00303 { return GetFieldAsString( GetFieldIndex(pszFName) ); }
00304 const int *GetFieldAsIntegerList( const char *pszFName,
00305 int *pnCount )
00306 { return GetFieldAsIntegerList( GetFieldIndex(pszFName),
00307 pnCount ); }
00308 const double *GetFieldAsDoubleList( const char *pszFName,
00309 int *pnCount )
00310 { return GetFieldAsDoubleList( GetFieldIndex(pszFName),
00311 pnCount ); }
00312 char **GetFieldAsStringList( const char *pszFName )
00313 { return GetFieldAsStringList(GetFieldIndex(pszFName)); }
00314
00315 void SetField( int i, int nValue );
00316 void SetField( int i, double dfValue );
00317 void SetField( int i, const char * pszValue );
00318 void SetField( int i, int nCount, int * panValues );
00319 void SetField( int i, int nCount, double * padfValues );
00320 void SetField( int i, char ** papszValues );
00321 void SetField( int i, OGRField * puValue );
00322
00323 void SetField( const char *pszFName, int nValue )
00324 { SetField( GetFieldIndex(pszFName), nValue ); }
00325 void SetField( const char *pszFName, double dfValue )
00326 { SetField( GetFieldIndex(pszFName), dfValue ); }
00327 void SetField( const char *pszFName, const char * pszValue)
00328 { SetField( GetFieldIndex(pszFName), pszValue ); }
00329 void SetField( const char *pszFName, int nCount,
00330 int * panValues )
00331 { SetField(GetFieldIndex(pszFName),nCount,panValues);}
00332 void SetField( const char *pszFName, int nCount,
00333 double * padfValues )
00334 {SetField(GetFieldIndex(pszFName),nCount,padfValues);}
00335 void SetField( const char *pszFName, char ** papszValues )
00336 { SetField( GetFieldIndex(pszFName), papszValues); }
00337 void SetField( const char *pszFName, OGRField * puValue )
00338 { SetField( GetFieldIndex(pszFName), puValue ); }
00339
00340 long GetFID() { return nFID; }
00341 virtual OGRErr SetFID( long nFID );
00342
00343 void DumpReadable( FILE * );
00344
00345 OGRErr SetFrom( OGRFeature *, int = TRUE);
00346
00347 OGRErr RemapFields( OGRFeatureDefn *poNewDefn,
00348 int *panRemapSource );
00349
00350 virtual const char *GetStyleString();
00351 virtual void SetStyleString(const char *);
00352 virtual void SetStyleTable(OGRStyleTable *poStyleTable);
00353
00354 static OGRFeature *CreateFeature( OGRFeatureDefn * );
00355 static void DestroyFeature( OGRFeature * );
00356 };
00357
00358
00359
00360
00361
00362 class OGRLayer;
00363
00364 class CPL_DLL OGRFeatureQuery
00365 {
00366 private:
00367 OGRFeatureDefn *poTargetDefn;
00368 void *pSWQExpr;
00369
00370 public:
00371 OGRFeatureQuery();
00372 ~OGRFeatureQuery();
00373
00374 OGRErr Compile( OGRFeatureDefn *, const char * );
00375 int Evaluate( OGRFeature * );
00376
00377 long *EvaluateAgainstIndices( OGRLayer *, OGRErr * );
00378 };
00379
00380 #endif