OGRFeatureDefn Class Reference

#include <ogr_feature.h>

List of all members.

Public Member Functions

 OGRFeatureDefn (const char *pszName=NULL)
 Constructor.
const char * GetName ()
 Get name of this OGRFeatureDefn.
int GetFieldCount ()
 Fetch number of fields on this feature.
OGRFieldDefnGetFieldDefn (int i)
 Fetch field definition.
int GetFieldIndex (const char *)
 Find field by name.
void AddFieldDefn (OGRFieldDefn *)
 Add a new field definition.
OGRwkbGeometryType GetGeomType ()
 Fetch the geometry base type.
void SetGeomType (OGRwkbGeometryType)
 Assign the base geometry type for this layer.
OGRFeatureDefnClone ()
 Create a copy of this feature definition.
int Reference ()
 Increments the reference count by one.
int Dereference ()
 Decrements the reference count by one.
int GetReferenceCount ()
 Fetch current reference count.
void Release ()
 Drop a reference to this object, and destroy if no longer referenced.


Detailed Description

Definition of a feature class or feature layer.

This object contains schema information for a set of OGRFeatures. In table based systems, an OGRFeatureDefn is essentially a layer. In more object oriented approaches (such as SF CORBA) this can represent a class of features but doesn't necessarily relate to all of a layer, or just one layer.

This object also can contain some other information such as a name, the base geometry type and potentially other metadata.

It is reasonable for different translators to derive classes from OGRFeatureDefn with additional translator specific information.


Constructor & Destructor Documentation

OGRFeatureDefn::OGRFeatureDefn ( const char *  pszName = NULL  ) 

Constructor.

The OGRFeatureDefn maintains a reference count, but this starts at zero. It is mainly intended to represent a count of OGRFeature's based on this definition.

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

Parameters:
pszName the name to be assigned to this layer/class. It does not need to be unique.

References wkbUnknown.

Referenced by Clone().


Member Function Documentation

void OGRFeatureDefn::AddFieldDefn ( OGRFieldDefn poNewDefn  ) 

Add a new field definition.

This method should only be called while there are no OGRFeature objects in existance based on this OGRFeatureDefn. The OGRFieldDefn passed in is copied, and remains the responsibility of the caller.

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

Parameters:
poNewDefn the definition of the new field.

Referenced by Clone().

OGRFeatureDefn * OGRFeatureDefn::Clone (  ) 

Create a copy of this feature definition.

Creates a deep copy of the feature definition.

Returns:
the copy.

References AddFieldDefn(), GetFieldCount(), GetFieldDefn(), GetGeomType(), GetName(), OGRFeatureDefn(), and SetGeomType().

int OGRFeatureDefn::Dereference (  )  [inline]

Decrements the reference count by one.

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

Returns:
the updated reference count.

Referenced by Release().

int OGRFeatureDefn::GetFieldCount (  )  [inline]

OGRFieldDefn * OGRFeatureDefn::GetFieldDefn ( int  iField  ) 

Fetch field definition.

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

Starting with GDAL 1.7.0, this method will also issue an error if the index is not valid.

Parameters:
iField the field to fetch, between 0 and GetFieldCount()-1.
Returns:
a pointer to an internal field definition object or NULL if invalid index. This object should not be modified or freed by the application.

Referenced by Clone(), OGRDataSource::CopyLayer(), OGRFeature::DumpReadable(), OGRFeature::Equal(), OGRDataSource::ExecuteSQL(), OGRFeature::GetFieldAsBinary(), OGRFeature::GetFieldAsDateTime(), OGRFeature::GetFieldAsDouble(), OGRFeature::GetFieldAsDoubleList(), OGRFeature::GetFieldAsInteger(), OGRFeature::GetFieldAsIntegerList(), OGRFeature::GetFieldAsString(), OGRFeature::GetFieldAsStringList(), OGRFeature::SetField(), and OGRFeature::UnsetField().

int OGRFeatureDefn::GetFieldIndex ( const char *  pszFieldName  ) 

Find field by name.

The field index of the first field matching the passed field name (case insensitively) is returned.

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

Parameters:
pszFieldName the field name to search for.
Returns:
the field index, or -1 if no match found.

OGRwkbGeometryType OGRFeatureDefn::GetGeomType (  )  [inline]

Fetch the geometry base type.

Note that some drivers are unable to determine a specific geometry type for a layer, in which case wkbUnknown is returned. A value of wkbNone indicates no geometry is available for the layer at all. Many drivers do not properly mark the geometry type as 25D even if some or all geometries are in fact 25D. A few (broken) drivers return wkbPolygon for layers that also include wkbMultiPolygon.

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

Returns:
the base type for all geometry related to this definition.

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

const char * OGRFeatureDefn::GetName (  )  [inline]

Get name of this OGRFeatureDefn.

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

Returns:
the name. This name is internal and should not be modified, or freed.

Referenced by Clone(), OGRSFDriver::CopyDataSource(), OGRDataSource::CopyLayer(), OGRFeature::DumpReadable(), and OGRDataSource::GetLayerByName().

int OGRFeatureDefn::GetReferenceCount (  )  [inline]

Fetch current reference count.

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

Returns:
the current reference count.

int OGRFeatureDefn::Reference (  )  [inline]

Increments the reference count by one.

The reference count is used keep track of the number of OGRFeature objects referencing this definition.

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

Returns:
the updated reference count.

Referenced by OGRFeature::OGRFeature().

void OGRFeatureDefn::SetGeomType ( OGRwkbGeometryType  eNewType  ) 

Assign the base geometry type for this layer.

All geometry objects using this type must be of the defined type or a derived type. The default upon creation is wkbUnknown which allows for any geometry type. The geometry type should generally not be changed after any OGRFeatures have been created against this definition.

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

Parameters:
eNewType the new type to assign.

Referenced by Clone().


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

Generated for GDAL by doxygen 1.5.7.1.