OGR
Public Member Functions | Static Public Member Functions | List of all members
OGRFeature Class Reference

#include <ogr_feature.h>

Public Member Functions

 OGRFeature (OGRFeatureDefn *)
 Constructor. More...
 
OGRFeatureDefnGetDefnRef ()
 Fetch feature definition. More...
 
OGRErr SetGeometryDirectly (OGRGeometry *)
 Set feature geometry. More...
 
OGRErr SetGeometry (OGRGeometry *)
 Set feature geometry. More...
 
OGRGeometryGetGeometryRef ()
 Fetch pointer to feature geometry. More...
 
OGRGeometryStealGeometry ()
 Take away ownership of geometry. More...
 
int GetGeomFieldCount ()
 Fetch number of geometry fields on this feature. This will always be the same as the geometry field count for the OGRFeatureDefn. More...
 
OGRGeomFieldDefnGetGeomFieldDefnRef (int iField)
 Fetch definition for this geometry field. More...
 
int GetGeomFieldIndex (const char *pszName)
 Fetch the geometry field index given geometry field name. More...
 
OGRGeometryGetGeomFieldRef (int iField)
 Fetch pointer to feature geometry. More...
 
OGRGeometryGetGeomFieldRef (const char *pszFName)
 Fetch pointer to feature geometry. More...
 
OGRErr SetGeomFieldDirectly (int iField, OGRGeometry *)
 Set feature geometry of a specified geometry field. More...
 
OGRErr SetGeomField (int iField, OGRGeometry *)
 Set feature geometry of a specified geometry field. More...
 
OGRFeatureClone ()
 Duplicate feature. More...
 
virtual OGRBoolean Equal (OGRFeature *poFeature)
 Test if two features are the same. More...
 
int GetFieldCount ()
 Fetch number of fields on this feature. This will always be the same as the field count for the OGRFeatureDefn. More...
 
OGRFieldDefnGetFieldDefnRef (int iField)
 Fetch definition for this field. More...
 
int GetFieldIndex (const char *pszName)
 Fetch the field index given field name. More...
 
int IsFieldSet (int iField)
 Test if a field has ever been assigned a value or not. More...
 
void UnsetField (int iField)
 Clear a field, marking it as unset. More...
 
OGRFieldGetRawFieldRef (int i)
 Fetch a pointer to the internal field value given the index. More...
 
int GetFieldAsInteger (int i)
 Fetch field value as integer. More...
 
double GetFieldAsDouble (int i)
 Fetch field value as a double. More...
 
const char * GetFieldAsString (int i)
 Fetch field value as a string. More...
 
const int * GetFieldAsIntegerList (int i, int *pnCount)
 Fetch field value as a list of integers. More...
 
const double * GetFieldAsDoubleList (int i, int *pnCount)
 Fetch field value as a list of doubles. More...
 
char ** GetFieldAsStringList (int i)
 Fetch field value as a list of strings. More...
 
GByte * GetFieldAsBinary (int i, int *pnCount)
 Fetch field value as binary data. More...
 
int GetFieldAsDateTime (int i, int *pnYear, int *pnMonth, int *pnDay, int *pnHour, int *pnMinute, int *pnSecond, int *pnTZFlag)
 Fetch field value as date and time. More...
 
void SetField (int i, int nValue)
 Set field to integer value. More...
 
void SetField (int i, double dfValue)
 Set field to double value. More...
 
void SetField (int i, const char *pszValue)
 Set field to string value. More...
 
void SetField (int i, int nCount, int *panValues)
 Set field to list of integers value. More...
 
void SetField (int i, int nCount, double *padfValues)
 Set field to list of doubles value. More...
 
void SetField (int i, char **papszValues)
 Set field to list of strings value. More...
 
void SetField (int i, OGRField *puValue)
 Set field. More...
 
void SetField (int i, int nCount, GByte *pabyBinary)
 Set field to binary data. More...
 
void SetField (int i, int nYear, int nMonth, int nDay, int nHour=0, int nMinute=0, int nSecond=0, int nTZFlag=0)
 Set field to date. More...
 
long GetFID ()
 Get feature identifier. More...
 
virtual OGRErr SetFID (long nFID)
 Set the feature identifier. More...
 
void DumpReadable (FILE *, char **papszOptions=NULL)
 Dump this feature in a human readable form. More...
 
OGRErr SetFrom (OGRFeature *, int=TRUE)
 Set one feature from another. More...
 
OGRErr SetFrom (OGRFeature *, int *, int=TRUE)
 Set one feature from another. More...
 
OGRErr SetFieldsFrom (OGRFeature *, int *, int=TRUE)
 Set fields from another feature. More...
 
virtual const char * GetStyleString ()
 Fetch style string for this feature. More...
 
virtual void SetStyleString (const char *)
 Set feature style string. This method operate exactly as OGRFeature::SetStyleStringDirectly() except that it does not assume ownership of the passed string, but instead makes a copy of it. More...
 
virtual void SetStyleStringDirectly (char *)
 Set feature style string. This method operate exactly as OGRFeature::SetStyleString() except that it assumes ownership of the passed string. More...
 

