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