GDAL
OGRGeomFieldDefn Class Reference

Definition of a geometry field of an OGRFeatureDefn. More...

#include <ogr_feature.h>

Public Member Functions

 OGRGeomFieldDefn (const char *pszNameIn, OGRwkbGeometryType eGeomTypeIn)
 Constructor.
 OGRGeomFieldDefn (const OGRGeomFieldDefn *)
 Constructor.
 OGRGeomFieldDefn (const OGRGeomFieldDefn &oOther)
 OGRGeomFieldDefn::OGRGeomFieldDefn Copy constructor.
OGRGeomFieldDefnoperator= (const OGRGeomFieldDefn &oOther)
 Copy assignment operator.
void SetName (const char *)
 Reset the name of this field.
const char * GetNameRef () const
 Fetch name of this field.
OGRwkbGeometryType GetType () const
 Fetch geometry type of this field.
void SetType (OGRwkbGeometryType eTypeIn)
 Set the geometry type of this field.
virtual const OGRSpatialReferenceGetSpatialRef () const
 Fetch spatial reference system of this field.
void SetSpatialRef (const OGRSpatialReference *poSRSIn)
 Set the spatial reference of this field.
int IsIgnored () const
 Return whether this field should be omitted when fetching features.
void SetIgnored (int bIgnoreIn)
 Set whether this field should be omitted when fetching features.
int IsNullable () const
 Return whether this geometry field can receive null values.
void SetNullable (int bNullableIn)
 Set whether this geometry field can receive null values.
const OGRGeomCoordinatePrecisionGetCoordinatePrecision () const
 Return the coordinate precision associated to this geometry field.
void SetCoordinatePrecision (const OGRGeomCoordinatePrecision &prec)
 Set coordinate precision associated to this geometry field.
int IsSame (const OGRGeomFieldDefn *) const
 Test if the geometry field definition is identical to the other one.
void Seal ()
 Seal a OGRGeomFieldDefn.
void Unseal ()
 Unseal a OGRGeomFieldDefn.
TemporaryUnsealer GetTemporaryUnsealer ()
 Return an object that temporary unseals the OGRGeomFieldDefn.

Static Public Member Functions

static OGRGeomFieldDefnH ToHandle (OGRGeomFieldDefn *poGeomFieldDefn)
 Convert a OGRGeomFieldDefn* to a OGRGeomFieldDefnH.
static OGRGeomFieldDefnFromHandle (OGRGeomFieldDefnH hGeomFieldDefn)
 Convert a OGRGeomFieldDefnH to a OGRGeomFieldDefn*.

Detailed Description

Definition of a geometry field of an OGRFeatureDefn.

A geometry field is described by :

Note that once a OGRGeomFieldDefn has been added to a layer definition with OGRLayer::AddGeomFieldDefn(), its setter methods should not be called on the object returned with OGRLayer::GetLayerDefn()->GetGeomFieldDefn(). Instead, OGRLayer::AlterGeomFieldDefn() should be called on a new instance of OGRFieldDefn, for drivers that support AlterFieldDefn().

Constructor & Destructor Documentation

◆ OGRGeomFieldDefn() [1/3]

OGRGeomFieldDefn::OGRGeomFieldDefn ( const char * pszNameIn,
OGRwkbGeometryType eGeomTypeIn )

Constructor.

Parameters
pszNameInthe name of the new field.
eGeomTypeInthe type of the new field.

◆ OGRGeomFieldDefn() [2/3]

OGRGeomFieldDefn::OGRGeomFieldDefn ( const OGRGeomFieldDefn * poPrototype)
explicit

Constructor.

Create by cloning an existing geometry field definition.

Parameters
poPrototypethe geometry field definition to clone.

◆ OGRGeomFieldDefn() [3/3]

OGRGeomFieldDefn::OGRGeomFieldDefn ( const OGRGeomFieldDefn & oOther)

OGRGeomFieldDefn::OGRGeomFieldDefn Copy constructor.

Parameters
oOtherthe OGRGeomFieldDefn to copy.
Since
GDAL 3.11

Member Function Documentation

◆ GetCoordinatePrecision()

const OGRGeomCoordinatePrecision & OGRGeomFieldDefn::GetCoordinatePrecision ( ) const
inline

Return the coordinate precision associated to this geometry field.

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

Returns
the coordinate precision
Since
GDAL 3.9

◆ GetNameRef()

const char * OGRGeomFieldDefn::GetNameRef ( ) const
inline

Fetch name of this field.

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

Returns
pointer to an internal name string that should not be freed or modified.

◆ GetSpatialRef()

const OGRSpatialReference * OGRGeomFieldDefn::GetSpatialRef ( ) const
virtual

Fetch spatial reference system of this field.

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

Returns
field spatial reference system.

◆ GetTemporaryUnsealer()

OGRGeomFieldDefn::TemporaryUnsealer OGRGeomFieldDefn::GetTemporaryUnsealer ( )

Return an object that temporary unseals the OGRGeomFieldDefn.

The returned object calls Unseal() initially, and when it is destroyed it calls Seal().

This method should only be called by driver implementations.

It is also possible to use the helper method whileUnsealing(). Example: whileUnsealing(poGeomFieldDefn)->some_method()

Since
GDAL 3.9

◆ GetType()

OGRwkbGeometryType OGRGeomFieldDefn::GetType ( ) const
inline

Fetch geometry type of this field.

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

Returns
field geometry type.

◆ IsIgnored()

