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
00120
00121
00122 #ifndef _OGR_FEATURE_H_INCLUDED
00123 #define _OGR_FEATURE_H_INCLUDED
00124
00125 #include "ogr_geometry.h"
00126
00127 class OGRStyleTable;
00128
00135
00136
00137
00138
00143 class CPL_DLL OGRFieldDefn
00144 {
00145 private:
00146 char *pszName;
00147 OGRFieldType eType;
00148 OGRJustification eJustify;
00149 int nWidth;
00150 int nPrecision;
00151 OGRField uDefault;
00152
00153 void Initialize( const char *, OGRFieldType );
00154
00155 public:
00156 OGRFieldDefn( const char *, OGRFieldType );
00157 OGRFieldDefn( OGRFieldDefn * );
00158 ~OGRFieldDefn();
00159
00160 void SetName( const char * );
00161 const char *GetNameRef() { return pszName; }
00162
00163 OGRFieldType GetType() { return eType; }
00164 void SetType( OGRFieldType eTypeIn ) { eType = eTypeIn;}
00165 static const char *GetFieldTypeName( OGRFieldType );
00166
00167 OGRJustification GetJustify() { return eJustify; }
00168 void SetJustify( OGRJustification eJustifyIn )
00169 { eJustify = eJustifyIn; }
00170
00171 int GetWidth() { return nWidth; }
00172 void SetWidth( int nWidthIn ) { nWidth = MAX(0,nWidthIn); }
00173
00174 int GetPrecision() { return nPrecision; }
00175 void SetPrecision( int nPrecisionIn )
00176 { nPrecision = nPrecisionIn; }
00177
00178 void Set( const char *, OGRFieldType, int = 0, int = 0,
00179 OGRJustification = OJUndefined );
00180
00181 void SetDefault( const OGRField * );
00182 const OGRField *GetDefaultRef() { return &uDefault; }
00183 };
00184
00185
00186
00187
00188
00205 class CPL_DLL OGRFeatureDefn
00206 {
00207 private:
00208 int nRefCount;
00209
00210 int nFieldCount;
00211 OGRFieldDefn **papoFieldDefn;
00212
00213 OGRwkbGeometryType eGeomType;
00214
00215 char *pszFeatureClassName;
00216
00217 public:
00218 OGRFeatureDefn( const char * pszName = NULL );
00219 virtual ~OGRFeatureDefn();
00220
00221 const char *GetName() { return pszFeatureClassName; }
00222
00223 int GetFieldCount() { return nFieldCount; }
00224 OGRFieldDefn *GetFieldDefn( int i );
00225 int GetFieldIndex( const char * );
00226
00227 void AddFieldDefn( OGRFieldDefn * );
00228
00229 OGRwkbGeometryType GetGeomType() { return eGeomType; }
00230 void SetGeomType( OGRwkbGeometryType );
00231
00232 OGRFeatureDefn *Clone();
00233
00234 int Reference() { return ++nRefCount; }
00235 int Dereference() { return --nRefCount; }
00236 int GetReferenceCount() { return nRefCount; }
00237
00238 static OGRFeatureDefn *CreateFeatureDefn( const char *pszName = NULL );
00239 static void DestroyFeatureDefn( OGRFeatureDefn * );
00240 };
00241
00242
00243
00244
00245
00250 class CPL_DLL OGRFeature
00251 {
00252 private:
00253
00254 long nFID;
00255 OGRFeatureDefn *poDefn;
00256 OGRGeometry *poGeometry;
00257 OGRField *pauFields;
00258
00259 protected:
00260 char * m_pszStyleString;
00261 OGRStyleTable *m_poStyleTable;
00262
00263
00264 public:
00265 OGRFeature( OGRFeatureDefn * );
00266 virtual ~OGRFeature();
00267
00268 OGRFeatureDefn *GetDefnRef() { return poDefn; }
00269
00270 OGRErr SetGeometryDirectly( OGRGeometry * );
00271 OGRErr SetGeometry( OGRGeometry * );
00272 OGRGeometry *GetGeometryRef() { return poGeometry; }
00273 OGRGeometry *StealGeometry();
00274
00275 OGRFeature *Clone();
00276 virtual OGRBoolean Equal( OGRFeature * poFeature );
00277
00278 int GetFieldCount() { return poDefn->GetFieldCount(); }
00279 OGRFieldDefn *GetFieldDefnRef( int iField )
00280 { return poDefn->GetFieldDefn(iField); }
00281 int GetFieldIndex( const char * pszName)
00282 { return poDefn->GetFieldIndex(pszName);}
00283
00284 int IsFieldSet( int iField )
00285 { return
00286 pauFields[iField].Set.nMarker1 != OGRUnsetMarker
00287 || pauFields[iField].Set.nMarker2 != OGRUnsetMarker;
00288 }
00289
00290 void UnsetField( int iField );
00291
00292 OGRField *GetRawFieldRef( int i ) { return pauFields + i; }
00293
00294 int GetFieldAsInteger( int i );
00295 double GetFieldAsDouble( int i );
00296 const char *GetFieldAsString( int i );
00297 const int *GetFieldAsIntegerList( int i, int *pnCount );
00298 const double *GetFieldAsDoubleList( int i, int *pnCount );
00299 char **GetFieldAsStringList( int i );
00300
00301 int GetFieldAsInteger( const char *pszFName )
00302 { return GetFieldAsInteger( GetFieldIndex(pszFName) ); }
00303 double GetFieldAsDouble( const char *pszFName )
00304 { return GetFieldAsDouble( GetFieldIndex(pszFName) ); }
00305 const char *GetFieldAsString( const char *pszFName )
00306 { return GetFieldAsString( GetFieldIndex(pszFName) ); }
00307 const int *GetFieldAsIntegerList( const char *pszFName,
00308 int *pnCount )
00309 { return GetFieldAsIntegerList( GetFieldIndex(pszFName),
00310 pnCount ); }
00311 const double *GetFieldAsDoubleList( const char *pszFName,
00312 int *pnCount )
00313 { return GetFieldAsDoubleList( GetFieldIndex(pszFName),
00314 pnCount ); }
00315 char **GetFieldAsStringList( const char *pszFName )
00316 { return GetFieldAsStringList(GetFieldIndex(pszFName)); }
00317
00318 void SetField( int i, int nValue );
00319 void SetField( int i, double dfValue );
00320 void SetField( int i, const char * pszValue );
00321 void SetField( int i, int nCount, int * panValues );
00322 void SetField( int i, int nCount, double * padfValues );
00323 void SetField( int i, char ** papszValues );
00324 void SetField( int i, OGRField * puValue );
00325
00326 void SetField( const char *pszFName, int nValue )
00327 { SetField( GetFieldIndex(pszFName), nValue ); }
00328 void SetField( const char *pszFName, double dfValue )
00329 { SetField( GetFieldIndex(pszFName), dfValue ); }
00330 void SetField( const char *pszFName, const char * pszValue)
00331 { SetField( GetFieldIndex(pszFName), pszValue ); }
00332 void SetField( const char *pszFName, int nCount,
00333 int * panValues )
00334 { SetField(GetFieldIndex(pszFName),nCount,panValues);}
00335 void SetField( const char *pszFName, int nCount,
00336 double * padfValues )
00337 {SetField(GetFieldIndex(pszFName),nCount,padfValues);}
00338 void SetField( const char *pszFName, char ** papszValues )
00339 { SetField( GetFieldIndex(pszFName), papszValues); }
00340 void SetField( const char *pszFName, OGRField * puValue )
00341 { SetField( GetFieldIndex(pszFName), puValue ); }
00342
00343 long GetFID() { return nFID; }
00344 virtual OGRErr SetFID( long nFID );
00345
00346 void DumpReadable( FILE * );
00347
00348 OGRErr SetFrom( OGRFeature *, int = TRUE);
00349
00350 OGRErr RemapFields( OGRFeatureDefn *poNewDefn,
00351 int *panRemapSource );
00352
00353 virtual const char *GetStyleString();
00354 virtual void SetStyleString(const char *);
00355 virtual void SetStyleTable(OGRStyleTable *poStyleTable);
00356
00357 static OGRFeature *CreateFeature( OGRFeatureDefn * );
00358 static void DestroyFeature( OGRFeature * );
00359 };
00360
00361
00362
00363
00364
00365 class OGRLayer;
00366
00367 class CPL_DLL OGRFeatureQuery
00368 {
00369 private:
00370 OGRFeatureDefn *poTargetDefn;
00371 void *pSWQExpr;
00372
00373 char **FieldCollector( void *, char ** );
00374
00375 public:
00376 OGRFeatureQuery();
00377 ~OGRFeatureQuery();
00378
00379 OGRErr Compile( OGRFeatureDefn *, const char * );
00380 int Evaluate( OGRFeature * );
00381
00382 long *EvaluateAgainstIndices( OGRLayer *, OGRErr * );
00383
00384 char **GetUsedFields();
00385
00386 void *GetSWGExpr() { return pSWQExpr; }
00387 };
00388
00389 #endif