Static Public Member Functions

static OGRFeatureCreateFeature (OGRFeatureDefn *)
 Feature factory. More...
 
static void DestroyFeature (OGRFeature *)
 Destroy feature. More...
 

Detailed Description

A simple feature, including geometry and attributes.

Constructor & Destructor Documentation

OGRFeature::OGRFeature ( OGRFeatureDefn poDefnIn)

Constructor.

Note that the OGRFeature will increment the reference count of it's defining OGRFeatureDefn. Destruction of the OGRFeatureDefn before destruction of all OGRFeatures that depend on it is likely to result in a crash.

This method is the same as the C function OGR_F_Create().

Parameters
poDefnInfeature class (layer) definition to which the feature will adhere.

References CPLCalloc(), CPLMalloc(), OGRFeatureDefn::GetFieldCount(), OGRFeatureDefn::GetGeomFieldCount(), and OGRFeatureDefn::Reference().

Referenced by Clone(), CreateFeature(), and OGR_F_Create().

Member Function Documentation

OGRFeature * OGRFeature::Clone ( )

Duplicate feature.

The newly created feature is owned by the caller, and will have it's own reference to the OGRFeatureDefn.

This method is the same as the C function OGR_F_Clone().

Returns
new feature, exactly matching this feature.

References GetFID(), OGRFeatureDefn::GetFieldCount(), OGRFeatureDefn::GetGeomFieldCount(), GetStyleString(), OGRFeature(), SetFID(), SetField(), SetGeomField(), and SetStyleString().

OGRFeature * OGRFeature::CreateFeature ( OGRFeatureDefn poDefn)
static

Feature factory.

This is essentially a feature factory, useful for applications creating features but wanting to ensure they are created out of the OGR/GDAL heap.

This method is the same as the C function OGR_F_Create().

Parameters
poDefnFeature definition defining schema.
Returns
new feature object with null fields and no geometry. May be deleted with delete.

References OGRFeature().

Referenced by OGRDataSource::CopyLayer().

void OGRFeature::DestroyFeature ( OGRFeature poFeature)
static

Destroy feature.

The feature is deleted, but within the context of the GDAL/OGR heap. This is necessary when higher level applications use GDAL/OGR from a DLL and they want to delete a feature created within the DLL. If the delete is done in the calling application the memory will be freed onto the application heap which is inappropriate.

This method is the same as the C function OGR_F_Destroy().

Parameters
poFeaturethe feature to delete.

Referenced by OGRDataSource::CopyLayer(), and OGRGeocodeDestroySession().

void OGRFeature::DumpReadable ( FILE *  fpOut,
char **  papszOptions = NULL 
)

Dump this feature in a human readable form.

This dumps the attributes, and geometry; however, it doesn't definition information (other than field types and names), nor does it report the geometry spatial reference system.

A few options can be defined to change the default dump :

  • DISPLAY_FIELDS=NO : to hide the dump of the attributes
  • DISPLAY_STYLE=NO : to hide the dump of the style string
  • DISPLAY_GEOMETRY=NO : to hide the dump of the geometry
  • DISPLAY_GEOMETRY=SUMMARY : to get only a summary of the geometry

This method is the same as the C function OGR_F_DumpReadable().

Parameters
fpOutthe stream to write to, such as stdout. If NULL stdout will be used.
papszOptionsNULL terminated list of options (may be NULL)

References CSLTestBoolean(), OGRGeometry::dumpReadable(), GetFID(), GetFieldAsString(), GetFieldCount(), OGRFeatureDefn::GetFieldDefn(), OGRFieldDefn::GetFieldTypeName(), GetGeomFieldCount(), OGRFeatureDefn::GetGeomFieldDefn(), OGRFeatureDefn::GetName(), OGRFieldDefn::GetNameRef(), OGRGeomFieldDefn::GetNameRef(), GetStyleString(), OGRFieldDefn::GetType(), and IsFieldSet().

OGRBoolean OGRFeature::Equal ( OGRFeature poFeature)
virtual

Test if two features are the same.

Two features are considered equal if the share them (pointer equality) same OGRFeatureDefn, have the same field values, and the same geometry (as tested by OGRGeometry::Equal()) as well as the same feature id.

This method is the same as the C function OGR_F_Equal().

Parameters
poFeaturethe other feature to test this one against.
Returns
TRUE if they are equal, otherwise FALSE.

References CSLCount(), OGRGeometry::Equals(), GetDefnRef(), GetFID(), GetFieldAsBinary(), GetFieldAsDateTime(), GetFieldAsDouble(), GetFieldAsDoubleList(), GetFieldAsInteger(), GetFieldAsIntegerList(), GetFieldAsString(), GetFieldAsStringList(), OGRFeatureDefn::GetFieldCount(), OGRFeatureDefn::GetFieldDefn(), GetGeomFieldCount(), GetGeomFieldRef(), OGRFieldDefn::GetType(), IsFieldSet(), OFTBinary, OFTDate, OFTDateTime, OFTInteger, OFTIntegerList, OFTReal, OFTRealList, OFTString, OFTStringList, and OFTTime.

