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