int OGRGeomFieldDefn::IsIgnored ( ) const
inline

Return whether this field should be omitted when fetching features.

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

Returns
ignore state

◆ IsNullable()

int OGRGeomFieldDefn::IsNullable ( ) const
inline

Return whether this geometry field can receive null values.

By default, fields are nullable.

Even if this method returns FALSE (i.e not-nullable field), it doesn't mean that OGRFeature::IsFieldSet() will necessary return TRUE, as fields can be temporary unset and null/not-null validation is usually done when OGRLayer::CreateFeature()/SetFeature() is called.

Note that not-nullable geometry fields might also contain 'empty' geometries.

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

Returns
TRUE if the field is authorized to be null.

◆ IsSame()

int OGRGeomFieldDefn::IsSame ( const OGRGeomFieldDefn * poOtherFieldDefn) const

Test if the geometry field definition is identical to the other one.

Parameters
poOtherFieldDefnthe other field definition to compare to.
Returns
TRUE if the geometry field definition is identical to the other one.

◆ operator=()

OGRGeomFieldDefn & OGRGeomFieldDefn::operator= ( const OGRGeomFieldDefn & oOther)

Copy assignment operator.

Parameters
oOtherthe OGRGeomFieldDefn to copy.
Returns
a reference to the current object.
Since
GDAL 3.11

◆ Seal()

void OGRGeomFieldDefn::Seal ( )

Seal a OGRGeomFieldDefn.

A sealed OGRGeomFieldDefn can not be modified while it is sealed.

This method should only be called by driver implementations.

Since
GDAL 3.9

◆ SetCoordinatePrecision()

void OGRGeomFieldDefn::SetCoordinatePrecision ( const OGRGeomCoordinatePrecision & prec)

Set coordinate precision associated to this geometry field.

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

Note that once a OGRGeomFieldDefn has been added to a layer definition with OGRLayer::AddGeomFieldDefn(), its setter methods should not be called on the object returned with OGRLayer::GetLayerDefn() const->GetGeomFieldDefn().

Parameters
precCoordinate precision
Since
GDAL 3.9

◆ SetIgnored()

void OGRGeomFieldDefn::SetIgnored ( int ignore)
inline

Set whether this field should be omitted when fetching features.

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

This method should not be called on a object returned with OGRLayer::GetLayerDefn() const->GetGeomFieldDefn(). Instead, the OGRLayer::SetIgnoredFields() method should be called.

Parameters
ignoreignore state

◆ SetName()

void OGRGeomFieldDefn::SetName ( const char * pszNameIn)

Reset the name of this field.

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

Note that once a OGRGeomFieldDefn has been added to a layer definition with OGRLayer::AddGeomFieldDefn(), its setter methods should not be called on the object returned with OGRLayer::GetLayerDefn() const->GetGeomFieldDefn(). Instead, OGRLayer::AlterGeomFieldDefn() should be called on a new instance of OGRFieldDefn, for drivers that support AlterFieldDefn().

Parameters
pszNameInthe new name to apply.

◆ SetNullable()

void OGRGeomFieldDefn::SetNullable ( int bNullableIn)

Set whether this geometry field can receive null values.

By default, fields are nullable, so this method is generally called with FALSE to set a not-null constraint.

Drivers that support writing not-null constraint will advertise the GDAL_DCAP_NOTNULL_GEOMFIELDS driver metadata item.

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

Note that once a OGRGeomFieldDefn has been added to a layer definition with OGRLayer::AddGeomFieldDefn(), its setter methods should not be called on the object returned with OGRLayer::GetLayerDefn() const->GetGeomFieldDefn(). Instead, OGRLayer::AlterGeomFieldDefn() should be called on a new instance of OGRFieldDefn, for drivers that support AlterFieldDefn().

Parameters
bNullableInFALSE if the field must have a not-null constraint.

◆ SetSpatialRef()

void OGRGeomFieldDefn::SetSpatialRef ( const OGRSpatialReference * poSRSIn)

Set the spatial reference of this field.

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

This method drops the reference of the previously set SRS object and acquires a new reference on the passed object (if non-NULL).

Note that once a OGRGeomFieldDefn has been added to a layer definition with OGRLayer::AddGeomFieldDefn(), its setter methods should not be called on the object returned with OGRLayer::GetLayerDefn() const->GetGeomFieldDefn(). Instead, OGRLayer::AlterGeomFieldDefn() should be called on a new instance of OGRFieldDefn, for drivers that support AlterFieldDefn().

Parameters
poSRSInthe new SRS to apply.

◆ SetType()

void OGRGeomFieldDefn::SetType ( OGRwkbGeometryType eTypeIn)

Set the geometry type of this field.

This should never be done to an OGRGeomFieldDefn that is already part of an OGRFeatureDefn.

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

Note that once a OGRGeomFieldDefn has been added to a layer definition with OGRLayer::AddGeomFieldDefn(), its setter methods should not be called on the object returned with OGRLayer::GetLayerDefn() const->GetGeomFieldDefn(). Instead, OGRLayer::AlterGeomFieldDefn() should be called on a new instance of OGRFieldDefn, for drivers that support AlterFieldDefn().

Parameters
eTypeInthe new field geometry type.

◆ Unseal()

void OGRGeomFieldDefn::Unseal ( )

Unseal a OGRGeomFieldDefn.

Undo OGRGeomFieldDefn::Seal()

Using GetTemporaryUnsealer() is recommended for most use cases.

This method should only be called by driver implementations.

Since
GDAL 3.9

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