OGRFeatureDefn * OGRFeature::GetDefnRef ( )
inline

Fetch feature definition.

This method is the same as the C function OGR_F_GetDefnRef().

Returns
a reference to the feature definition object.

Referenced by Equal(), and OGRGenSQLResultsLayer::TestCapability().

long OGRFeature::GetFID ( )
inline
GByte * OGRFeature::GetFieldAsBinary ( int  iField,
int *  pnBytes 
)

Fetch field value as binary data.

Currently this method only works for OFTBinary fields.

This method is the same as the C function OGR_F_GetFieldAsBinary().

Parameters
iFieldthe field to fetch, from 0 to GetFieldCount()-1.
pnByteslocation to put the number of bytes returned.
Returns
the field value. This data is internal, and should not be modified, or freed. Its lifetime may be very brief.

References OGRFeatureDefn::GetFieldDefn(), OGRFieldDefn::GetType(), IsFieldSet(), and OFTBinary.

Referenced by Equal().

int OGRFeature::GetFieldAsDateTime ( int  iField,
int *  pnYear,
int *  pnMonth,
int *  pnDay,
int *  pnHour,
int *  pnMinute,
int *  pnSecond,
int *  pnTZFlag 
)

Fetch field value as date and time.

Currently this method only works for OFTDate, OFTTime and OFTDateTime fields.

This method is the same as the C function OGR_F_GetFieldAsDateTime().

Parameters
iFieldthe field to fetch, from 0 to GetFieldCount()-1.
pnYear(including century)
pnMonth(1-12)
pnDay(1-31)
pnHour(0-23)
pnMinute(0-59)
pnSecond(0-59)
pnTZFlag(0=unknown, 1=localtime, 100=GMT, see data model for details)
Returns
TRUE on success or FALSE on failure.

References OGRFeatureDefn::GetFieldDefn(), OGRFieldDefn::GetType(), IsFieldSet(), OFTDate, OFTDateTime, and OFTTime.

Referenced by Equal().

double OGRFeature::GetFieldAsDouble ( int  iField)

Fetch field value as a double.

OFTString features will be translated using atof(). OFTInteger fields will be cast to double. Other field types, or errors will result in a return value of zero.

This method is the same as the C function OGR_F_GetFieldAsDouble().

Parameters
iFieldthe field to fetch, from 0 to GetFieldCount()-1.
Returns
the field value.

References GetFID(), OGRFeatureDefn::GetFieldCount(), OGRFeatureDefn::GetFieldDefn(), GetGeomFieldCount(), OGRFieldDefn::GetType(), IsFieldSet(), OFTInteger, OFTReal, OFTString, and OGR_G_Area().

Referenced by Equal(), OGRGenSQLResultsLayer::GetLayerDefn(), SetFieldsFrom(), and OGRGenSQLResultsLayer::TestCapability().

const double * OGRFeature::GetFieldAsDoubleList ( int  iField,
int *  pnCount 
)

Fetch field value as a list of doubles.

Currently this method only works for OFTRealList fields.

This method is the same as the C function OGR_F_GetFieldAsDoubleList().

Parameters
iFieldthe field to fetch, from 0 to GetFieldCount()-1.
pnCountan integer to put the list count (number of doubles) into.
Returns
the field value. This list is internal, and should not be modified, or freed. Its lifetime may be very brief. If *pnCount is zero on return the returned pointer may be NULL or non-NULL.

References OGRFeatureDefn::GetFieldDefn(), OGRFieldDefn::GetType(), IsFieldSet(), and OFTRealList.

Referenced by Equal(), and SetFieldsFrom().

int OGRFeature::GetFieldAsInteger ( int  iField)

Fetch field value as integer.

OFTString features will be translated using atoi(). OFTReal fields will be cast to integer. Other field types, or errors will result in a return value of zero.

This method is the same as the C function OGR_F_GetFieldAsInteger().

Parameters
iFieldthe field to fetch, from 0 to GetFieldCount()-1.
Returns
the field value.

References GetFID(), OGRFeatureDefn::GetFieldCount(), OGRFeatureDefn::GetFieldDefn(), GetGeomFieldCount(), OGRFieldDefn::GetType(), IsFieldSet(), OFTInteger, OFTReal, OFTString, and OGR_G_Area().

Referenced by Equal(), OGRGenSQLResultsLayer::GetLayerDefn(), SetFieldsFrom(), and OGRGenSQLResultsLayer::TestCapability().

const int * OGRFeature::GetFieldAsIntegerList ( int  iField,
int *  pnCount 
)

Fetch field value as a list of integers.

Currently this method only works for OFTIntegerList fields.

This method is the same as the C function OGR_F_GetFieldAsIntegerList().

Parameters
iFieldthe field to fetch, from 0 to GetFieldCount()-1.
pnCountan integer to put the list count (number of integers) into.
Returns
the field value. This list is internal, and should not be modified, or freed. Its lifetime may be very brief. If *pnCount is zero on return the returned pointer may be NULL or non-NULL.

