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