References OGRFeatureDefn::GetFieldDefn(), OGRFieldDefn::GetType(), IsFieldSet(), and OFTIntegerList.

Referenced by Equal(), and SetFieldsFrom().

const char * OGRFeature::GetFieldAsString ( int  iField)

Fetch field value as a string.

OFTReal and OFTInteger fields will be translated to string using sprintf(), but not necessarily using the established formatting rules. Other field types, or errors will result in a return value of zero.

This method is the same as the C function OGR_F_GetFieldAsString().

Parameters
iFieldthe field to fetch, from 0 to GetFieldCount()-1.
Returns
the field value. This string is internal, and should not be modified, or freed. Its lifetime may be very brief.

References CPLBinaryToHex(), CPLStrdup(), GetFID(), OGRFeatureDefn::GetFieldCount(), OGRFeatureDefn::GetFieldDefn(), OGRGeometry::getGeometryName(), GetGeomFieldCount(), OGRFieldDefn::GetPrecision(), GetStyleString(), OGRFieldDefn::GetType(), OGRFieldDefn::GetWidth(), IsFieldSet(), OFTBinary, OFTDate, OFTDateTime, OFTInteger, OFTIntegerList, OFTReal, OFTRealList, OFTString, OFTStringList, OFTTime, and OGR_G_Area().

Referenced by OGRUnionLayer::CreateFeature(), DumpReadable(), Equal(), OGRGenSQLResultsLayer::GetLayerDefn(), GetStyleString(), OGRGeocodeDestroySession(), OGRUnionLayer::SetFeature(), SetFieldsFrom(), and OGRGenSQLResultsLayer::TestCapability().

char ** OGRFeature::GetFieldAsStringList ( int  iField)

Fetch field value as a list of strings.

Currently this method only works for OFTStringList fields.

The returned list is terminated by a NULL pointer. The number of elements can also be calculated using CSLCount().

This method is the same as the C function OGR_F_GetFieldAsStringList().

Parameters
iFieldthe field to fetch, from 0 to GetFieldCount()-1.
Returns
the field value. This list is internal, and should not be modified, or freed. Its lifetime may be very brief.

References OGRFeatureDefn::GetFieldDefn(), OGRFieldDefn::GetType(), IsFieldSet(), and OFTStringList.

Referenced by Equal().

int OGRFeature::GetFieldCount ( )
inline

Fetch number of fields on this feature. This will always be the same as the field count for the OGRFeatureDefn.

This method is the same as the C function OGR_F_GetFieldCount().

Returns
count of fields.

References OGRFeatureDefn::GetFieldCount().

Referenced by DumpReadable(), OGR_F_IsFieldSet(), SetFieldsFrom(), and SetFrom().

OGRFieldDefn * OGRFeature::GetFieldDefnRef ( int  iField)
inline

Fetch definition for this field.

This method is the same as the C function OGR_F_GetFieldDefnRef().

Parameters
iFieldthe field to fetch, from 0 to GetFieldCount()-1.
Returns
the field definition (from the OGRFeatureDefn). This is an internal reference, and should not be deleted or modified.

References OGRFeatureDefn::GetFieldDefn().

Referenced by SetFieldsFrom(), and SetFrom().

int OGRFeature::GetFieldIndex ( const char *  pszName)
inline

Fetch the field index given field name.

This is a cover for the OGRFeatureDefn::GetFieldIndex() method.

This method is the same as the C function OGR_F_GetFieldIndex().

Parameters
pszNamethe name of the field to search for.
Returns
the field index, or -1 if no matching field is found.

References OGRFeatureDefn::GetFieldIndex().

Referenced by GetStyleString(), and SetFrom().

OGRGeometry * OGRFeature::GetGeometryRef ( )

Fetch pointer to feature geometry.

This method is the same as the C function OGR_F_GetGeometryRef().

Starting with GDAL 1.11, this is equivalent to calling OGRFeature::GetGeomFieldRef(0).

Returns
pointer to internal feature geometry. This object should not be modified.

References GetGeomFieldCount(), and GetGeomFieldRef().

Referenced by OGRLayer::Clip(), OGRLayer::Erase(), OGR_L_SetIgnoredFields(), and OGRGeocodeDestroySession().

int OGRFeature::GetGeomFieldCount ( )
inline

Fetch number of geometry fields on this feature. This will always be the same as the geometry field count for the OGRFeatureDefn.

This method is the same as the C function OGR_F_GetGeomFieldCount().

Returns
count of geometry fields.
Since
GDAL 1.11

References OGRFeatureDefn::GetGeomFieldCount().

Referenced by DumpReadable(), Equal(), GetFieldAsDouble(), GetFieldAsInteger(), GetFieldAsString(), GetGeometryRef(), GetGeomFieldRef(), IsFieldSet(), SetFrom(), SetGeometry(), SetGeometryDirectly(), SetGeomField(), SetGeomFieldDirectly(), and StealGeometry().

OGRGeomFieldDefn * OGRFeature::GetGeomFieldDefnRef ( int  iGeomField)
inline

Fetch definition for this geometry field.

This method is the same as the C function OGR_F_GetGeomFieldDefnRef().

Parameters
iGeomFieldthe field to fetch, from 0 to GetGeomFieldCount()-1.
Returns
the field definition (from the OGRFeatureDefn). This is an internal reference, and should not be deleted or modified.
Since
GDAL 1.11

References OGRFeatureDefn::GetGeomFieldDefn().

Referenced by SetFrom(), and OGRGenSQLResultsLayer::TestCapability().

int OGRFeature::GetGeomFieldIndex ( const char *  pszName)
inline

Fetch the geometry field index given geometry field name.

This is a cover for the OGRFeatureDefn::GetGeomFieldIndex() method.

This method is the same as the C function OGR_F_GetGeomFieldIndex().

Parameters
pszNamethe name of the geometry field to search for.
Returns
the geometry field index, or -1 if no matching geometry field is found.
Since
GDAL 1.11

References OGRFeatureDefn::GetGeomFieldIndex().

Referenced by GetGeomFieldRef(), and SetFrom().

OGRGeometry * OGRFeature::GetGeomFieldRef ( int  iField)

Fetch pointer to feature geometry.

This method is the same as the C function OGR_F_GetGeomFieldRef().

Parameters
iFieldgeometry field to get.
Returns
pointer to internal feature geometry. This object should not be modified.
Since
GDAL 1.11

References GetGeomFieldCount().

Referenced by Equal(), OGRLayer::GetExtent(), GetGeometryRef(), OGRWarpedLayer::GetNextFeature(), OGRGenSQLResultsLayer::GetNextFeature(), OGRUnionLayer::GetNextFeature(), SetFrom(), OGRUnionLayer::SetSpatialFilter(), OGRWarpedLayer::SetSpatialFilterRect(), and OGRGenSQLResultsLayer::TestCapability().

OGRGeometry * OGRFeature::GetGeomFieldRef ( const char *  pszFName)

Fetch pointer to feature geometry.

Parameters
pszFNamename of geometry field to get.
Returns
pointer to internal feature geometry. This object should not be modified.
Since
GDAL 1.11

References GetGeomFieldIndex().

OGRField * OGRFeature::GetRawFieldRef ( int  iField)
inline

Fetch a pointer to the internal field value given the index.

This method is the same as the C function OGR_F_GetRawFieldRef().

Parameters
iFieldthe field to fetch, from 0 to GetFieldCount()-1.
Returns
the returned pointer is to an internal data structure, and should not be freed, or modified.

Referenced by OGRGenSQLResultsLayer::GetLayerDefn(), SetFieldsFrom(), and OGRGenSQLResultsLayer::TestCapability().

const char * OGRFeature::GetStyleString ( )
virtual

Fetch style string for this feature.

Set the OGR Feature Style Specification for details on the format of this string, and ogr_featurestyle.h for services available to parse it.

This method is the same as the C function OGR_F_GetStyleString().

Returns
a reference to a representation in string format, or NULL if there isn't one.

References GetFieldAsString(), and GetFieldIndex().

Referenced by Clone(), DumpReadable(), GetFieldAsString(), OGRStyleMgr::InitFromFeature(), SetFrom(), and OGRGenSQLResultsLayer::TestCapability().

int OGRFeature::IsFieldSet ( int  iField)
OGRErr OGRFeature::SetFID ( long  nFID)
virtual

Set the feature identifier.

For specific types of features this operation may fail on illegal features ids. Generally it always succeeds. Feature ids should be greater than or equal to zero, with the exception of OGRNullFID (-1) indicating that the feature id is unknown.

This method is the same as the C function OGR_F_SetFID().

Parameters
nFIDthe new feature identifier value to assign.
Returns
On success OGRERR_NONE, or on failure some other value.

Referenced by Clone(), OGRDataSource::CopyLayer(), OGRUnionLayer::CreateFeature(), OGRGenSQLResultsLayer::GetFeature(), OGRUnionLayer::SetFeature(), SetFrom(), OGRUnionLayer::SetSpatialFilter(), OGRWarpedLayer::SetSpatialFilterRect(), and OGRGenSQLResultsLayer::TestCapability().

void OGRFeature::SetField ( int  iField,
int  nValue 
)

Set field to integer value.

OFTInteger and OFTReal fields will be set directly. OFTString fields will be assigned a string representation of the value, but not necessarily taking into account formatting constraints on this field. Other field types may be unaffected.

This method is the same as the C function OGR_F_SetFieldInteger().

Parameters
iFieldthe field to fetch, from 0 to GetFieldCount()-1.
nValuethe value to assign.

References CPLStrdup(), OGRFeatureDefn::GetFieldDefn(), OGRFieldDefn::GetType(), IsFieldSet(), OFTInteger, OFTIntegerList, OFTReal, OFTRealList, and OFTString.

Referenced by Clone(), OGRGeocodeDestroySession(), SetField(), SetFieldsFrom(), OGRUnionLayer::SetSpatialFilter(), and OGRGenSQLResultsLayer::TestCapability().

void OGRFeature::SetField ( int  iField,
double  dfValue 
)

Set field to double value.

OFTInteger and OFTReal fields will be set directly. OFTString fields will be assigned a string representation of the value, but not necessarily taking into account formatting constraints on this field. Other field types may be unaffected.

This method is the same as the C function OGR_F_SetFieldDouble().

Parameters
iFieldthe field to fetch, from 0 to GetFieldCount()-1.
dfValuethe value to assign.

References CPLStrdup(), OGRFeatureDefn::GetFieldDefn(), OGRFieldDefn::GetType(), IsFieldSet(), OFTInteger, OFTIntegerList, OFTReal, OFTRealList, OFTString, and SetField().

void OGRFeature::SetField ( int  iField,
const char *  pszValue 
)

Set field to string value.

OFTInteger fields will be set based on an atoi() conversion of the string. OFTReal fields will be set based on an atof() conversion of the string. Other field types may be unaffected.

This method is the same as the C function OGR_F_SetFieldString().

Parameters
iFieldthe field to fetch, from 0 to GetFieldCount()-1.
pszValuethe value to assign.

References CPLError(), CPLGetConfigOption(), CPLStrdup(), CPLStrtod(), CSLCount(), CSLDestroy(), CSLTestBoolean(), CSLTokenizeString2(), OGRFeatureDefn::GetFieldDefn(), OGRFeatureDefn::GetName(), OGRFieldDefn::GetNameRef(), OGRFieldDefn::GetType(), IsFieldSet(), OFTDate, OFTDateTime, OFTInteger, OFTIntegerList, OFTReal, OFTRealList, OFTString, OFTStringList, OFTTime, and SetField().

void OGRFeature::SetField ( int  iField,
int  nCount,
int *  panValues 
)

Set field to list of integers value.

This method currently on has an effect of OFTIntegerList fields.

This method is the same as the C function OGR_F_SetFieldIntegerList().

Parameters
iFieldthe field to set, from 0 to GetFieldCount()-1.
nCountthe number of values in the list being assigned.
panValuesthe values to assign.

References OGRFeatureDefn::GetFieldDefn(), OGRFieldDefn::GetType(), OFTInteger, OFTIntegerList, OFTReal, OFTRealList, and SetField().

void OGRFeature::SetField ( int  iField,
int  nCount,
double *  padfValues 
)

Set field to list of doubles value.

This method currently on has an effect of OFTRealList fields.

This method is the same as the C function OGR_F_SetFieldDoubleList().

Parameters
iFieldthe field to set, from 0 to GetFieldCount()-1.
nCountthe number of values in the list being assigned.
padfValuesthe values to assign.

References OGRFeatureDefn::GetFieldDefn(), OGRFieldDefn::GetType(), OFTInteger, OFTIntegerList, OFTReal, OFTRealList, and SetField().

void OGRFeature::SetField ( int  iField,
char **  papszValues 
)

Set field to list of strings value.

This method currently on has an effect of OFTStringList fields.

This method is the same as the C function OGR_F_SetFieldStringList().

Parameters
iFieldthe field to set, from 0 to GetFieldCount()-1.
papszValuesthe values to assign.

References CSLCount(), OGRFeatureDefn::GetFieldDefn(), OGRFieldDefn::GetType(), OFTStringList, and SetField().

void OGRFeature::SetField ( int  iField,
OGRField puValue 
)

Set field.

The passed value OGRField must be of exactly the same type as the target field, or an application crash may occur. The passed value is copied, and will not be affected. It remains the responsibility of the caller.

This method is the same as the C function OGR_F_SetFieldRaw().

Parameters
iFieldthe field to fetch, from 0 to GetFieldCount()-1.
puValuethe value to assign.

References CPLMalloc(), CPLStrdup(), CSLCount(), CSLDestroy(), CSLDuplicate(), OGRFeatureDefn::GetFieldDefn(), OGRFieldDefn::GetType(), IsFieldSet(), OFTBinary, OFTDate, OFTDateTime, OFTInteger, OFTIntegerList, OFTReal, OFTRealList, OFTString, OFTStringList, and OFTTime.

void OGRFeature::SetField ( int  iField,
int  nBytes,
GByte *  pabyData 
)

Set field to binary data.

This method currently on has an effect of OFTBinary fields.

This method is the same as the C function OGR_F_SetFieldBinary().

Parameters
iFieldthe field to set, from 0 to GetFieldCount()-1.
nBytesbytes of data being set.
pabyDatathe raw data being applied.

References OGRFeatureDefn::GetFieldDefn(), OGRFieldDefn::GetType(), OFTBinary, and SetField().

void OGRFeature::SetField ( int  iField,
int  nYear,
int  nMonth,
int  nDay,
int  nHour = 0,
int  nMinute = 0,
int  nSecond = 0,
int  nTZFlag = 0 
)

Set field to date.

This method currently only has an effect for OFTDate, OFTTime and OFTDateTime fields.

This method is the same as the C function OGR_F_SetFieldDateTime().

Parameters
iFieldthe field to set, from 0 to GetFieldCount()-1.
nYear(including century)
nMonth(1-12)
nDay(1-31)
nHour(0-23)
nMinute(0-59)
nSecond(0-59)
nTZFlag(0=unknown, 1=localtime, 100=GMT, see data model for details)

References CPLError(), OGRFeatureDefn::GetFieldDefn(), OGRFieldDefn::GetType(), OFTDate, OFTDateTime, and OFTTime.

OGRErr OGRFeature::SetFieldsFrom ( OGRFeature poSrcFeature,
int *  panMap,
int  bForgiving = TRUE 
)

Set fields from another feature.

Overwrite the fields of this feature from the attributes of another. The FID and the style string are not set. The poSrcFeature does not need to have the same OGRFeatureDefn. Field values are copied according to the provided indices map. Field types do not have to exactly match. SetField() method conversion rules will be applied as needed. This is more efficient than OGR_F_SetFrom() in that this doesn't lookup the fields by their names. Particularly useful when the field names don't match.

Parameters
poSrcFeaturethe feature from which geometry, and field values will be copied.
panMapArray of the indices of the feature's fields stored at the corresponding index of the source feature's fields. A value of -1 should be used to ignore the source's field. The array should not be NULL and be as long as the number of fields in the source feature.
bForgivingTRUE if the operation should continue despite lacking output fields matching some of the source fields.
Returns
OGRERR_NONE if the operation succeeds, even if some values are not transferred, otherwise an error code.

References GetFieldAsDouble(), GetFieldAsDoubleList(), GetFieldAsInteger(), GetFieldAsIntegerList(), GetFieldAsString(), GetFieldCount(), GetFieldDefnRef(), GetRawFieldRef(), OGRFieldDefn::GetType(), IsFieldSet(), OFTDate, OFTDateTime, OFTInteger, OFTIntegerList, OFTReal, OFTRealList, OFTString, OFTTime, SetField(), and UnsetField().

Referenced by OGRLayer::Clip(), OGRLayer::Erase(), OGRLayer::Identity(), OGRLayer::Intersection(), SetFrom(), OGRLayer::SymDifference(), OGRLayer::Union(), and OGRLayer::Update().

OGRErr OGRFeature::SetFrom ( OGRFeature poSrcFeature,
int  bForgiving = TRUE 
)

Set one feature from another.

Overwrite the contents of this feature from the geometry and attributes of another. The poSrcFeature does not need to have the same OGRFeatureDefn. Field values are copied by corresponding field names. Field types do not have to exactly match. SetField() method conversion rules will be applied as needed.

This method is the same as the C function OGR_F_SetFrom().

Parameters
poSrcFeaturethe feature from which geometry, and field values will be copied.
bForgivingTRUE if the operation should continue despite lacking output fields matching some of the source fields.
Returns
OGRERR_NONE if the operation succeeds, even if some values are not transferred, otherwise an error code.

References GetFieldCount(), GetFieldDefnRef(), GetFieldIndex(), and OGRFieldDefn::GetNameRef().

Referenced by OGRDataSource::CopyLayer(), OGRUnionLayer::CreateFeature(), OGRUnionLayer::SetFeature(), OGRUnionLayer::SetSpatialFilter(), and OGRWarpedLayer::SetSpatialFilterRect().

OGRErr OGRFeature::SetFrom ( OGRFeature poSrcFeature,
int *  panMap,
int  bForgiving = TRUE 
)

Set one feature from another.

Overwrite the contents of this feature from the geometry and attributes of another. The poSrcFeature does not need to have the same OGRFeatureDefn. Field values are copied according to the provided indices map. Field types do not have to exactly match. SetField() method conversion rules will be applied as needed. This is more efficient than OGR_F_SetFrom() in that this doesn't lookup the fields by their names. Particularly useful when the field names don't match.

This method is the same as the C function OGR_F_SetFromWithMap().

Parameters
poSrcFeaturethe feature from which geometry, and field values will be copied.
panMapArray of the indices of the feature's fields stored at the corresponding index of the source feature's fields. A value of -1 should be used to ignore the source's field. The array should not be NULL and be as long as the number of fields in the source feature.
bForgivingTRUE if the operation should continue despite lacking output fields matching some of the source fields.
Returns
OGRERR_NONE if the operation succeeds, even if some values are not transferred, otherwise an error code.

References GetGeomFieldCount(), GetGeomFieldDefnRef(), GetGeomFieldIndex(), GetGeomFieldRef(), OGRGeomFieldDefn::GetNameRef(), GetStyleString(), SetFID(), SetFieldsFrom(), SetGeomField(), and SetStyleString().

OGRErr OGRFeature::SetGeometry ( OGRGeometry poGeomIn)

Set feature geometry.

This method updates the features geometry, and operate exactly as SetGeometryDirectly(), except that this method does not assume ownership of the passed geometry, but instead makes a copy of it.

This method is the same as the C function OGR_F_SetGeometry().

Parameters
poGeomInnew geometry to apply to feature. Passing NULL value here is correct and it will result in deallocation of currently assigned geometry without assigning new one.
Returns
OGRERR_NONE if successful, or OGR_UNSUPPORTED_GEOMETRY_TYPE if the geometry type is illegal for the OGRFeatureDefn (checking not yet implemented).

References GetGeomFieldCount(), and SetGeomField().

Referenced by OGRLayer::Update().

OGRErr OGRFeature::SetGeometryDirectly ( OGRGeometry poGeomIn)

Set feature geometry.

This method updates the features geometry, and operate exactly as SetGeometry(), except that this method assumes ownership of the passed geometry (even in case of failure of that function).

This method is the same as the C function OGR_F_SetGeometryDirectly().

Parameters
poGeomInnew geometry to apply to feature. Passing NULL value here is correct and it will result in deallocation of currently assigned geometry without assigning new one.
Returns
OGRERR_NONE if successful, or OGR_UNSUPPORTED_GEOMETRY_TYPE if the geometry type is illegal for the OGRFeatureDefn (checking not yet implemented).

References GetGeomFieldCount(), and SetGeomFieldDirectly().

Referenced by OGRLayer::Clip(), OGRLayer::Erase(), OGRLayer::Identity(), OGRLayer::Intersection(), OGRGeocodeDestroySession(), OGRLayer::SymDifference(), OGRLayer::Union(), and OGRLayer::Update().

OGRErr OGRFeature::SetGeomField ( int  iField,
OGRGeometry poGeomIn 
)

Set feature geometry of a specified geometry field.

This method updates the features geometry, and operate exactly as SetGeomFieldDirectly(), except that this method does not assume ownership of the passed geometry, but instead makes a copy of it.

This method is the same as the C function OGR_F_SetGeomField().

Parameters
iFieldgeometry field to set.
poGeomInnew geometry to apply to feature. Passing NULL value here is correct and it will result in deallocation of currently assigned geometry without assigning new one.
Returns
OGRERR_NONE if successful, or OGRERR_FAILURE if the index is invalid, or OGR_UNSUPPORTED_GEOMETRY_TYPE if the geometry type is illegal for the OGRFeatureDefn (checking not yet implemented).
Since
GDAL 1.11

References OGRGeometry::clone(), and GetGeomFieldCount().

Referenced by Clone(), SetFrom(), SetGeometry(), and OGRGenSQLResultsLayer::TestCapability().

OGRErr OGRFeature::SetGeomFieldDirectly ( int  iField,
OGRGeometry poGeomIn 
)

Set feature geometry of a specified geometry field.

This method updates the features geometry, and operate exactly as SetGeomField(), except that this method assumes ownership of the passed geometry (even in case of failure of that function).

This method is the same as the C function OGR_F_SetGeomFieldDirectly().

Parameters
iFieldgeometry field to set.
poGeomInnew geometry to apply to feature. Passing NULL value here is correct and it will result in deallocation of currently assigned geometry without assigning new one.
Returns
OGRERR_NONE if successful, or OGRERR_FAILURE if the index is invalid, or OGR_UNSUPPORTED_GEOMETRY_TYPE if the geometry type is illegal for the OGRFeatureDefn (checking not yet implemented).
Since
GDAL 1.11

References GetGeomFieldCount().

Referenced by SetGeometryDirectly(), and OGRUnionLayer::SetSpatialFilter().

void OGRFeature::SetStyleString ( const char *  pszString)
virtual

Set feature style string. This method operate exactly as OGRFeature::SetStyleStringDirectly() except that it does not assume ownership of the passed string, but instead makes a copy of it.

This method is the same as the C function OGR_F_SetStyleString().

Parameters
pszStringthe style string to apply to this feature, cannot be NULL.

References CPLStrdup().

Referenced by Clone(), OGRStyleMgr::SetFeatureStyleString(), SetFrom(), and OGRGenSQLResultsLayer::TestCapability().

void OGRFeature::SetStyleStringDirectly ( char *  pszString)
virtual

Set feature style string. This method operate exactly as OGRFeature::SetStyleString() except that it assumes ownership of the passed string.

This method is the same as the C function OGR_F_SetStyleStringDirectly().

Parameters
pszStringthe style string to apply to this feature, cannot be NULL.
OGRGeometry * OGRFeature::StealGeometry ( )

Take away ownership of geometry.

Fetch the geometry from this feature, and clear the reference to the geometry on the feature. This is a mechanism for the application to take over ownship of the geometry from the feature without copying. Sort of an inverse to SetGeometryDirectly().

After this call the OGRFeature will have a NULL geometry.

Returns
the pointer to the geometry.

References GetGeomFieldCount().

Referenced by OGRWarpedLayer::SetSpatialFilterRect().

void OGRFeature::UnsetField ( int  iField)

Clear a field, marking it as unset.

This method is the same as the C function OGR_F_UnsetField().

Parameters
iFieldthe field to unset.

References CSLDestroy(), OGRFeatureDefn::GetFieldDefn(), OGRFieldDefn::GetType(), IsFieldSet(), OFTBinary, OFTIntegerList, OFTRealList, OFTString, and OFTStringList.

Referenced by SetFieldsFrom().


The documentation for this class was generated from the following files:

Generated for GDAL by doxygen 1.8.11.