# OGRFeature C++ API

## OGRFeature class

class OGRFeature

  A simple feature, including geometry and attributes.

  Public Functions

  explicit OGRFeature(OGRFeatureDefn*)

    Constructor.

    Note that the OGRFeature will increment the reference count of its 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:

      poDefnIn -- feature class (layer) definition to which the feature will adhere.

  ConstFieldIterator begin() const

    Return begin of field value iterator.

    Using this iterator for standard range-based loops is safe, but due to implementation limitations, you shouldn't try to access (dereference) more than one iterator step at a time, since you will get a reference to the same object (FieldValue) at each iteration step.

    Since

      GDAL 2.3

  ConstFieldIterator end() const

    Return end of field value iterator.

  const FieldValue operator[](int iField) const

    Return a field value.

    Since

      GDAL 2.3

    Parameters:

      iField -- the field to fetch, from 0 to GetFieldCount()-1. This is not checked by the method !

    Returns:

      the field value.

  FieldValue operator[](int iField)

    Return a field value.

    Since

      GDAL 2.3

    Parameters:

      iField -- the field to fetch, from 0 to GetFieldCount()-1. This is not checked by the method !

    Returns:

      the field value.

  const FieldValue operator[](const char *pszFieldName) const

    Return a field value.

    Since

      GDAL 2.3

    Parameters:

      pszFieldName -- field name

    Returns:

      the field value, or throw a FieldNotFoundException if not found.

  FieldValue operator[](const char *pszFieldName)

    Return a field value.

    Since

      GDAL 2.3

    Parameters:

      pszFieldName -- field name

    Returns:

      the field value, or throw a FieldNotFoundException if not found.

  inline OGRFeatureDefn *GetDefnRef()

    Fetch feature definition.

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

    Returns:

      a reference to the feature definition object.

  inline const OGRFeatureDefn *GetDefnRef() const

    Fetch feature definition.

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

    Since

      GDAL 2.3

    Returns:

      a reference to the feature definition object.

  OGRErr SetGeometryDirectly(OGRGeometry*)

    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().

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      poGeomIn -- new 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).

  OGRErr SetGeometry(const OGRGeometry*)

    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().

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      poGeomIn -- new 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).

  OGRGeometry *GetGeometryRef()

    Fetch pointer to feature geometry.

    This method is essentially the same as the C function OGR_F_GetGeometryRef(). (the only difference is that the C function honours OGRGetNonLinearGeometriesEnabledFlag())

    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.

  const OGRGeometry *GetGeometryRef() const

    Fetch pointer to feature geometry.

    This method is essentially the same as the C function OGR_F_GetGeometryRef(). (the only difference is that the C function honours OGRGetNonLinearGeometriesEnabledFlag())

    Since

      GDAL 2.3

    Returns:

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

  OGRGeometry *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 ownership 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.

  inline int GetGeomFieldCount() const

    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().

    Since

      GDAL 1.11

    Returns:

      count of geometry fields.

  inline OGRGeomFieldDefn *GetGeomFieldDefnRef(int iField)

    Fetch definition for this geometry field.

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

    Since

      GDAL 1.11

    Parameters:

      iGeomField -- the 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.

  inline const OGRGeomFieldDefn *GetGeomFieldDefnRef(int iField) const

    Fetch definition for this geometry field.

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

    Since

      GDAL 2.3

    Parameters:

      iGeomField -- the 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.

  inline int GetGeomFieldIndex(const char *pszName) const

    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().

    Since

      GDAL 1.11

    Parameters:

      pszName -- the name of the geometry field to search for.

    Returns:

      the geometry field index, or -1 if no matching geometry field is found.

  OGRGeometry *GetGeomFieldRef(int iField)

    Fetch pointer to feature geometry.

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

    Since

      GDAL 1.11

    Parameters:

      iField -- geometry field to get.

    Returns:

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

  const OGRGeometry *GetGeomFieldRef(int iField) const

    Fetch pointer to feature geometry.

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

    Since

      GDAL 2.3

    Parameters:

      iField -- geometry field to get.

    Returns:

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

  OGRGeometry *StealGeometry(int iField)

    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 ownership of the geometry from the feature without copying. Sort of an inverse to SetGeometryDirectly().

    After this call the OGRFeature will have a NULL geometry.

    Parameters:

      iGeomField -- index of the geometry field.

    Returns:

      the pointer to the geometry.

  OGRGeometry *GetGeomFieldRef(const char *pszFName)

    Fetch pointer to feature geometry.

    Since

      GDAL 1.11

    Parameters:

      pszFName -- name of geometry field to get.

    Returns:

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

  const OGRGeometry *GetGeomFieldRef(const char *pszFName) const

    Fetch pointer to feature geometry.

    Since

      GDAL 2.3

    Parameters:

      pszFName -- name of geometry field to get.

    Returns:

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

  OGRErr SetGeomFieldDirectly(int iField, OGRGeometry*)

    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().

    Since

      GDAL 1.11

    Parameters:

      - iField -- geometry field to set.

      - poGeomIn -- new 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 OGRERR_UNSUPPORTED_GEOMETRY_TYPE if the geometry type is illegal for the OGRFeatureDefn (checking not yet implemented).

  OGRErr SetGeomField(int iField, const OGRGeometry*)

    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().

    Since

      GDAL 1.11

    Parameters:

      - iField -- geometry field to set.

      - poGeomIn -- new 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).

  void Reset()

    Reset the state of a OGRFeature to its state after construction.

    This enables recycling existing OGRFeature instances.

    Since

      GDAL 3.5

  OGRFeature *Clone() const

    Duplicate feature.

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

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

    Returns:

      new feature, exactly matching this feature. Or, starting with GDAL 2.1, NULL in case of out of memory situation.

  virtual OGRBoolean Equal(const OGRFeature *poFeature) const

    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:

      poFeature -- the other feature to test this one against.

    Returns:

      TRUE if they are equal, otherwise FALSE.

  inline int GetFieldCount() const

    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.

  inline const OGRFieldDefn *GetFieldDefnRef(int iField) const

    Fetch definition for this field.

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

    Since

      GDAL 2.3

    Parameters:

      iField -- the 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.

  inline OGRFieldDefn *GetFieldDefnRef(int iField)

    Fetch definition for this field.

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

    Parameters:

      iField -- the 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.

  inline int GetFieldIndex(const char *pszName) const

    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:

      pszName -- the name of the field to search for.

    Returns:

      the field index, or -1 if no matching field is found.

  int IsFieldSet(int iField) const

    Test if a field has ever been assigned a value or not.

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

    Parameters:

      iField -- the field to test.

    Returns:

      TRUE if the field has been set, otherwise false.

  void UnsetField(int iField)

    Clear a field, marking it as unset.

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

    Parameters:

      iField -- the field to unset.

  bool IsFieldNull(int iField) const

    Test if a field is null.

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

    Since

      GDAL 2.2

    Parameters:

      iField -- the field to test.

    Returns:

      TRUE if the field is null, otherwise false.

  void SetFieldNull(int iField)

    Clear a field, marking it as null.

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

    Since

      GDAL 2.2

    Parameters:

      iField -- the field to set to null.

  bool IsFieldSetAndNotNull(int iField) const

    Test if a field is set and not null.

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

    Since

      GDAL 2.2

    Parameters:

      iField -- the field to test.

    Returns:

      TRUE if the field is set and not null, otherwise false.

  inline OGRField *GetRawFieldRef(int i)

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

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

    Parameters:

      iField -- the 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.

  inline const OGRField *GetRawFieldRef(int i) const

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

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

    Since

      GDAL 2.3

    Parameters:

      iField -- the 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.

  int GetFieldAsInteger(int i) const

    Fetch field value as integer.

    OFTString features will be translated using atoi(). OFTReal fields will be cast to integer. OFTInteger64 are demoted to 32 bit, with clamping if out-of-range. 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:

      iField -- the field to fetch, from 0 to GetFieldCount()-1.

    Returns:

      the field value.

  GIntBig GetFieldAsInteger64(int i) const

    Fetch field value as integer 64 bit.

    OFTInteger are promoted to 64 bit. OFTString features will be translated using CPLAtoGIntBig(). 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_GetFieldAsInteger64().

    Since

      GDAL 2.0

    Parameters:

      iField -- the field to fetch, from 0 to GetFieldCount()-1.

    Returns:

      the field value.

  double GetFieldAsDouble(int i) const

    Fetch field value as a double.

    OFTString features will be translated using CPLAtof(). OFTInteger and OFTInteger64 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:

      iField -- the field to fetch, from 0 to GetFieldCount()-1.

    Returns:

      the field value.

  const char *GetFieldAsString(int i) const

    Fetch field value as a string.

    OFTReal, OFTInteger, OFTInteger64 fields will be translated to string using sprintf(), but not necessarily using the established formatting rules. OFTDateTime fields are formatted with "YYYY/MM/DD HH:MM:SS[.sss]+ZZ" (note this is not a ISO-8601 compliant string. Use GetFieldAsISO8601DateTime()) OFTDate fields are formatted as "YYYY/MM/DD" OFTTime fields are formatted as "HH:MM:SS[.sss]" OFTRealList, OFTIntegerList, OFTInteger64List, OFTStringList fields are formatted as "(number_of_values:val1,val2,...,valN)" OFTBinary fields are formatted as an hexadecimal representation. Other field types, or errors will result in a return of an empty string.

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

    Parameters:

      iField -- the 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.

  const char *GetFieldAsISO8601DateTime(int i, CSLConstList papszOptions) const

    Fetch OFTDateTime field value as a ISO8601 representation.

    Return a string like "YYYY-MM-DDTHH:MM:SS(.sss)?(Z|([+|-]HH:MM))?" Milliseconds are omitted if equal to zero. Other field types, or errors will result in a return of an empty string.

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

    Since

      GDAL 3.7

    Parameters:

      - iField -- the field to fetch, from 0 to GetFieldCount()-1.

      - papszOptions -- NULL terminated list of strings, or NULL. No options are defined currently.

    Returns:

      the field value. This string is internal, and should not be modified, or freed. Its lifetime may be very brief.

  const int *GetFieldAsIntegerList(int i, int *pnCount) const

    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:

      - iField -- the field to fetch, from 0 to GetFieldCount()-1.

      - pnCount -- an 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.

  const GIntBig *GetFieldAsInteger64List(int i, int *pnCount) const

    Fetch field value as a list of 64 bit integers.

    Currently this method only works for OFTInteger64List fields.

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

    Since

      GDAL 2.0

    Parameters:

      - iField -- the field to fetch, from 0 to GetFieldCount()-1.

      - pnCount -- an 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.

  const double *GetFieldAsDoubleList(int i, int *pnCount) const

    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:

      - iField -- the field to fetch, from 0 to GetFieldCount()-1.

      - pnCount -- an 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.

  char **GetFieldAsStringList(int i) const

    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:

      iField -- the 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.

  GByte *GetFieldAsBinary(int i, int *pnCount) const

    Fetch field value as binary data.

    This method only works for OFTBinary and OFTString fields.

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

    Parameters:

      - iField -- the field to fetch, from 0 to GetFieldCount()-1.

      - pnBytes -- location 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.

  int GetFieldAsDateTime(int i, int *pnYear, int *pnMonth, int *pnDay, int *pnHour, int *pnMinute, int *pnSecond, int *pnTZFlag) const

    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:

      - iField -- the 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.

  int GetFieldAsDateTime(int i, int *pnYear, int *pnMonth, int *pnDay, int *pnHour, int *pnMinute, float *pfSecond, int *pnTZFlag) const

    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:

      - iField -- the field to fetch, from 0 to GetFieldCount()-1.

      - pnYear -- (including century)

      - pnMonth -- (1-12)

      - pnDay -- (1-31)

      - pnHour -- (0-23)

      - pnMinute -- (0-59)

      - pfSecond -- (0-59 with millisecond accuracy)

      - pnTZFlag -- (0=unknown, 1=localtime, 100=GMT, see data model for details)

    Returns:

      TRUE on success or FALSE on failure.

  char *GetFieldAsSerializedJSon(int i) const

    Fetch field value as a serialized JSon object.

    Currently this method only works for OFTString with OFSTJSON subtype, OFTStringList, OFTIntegerList, OFTInteger64List and OFTRealList

    Since

      GDAL 2.2

    Parameters:

      iField -- the field to fetch, from 0 to GetFieldCount()-1.

    Returns:

      a string that must be de-allocate with CPLFree()

  inline int GetFieldAsInteger(const char *pszFName) const

    Fetch field value as integer.

    OFTString features will be translated using atoi(). OFTReal fields will be cast to integer. OFTInteger64 are demoted to 32 bit, with clamping if out-of-range. Other field types, or errors will result in a return value of zero.

    Parameters:

      pszFName -- the name of the field to fetch.

    Returns:

      the field value.

  inline GIntBig GetFieldAsInteger64(const char *pszFName) const

    Fetch field value as integer 64 bit.

    OFTInteger are promoted to 64 bit. OFTString features will be translated using CPLAtoGIntBig(). OFTReal fields will be cast to integer. Other field types, or errors will result in a return value of zero.

    Parameters:

      pszFName -- the name of the field to fetch.

    Returns:

      the field value.

  inline double GetFieldAsDouble(const char *pszFName) const

    Fetch field value as a double.

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

    Parameters:

      pszFName -- the name of the field to fetch.

    Returns:

      the field value.

  inline const char *GetFieldAsString(const char *pszFName) const

    Fetch field value as a string.

    OFTReal, OFTInteger, OFTInteger64 fields will be translated to string using sprintf(), but not necessarily using the established formatting rules. OFTDateTime fields are formatted with "YYYY/MM/DD HH:MM:SS[.sss]+ZZ" (note this is not a ISO-8601 compliant string. Use GetFieldAsISO8601DateTime()) OFTDate fields are formatted as "YYYY/MM/DD" OFTTime fields are formatted as "HH:MM:SS[.sss]" OFTRealList, OFTIntegerList, OFTInteger64List, OFTStringList fields are formatted as "(number_of_values:val1,val2,...,valN)" OFTBinary fields are formatted as an hexadecimal representation. Other field types, or errors will result in a return of an empty string.

    Parameters:

      pszFName -- the name of the field to fetch.

    Returns:

      the field value. This string is internal, and should not be modified, or freed. Its lifetime may be very brief.

  inline const char *GetFieldAsISO8601DateTime(const char *pszFName, CSLConstList papszOptions) const

    Fetch OFTDateTime field value as a ISO8601 representation.

    Return a string like "YYYY-MM-DDTHH:MM:SS(.sss)?(Z|([+|-]HH:MM))?" Milliseconds are omitted if equal to zero. Other field types, or errors will result in a return of an empty string.

    Since

      GDAL 3.7

    Parameters:

      - pszFName -- the name of the field to fetch.

      - papszOptions -- NULL terminated list of strings, or NULL. No options are defined currently.

    Returns:

      the field value. This string is internal, and should not be modified, or freed. Its lifetime may be very brief.

  inline const int *GetFieldAsIntegerList(const char *pszFName, int *pnCount) const

    Fetch field value as a list of integers.

    Currently this method only works for OFTIntegerList fields.

    Parameters:

      - pszFName -- the name of the field to fetch.

      - pnCount -- an 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. 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.

  inline const GIntBig *GetFieldAsInteger64List(const char *pszFName, int *pnCount) const

    Fetch field value as a list of 64 bit integers.

    Currently this method only works for OFTInteger64List fields.

    Since

      GDAL 2.0

    Parameters:

      - pszFName -- the name of the field to fetch.

      - pnCount -- an 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.

  inline const double *GetFieldAsDoubleList(const char *pszFName, int *pnCount) const

    Fetch field value as a list of doubles.

    Currently this method only works for OFTRealList fields.

    Parameters:

      - pszFName -- the name of the field to fetch.

      - pnCount -- an 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.

  inline char **GetFieldAsStringList(const char *pszFName) const

    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().

    Parameters:

      pszFName -- the name of the field to fetch.

    Returns:

      the field value. This list is internal, and should not be modified, or freed. Its lifetime may be very brief.

  void SetField(int i, int nValue)

    Set field to integer value.

    OFTInteger, OFTInteger64 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().

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - iField -- the field to fetch, from 0 to GetFieldCount()-1.

      - nValue -- the value to assign.

  void SetField(int i, GIntBig nValue)

    Set field to 64 bit integer value.

    OFTInteger, OFTInteger64 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_SetFieldInteger64().

    Since

      GDAL 2.0

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - iField -- the field to fetch, from 0 to GetFieldCount()-1.

      - nValue -- the value to assign.

  void SetField(int i, double dfValue)

    Set field to double value.

    OFTInteger, OFTInteger64 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().

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - iField -- the field to fetch, from 0 to GetFieldCount()-1.

      - dfValue -- the value to assign.

  void SetField(int i, const char *pszValue)

    Set field to string value.

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

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

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - iField -- the field to fetch, from 0 to GetFieldCount()-1.

      - pszValue -- the value to assign.

  void SetField(int i, int nCount, const int *panValues)

    Set field to list of integers value.

    This method currently on has an effect of OFTIntegerList, OFTInteger64List and OFTRealList fields.

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

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - iField -- the field to set, from 0 to GetFieldCount()-1.

      - nCount -- the number of values in the list being assigned.

      - panValues -- the values to assign.

  void SetField(int i, int nCount, const GIntBig *panValues)

    Set field to list of 64 bit integers value.

    This method currently on has an effect of OFTIntegerList, OFTInteger64List and OFTRealList fields.

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

    Since

      GDAL 2.0

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - iField -- the field to set, from 0 to GetFieldCount()-1.

      - nCount -- the number of values in the list being assigned.

      - panValues -- the values to assign.

  void SetField(int i, int nCount, const double *padfValues)

    Set field to list of doubles value.

    This method currently on has an effect of OFTIntegerList, OFTInteger64List, OFTRealList fields.

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

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - iField -- the field to set, from 0 to GetFieldCount()-1.

      - nCount -- the number of values in the list being assigned.

      - padfValues -- the values to assign.

  void SetField(int i, const char *const *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().

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - iField -- the field to set, from 0 to GetFieldCount()-1.

      - papszValues -- the values to assign. List of NUL-terminated string, ending with a NULL pointer.

  void SetField(int i, const 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().

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - iField -- the field to fetch, from 0 to GetFieldCount()-1.

      - puValue -- the value to assign.

  void SetField(int i, int nCount, const void *pabyBinary)

    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().

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - iField -- the field to set, from 0 to GetFieldCount()-1.

      - nBytes -- bytes of data being set.

      - pabyData -- the raw data being applied.

  void SetField(int i, int nYear, int nMonth, int nDay, int nHour = 0, int nMinute = 0, float fSecond = 0.f, 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().

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - iField -- the field to set, from 0 to GetFieldCount()-1.

      - nYear -- (including century)

      - nMonth -- (1-12)

      - nDay -- (1-31)

      - nHour -- (0-23)

      - nMinute -- (0-59)

      - fSecond -- (0-59, with millisecond accuracy)

      - nTZFlag -- (0=unknown, 1=localtime, 100=GMT, see data model for details)

  inline void SetField(const char *pszFName, int nValue)

    Set field to integer value.

    OFTInteger, OFTInteger64 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.

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - pszFName -- the name of the field to set.

      - nValue -- the value to assign.

  inline void SetField(const char *pszFName, GIntBig nValue)

    Set field to 64 bit integer value.

    OFTInteger, OFTInteger64 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.

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - pszFName -- the name of the field to set.

      - nValue -- the value to assign.

  inline void SetField(const char *pszFName, double dfValue)

    Set field to double value.

    OFTInteger, OFTInteger64 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.

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - pszFName -- the name of the field to set.

      - dfValue -- the value to assign.

  inline void SetField(const char *pszFName, const char *pszValue)

    Set field to string value.

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

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - pszFName -- the name of the field to set.

      - pszValue -- the value to assign.

  inline void SetField(const char *pszFName, int nCount, const int *panValues)

    This method currently on has an effect of OFTIntegerList, OFTInteger64List and OFTRealList fields.

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - pszFName -- the name of the field to set.

      - nCount -- the number of values in the list being assigned.

      - panValues -- the values to assign.

  inline void SetField(const char *pszFName, int nCount, const GIntBig *panValues)

    Set field to list of 64 bit integers value.

    This method currently on has an effect of OFTIntegerList, OFTInteger64List and OFTRealList fields.

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - pszFName -- the name of the field to set.

      - nCount -- the number of values in the list being assigned.

      - panValues -- the values to assign.

  inline void SetField(const char *pszFName, int nCount, const double *padfValues)

    This method currently on has an effect of OFTIntegerList, OFTInteger64List, OFTRealList fields.

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - pszFName -- the name of the field to set.

      - nCount -- the number of values in the list being assigned.

      - padfValues -- the values to assign.

  inline void SetField(const char *pszFName, const char *const *papszValues)

    This method currently on has an effect of OFTStringList fields.

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - pszFName -- the name of the field to set.

      - papszValues -- the values to assign. List of NUL-terminated string, ending with a NULL pointer.

  inline void SetField(const char *pszFName, const 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.

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - pszFName -- the name of the field to set.

      - puValue -- the value to assign.

  inline void SetField(const char *pszFName, int nYear, int nMonth, int nDay, int nHour = 0, int nMinute = 0, float fSecond = 0.f, int nTZFlag = 0)

    Set field to date.

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

    Note

    This method has only an effect on the in-memory feature object. If this object comes from a layer and the modifications must be serialized back to the datasource, OGR_L_SetFeature() must be used afterwards. Or if this is a new feature, OGR_L_CreateFeature() must be used afterwards.

    Parameters:

      - pszFName -- the name of the field to set.

      - nYear -- (including century)

      - nMonth -- (1-12)

      - nDay -- (1-31)

      - nHour -- (0-23)

      - nMinute -- (0-59)

      - fSecond -- (0-59, with millisecond accuracy)

      - nTZFlag -- (0=unknown, 1=localtime, 100=GMT, see data model for details)

  inline GIntBig GetFID() const

    Get feature identifier.

    This method is the same as the C function OGR_F_GetFID(). Note: since GDAL 2.0, this method returns a GIntBig (previously a long)

    Returns:

      feature id or OGRNullFID if none has been assigned.

  virtual OGRErr SetFID(GIntBig nFIDIn)

    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:

      nFIDIn -- the new feature identifier value to assign.

    Returns:

      On success OGRERR_NONE, or on failure some other value.

  void DumpReadable(FILE*, CSLConstList papszOptions = nullptr) const

    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:

      - fpOut -- the stream to write to, such as stdout. If NULL stdout will be used.

      - papszOptions -- NULL terminated list of options (may be NULL)

  std::string DumpReadableAsString(CSLConstList papszOptions = nullptr) const

    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

    Since

      GDAL 3.7

    Parameters:

      papszOptions -- NULL terminated list of options (may be NULL)

    Returns:

      a string with the feature representation.

  OGRErr SetFrom(const OGRFeature*, 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:

      - poSrcFeature -- the feature from which geometry, and field values will be copied.

      - bForgiving -- TRUE 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.

  OGRErr SetFrom(const OGRFeature*, const int *panMap, int bForgiving = TRUE, bool bUseISO8601ForDateTimeAsString = false)

    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:

      - poSrcFeature -- the feature from which geometry, and field values will be copied.

      - panMap -- Array 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.

      - bForgiving -- TRUE if the operation should continue despite lacking output fields matching some of the source fields.

      - bUseISO8601ForDateTimeAsString -- true if datetime fields converted to string should use ISO8601 formatting rather than OGR own format.

    Returns:

      OGRERR_NONE if the operation succeeds, even if some values are not transferred, otherwise an error code.

  OGRErr SetFieldsFrom(const OGRFeature*, const int *panMap, int bForgiving = TRUE, bool bUseISO8601ForDateTimeAsString = false)

    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:

      - poSrcFeature -- the feature from which geometry, and field values will be copied.

      - panMap -- Array 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.

      - bForgiving -- TRUE if the operation should continue despite lacking output fields matching some of the source fields.

      - bUseISO8601ForDateTimeAsString -- true if datetime fields converted to string should use ISO8601 formatting rather than OGR own format.

    Returns:

      OGRERR_NONE if the operation succeeds, even if some values are not transferred, otherwise an error code.

  int Validate(int nValidateFlags, int bEmitError) const

    Validate that a feature meets constraints of its schema.

    The scope of test is specified with the nValidateFlags parameter.

    Regarding OGR_F_VAL_WIDTH, the test is done assuming the string width must be interpreted as the number of UTF-8 characters. Some drivers might interpret the width as the number of bytes instead. So this test is rather conservative (if it fails, then it will fail for all interpretations).

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

    Since

      GDAL 2.0

    Parameters:

      - nValidateFlags -- OGR_F_VAL_ALL or combination of OGR_F_VAL_NULL, OGR_F_VAL_GEOM_TYPE, OGR_F_VAL_WIDTH and OGR_F_VAL_ALLOW_NULL_WHEN_DEFAULT, OGR_F_VAL_ALLOW_DIFFERENT_GEOM_DIM with '|' operator

      - bEmitError -- TRUE if a CPLError() must be emitted when a check fails

    Returns:

      TRUE if all enabled validation tests pass.

  void FillUnsetWithDefault(int bNotNullableOnly, char **papszOptions)

    Fill unset fields with default values that might be defined.

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

    Since

      GDAL 2.0

    Parameters:

      - bNotNullableOnly -- if we should fill only unset fields with a not-null constraint.

      - papszOptions -- unused currently. Must be set to NULL.

  bool SerializeToBinary(std::vector<GByte> &abyBuffer) const

    Serialize the feature to a binary encoding.

    This saves the feature ID, attribute fields content and geometry fields content.

    This method is aimed at being paired with DeserializeFromBinary().

    The format of that encoding may vary across GDAL versions.

    Note that abyBuffer is cleared at the beginning of this function.

    Since

      3.9

  bool DeserializeFromBinary(const GByte *pabyBuffer, size_t nSize)

    Instantiate a feature from a binary encoding produces by SerializeToBinary()

    This sets the feature ID, attribute fields content and geometry fields content.

    DeserializeFromBinary() should be called on a feature whose feature definition is exactly the same as the one on which SerializeToBinary() was called. (but there is no security issue if not doing that, or if feeding a "random" buffer to that method).

    The format of that encoding may vary across GDAL versions.

    Since

      3.9

  virtual const char *GetStyleString() const

    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.

  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.

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

    Parameters:

      pszString -- the style string to apply to this feature, cannot be NULL.

  virtual void SetStyleStringDirectly(char*)

    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:

      pszString -- the style string to apply to this feature, cannot be NULL.

  inline virtual OGRStyleTable *GetStyleTable() const

    Return style table.

    Returns:

      style table.

  virtual void SetStyleTable(OGRStyleTable *poStyleTable)

    Set style table.

    Parameters:

      poStyleTable -- new style table (will be cloned)

  virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable)

    Set style table.

    Parameters:

      poStyleTable -- new style table (ownership transferred to the object)

  inline const char *GetNativeData() const

    Returns the native data for the feature.

    The native data is the representation in a "natural" form that comes from the driver that created this feature, or that is aimed at an output driver. The native data may be in different format, which is indicated by GetNativeMediaType().

    Note that most drivers do not support storing the native data in the feature object, and if they do, generally the NATIVE_DATA open option must be passed at dataset opening.

    The "native data" does not imply it is something more performant or powerful than what can be obtained with the rest of the API, but it may be useful in round-tripping scenarios where some characteristics of the underlying format are not captured otherwise by the OGR abstraction.

    This function is the same as the C function OGR_F_GetNativeData().

    See also

    https://trac.osgeo.org/gdal/wiki/rfc60_improved_roundtripping_in_ogr

    Since

      GDAL 2.1

    Returns:

      a string with the native data, or NULL if there is none.

  inline const char *GetNativeMediaType() const

    Returns the native media type for the feature.

    The native media type is the identifier for the format of the native data. It follows the IANA RFC 2045 (see https://en.wikipedia.org/wiki/Media_type), e.g. "application/vnd.geo+json" for JSon.

    This function is the same as the C function OGR_F_GetNativeMediaType().

    See also

    https://trac.osgeo.org/gdal/wiki/rfc60_improved_roundtripping_in_ogr

    Since

      GDAL 2.1

    Returns:

      a string with the native media type, or NULL if there is none.

  void SetNativeData(const char *pszNativeData)

    Sets the native data for the feature.

    The native data is the representation in a "natural" form that comes from the driver that created this feature, or that is aimed at an output driver. The native data may be in different format, which is indicated by GetNativeMediaType().

    This function is the same as the C function OGR_F_SetNativeData().

    See also

    https://trac.osgeo.org/gdal/wiki/rfc60_improved_roundtripping_in_ogr

    Since

      GDAL 2.1

    Parameters:

      pszNativeData -- a string with the native data, or NULL if there is none.

  void SetNativeMediaType(const char *pszNativeMediaType)

    Sets the native media type for the feature.

    The native media type is the identifier for the format of the native data. It follows the IANA RFC 2045 (see https://en.wikipedia.org/wiki/Media_type), e.g. "application/vnd.geo+json" for JSon.

    This function is the same as the C function OGR_F_SetNativeMediaType().

    See also

    https://trac.osgeo.org/gdal/wiki/rfc60_improved_roundtripping_in_ogr

    Since

      GDAL 2.1

    Parameters:

      pszNativeMediaType -- a string with the native media type, or NULL if there is none.

  Public Static Functions

  static OGRFeature *CreateFeature(OGRFeatureDefn*)

    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:

      poDefn -- Feature definition defining schema.

    Returns:

      new feature object with null fields and no geometry, or, starting with GDAL 2.1, NULL in case of out of memory situation. May be deleted with DestroyFeature().

  static void DestroyFeature(OGRFeature*)

    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:

      poFeature -- the feature to delete.

  static inline OGRFeatureH ToHandle(OGRFeature *poFeature)

    Convert a OGRFeature* to a OGRFeatureH.

    Since

      GDAL 2.3

  static inline OGRFeature *FromHandle(OGRFeatureH hFeature)

    Convert a OGRFeatureH to a OGRFeature*.

    Since

      GDAL 2.3

  class ConstFieldIterator

    Field value iterator class.

    struct Private
  class FieldNotFoundException : public std::exception

    Exception raised by operator[](const char*) when a field is not found.

  class FieldValue

    Field value.

    Public Functions

    FieldValue &operator=(const FieldValue &oOther)

      Set a field value from another one.

    FieldValue &operator=(int nVal)

      Set an integer value to the field.

    FieldValue &operator=(GIntBig nVal)

      Set an integer value to the field.

    FieldValue &operator=(double dfVal)

      Set a real value to the field.

    FieldValue &operator=(const char *pszVal)

      Set a string value to the field.

    FieldValue &operator=(const std::string &osVal)

      Set a string value to the field.

    FieldValue &operator=(const std::vector<int> &oArray)

      Set an array of integer to the field.

    FieldValue &operator=(const std::vector<GIntBig> &oArray)

      Set an array of big integer to the field.

    FieldValue &operator=(const std::vector<double> &oArray)

      Set an array of double to the field.

    FieldValue &operator=(const std::vector<std::string> &oArray)

      Set an array of strings to the field.

    FieldValue &operator=(CSLConstList papszValues)

      Set an array of strings to the field.

    void SetNull()

      Set a null value to the field.

    void clear()

      Unset the field.

    inline void Unset()

      Unset the field.

    void SetDateTime(int nYear, int nMonth, int nDay, int nHour = 0, int nMinute = 0, float fSecond = 0.f, int nTZFlag = 0)

      Set date time value/.

    int GetIndex() const

      Return field index.

    const OGRFieldDefn *GetDefn() const

      Return field definition.

    inline const char *GetName() const

      Return field name.

    inline OGRFieldType GetType() const

      Return field type.

    inline OGRFieldSubType GetSubType() const

      Return field subtype.

    inline bool empty() const

      Return whether the field value is unset/empty.

    bool IsUnset() const

      Return whether the field value is unset/empty.

    bool IsNull() const

      Return whether the field value is null.

    const OGRField *GetRawValue() const

      Return the raw field value.

    inline int GetInteger() const

      Return the integer value.

      Only use that method if and only if GetType() == OFTInteger.

    inline GIntBig GetInteger64() const

      Return the 64-bit integer value.

      Only use that method if and only if GetType() == OFTInteger64.

    inline double GetDouble() const

      Return the double value.

      Only use that method if and only if GetType() == OFTReal.

    inline const char *GetString() const

      Return the string value.

      Only use that method if and only if GetType() == OFTString.

    bool GetDateTime(int *pnYear, int *pnMonth, int *pnDay, int *pnHour, int *pnMinute, float *pfSecond, int *pnTZFlag) const

      Return the date/time/datetime value.

    inline operator int() const

      Return the field value as integer, with potential conversion.

    inline operator GIntBig() const

      Return the field value as 64-bit integer, with potential conversion.

    inline operator double() const

      Return the field value as double, with potential conversion.

    inline operator const char*() const

      Return the field value as string, with potential conversion.

    inline operator const std::vector<int>&() const

      Return the field value as integer list, with potential conversion.

    inline operator const std::vector<GIntBig>&() const

      Return the field value as 64-bit integer list, with potential conversion.

    inline operator const std::vector<double>&() const

      Return the field value as double list, with potential conversion.

    inline operator const std::vector<std::string>&() const

      Return the field value as string list, with potential conversion.

    operator CSLConstList() const

      Return the field value as string list, with potential conversion.

    int GetAsInteger() const

      Return the field value as integer, with potential conversion.

    GIntBig GetAsInteger64() const

      Return the field value as 64-bit integer, with potential conversion.

    double GetAsDouble() const

      Return the field value as double, with potential conversion.

    const char *GetAsString() const

      Return the field value as string, with potential conversion.

    const std::vector<int> &GetAsIntegerList() const

      Return the field value as integer list, with potential conversion.

    const std::vector<GIntBig> &GetAsInteger64List() const

      Return the field value as 64-bit integer list, with potential conversion.

    const std::vector<double> &GetAsDoubleList() const

      Return the field value as double list, with potential conversion.

    const std::vector<std::string> &GetAsStringList() const

      Return the field value as string list, with potential conversion.

    struct Private

## OGRFeatureDefn class

class OGRFeatureDefn

  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 and potentially other metadata.

  It is essentially a collection of field descriptions (OGRFieldDefn class). Starting with GDAL 1.11, in addition to attribute fields, it can also contain multiple geometry fields (OGRGeomFieldDefn class).

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

  Note that adding, modifying, removing, reordering a OGRFieldDefn (or a OGRGeomFieldDefn) from/to a OGRFeatureDefn that belongs to a OGRLayer should not be done through the OGRFeatureDefn::AddFieldDefn(), OGRFeatureDefn::DeleteFieldDefn() or OGRFeatureDefn::ReorderFieldDefns() methods, but rather through OGRLayer::CreateField(), OGRLayer::AlterFieldDefn() or OGRLayer::ReorderFields(), for drivers that support those operations.

  Public Functions

  explicit OGRFeatureDefn(const char *pszName = nullptr)

    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.

  void SetName(const char *pszName)

    Change name of this OGRFeatureDefn.

    To rename a layer, do not use this function directly, but use OGRLayer::Rename() instead.

    Since

      GDAL 2.3

    Parameters:

      pszName -- feature definition name

  virtual const char *GetName() const

    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.

  virtual int GetFieldCount() const

    Fetch number of fields on this feature.

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

    Returns:

      count of fields.

  virtual OGRFieldDefn *GetFieldDefn(int i)

    Fetch field definition.

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

    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.

  virtual const OGRFieldDefn *GetFieldDefn(int i) const

    Fetch field definition.

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

    Since

      GDAL 2.3

    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.

  virtual int GetFieldIndex(const char*) const

    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.

  int GetFieldIndexCaseSensitive(const char*) const

    Find field by name, in a case sensitive way.

    The field index of the first field matching the passed field name is returned.

    Parameters:

      pszFieldName -- the field name to search for.

    Returns:

      the field index, or -1 if no match found.

  inline Fields GetFields()

    Return an object that can be used to iterate over non-geometry fields.

        for( const auto* poFieldDefn: poFeatureDefn->GetFields() )
        {
            // do something
        }

    Since

      GDAL 3.7

  virtual void AddFieldDefn(const OGRFieldDefn*)

    Add a new field definition.

    To add a new field definition to a layer definition, do not use this function directly, but use OGRLayer::CreateField() instead.

    This method should only be called while there are no OGRFeature objects in existence 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.

  virtual OGRErr DeleteFieldDefn(int iField)

    Delete an existing field definition.

    To delete an existing field definition from a layer definition, do not use this function directly, but use OGRLayer::DeleteField() instead.

    This method should only be called while there are no OGRFeature objects in existence based on this OGRFeatureDefn.

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

    Since

      OGR 1.9.0

    Parameters:

      iField -- the index of the field definition.

    Returns:

      OGRERR_NONE in case of success.

  virtual OGRErr ReorderFieldDefns(const int *panMap)

    Reorder the field definitions in the array of the feature definition.

    To reorder the field definitions in a layer definition, do not use this function directly, but use OGR_L_ReorderFields() instead.

    This method should only be called while there are no OGRFeature objects in existence based on this OGRFeatureDefn.

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

    Since

      OGR 1.9.0

    Parameters:

      panMap -- an array of GetFieldCount() elements which is a permutation of [0, GetFieldCount()-1]. panMap is such that, for each field definition at position i after reordering, its position before reordering was panMap[i].

    Returns:

      OGRERR_NONE in case of success.

  virtual int GetGeomFieldCount() const

    Fetch number of geometry fields on this feature.

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

    Since

      GDAL 1.11

    Returns:

      count of geometry fields.

  virtual OGRGeomFieldDefn *GetGeomFieldDefn(int i)

    Fetch geometry field definition.

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

    Since

      GDAL 1.11

    Parameters:

      iGeomField -- the geometry field to fetch, between 0 and GetGeomFieldCount() - 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.

  virtual const OGRGeomFieldDefn *GetGeomFieldDefn(int i) const

    Fetch geometry field definition.

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

    Since

      GDAL 2.3

    Parameters:

      iGeomField -- the geometry field to fetch, between 0 and GetGeomFieldCount() - 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.

  virtual int GetGeomFieldIndex(const char*) const

    Find geometry field by name.

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

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

    Parameters:

      pszGeomFieldName -- the geometry field name to search for.

    Returns:

      the geometry field index, or -1 if no match found.

  inline GeomFields GetGeomFields()

    Return an object that can be used to iterate over geometry fields.

        for( const auto* poGeomFieldDefn: poFeatureDefn->GetGeomFields() )
        {
            // do something
        }

    Since

      GDAL 3.7

  virtual void AddGeomFieldDefn(const OGRGeomFieldDefn*)

    Add a new geometry field definition.

    To add a new geometry field definition to a layer definition, do not use this function directly, but use OGRLayer::CreateGeomField() instead.

    This method does an internal copy of the passed geometry field definition, unless bCopy is set to FALSE (in which case it takes ownership of the field definition.

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

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

    Since

      GDAL 1.11

    Parameters:

      poNewDefn -- the definition of the new geometry field.

  virtual void AddGeomFieldDefn(std::unique_ptr<OGRGeomFieldDefn>&&)

    Add a new geometry field definition.

    To add a new geometry field definition to a layer definition, do not use this function directly, but use OGRLayer::CreateGeomField() instead.

    This method takes ownership of the passed geometry field definition.

    This method should only be called while there are no OGRFeature objects in existence based on this OGRFeatureDefn.

    Since

      GDAL 3.4

    Parameters:

      poNewDefn -- the definition of the new geometry field.

  virtual OGRErr DeleteGeomFieldDefn(int iGeomField)

    Delete an existing geometry field definition.

    To delete an existing field definition from a layer definition, do not use this function directly, but use OGRLayer::DeleteGeomField() instead.

    This method should only be called while there are no OGRFeature objects in existence based on this OGRFeatureDefn.

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

    Since

      GDAL 1.11

    Parameters:

      iGeomField -- the index of the geometry field definition.

    Returns:

      OGRERR_NONE in case of success.

  virtual OGRwkbGeometryType GetGeomType() const

    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.

    Starting with GDAL 1.11, this method returns GetGeomFieldDefn(0)->GetType().

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

    Returns:

      the base type for all geometry related to this definition.

  virtual void SetGeomType(OGRwkbGeometryType)

    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().

    Starting with GDAL 1.11, this method calls GetGeomFieldDefn(0)->SetType().

    Parameters:

      eNewType -- the new type to assign.

  virtual OGRFeatureDefn *Clone() const

    Create a copy of this feature definition.

    Creates a deep copy of the feature definition.

    Returns:

      the copy.

  inline int Reference()

    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.

  inline int Dereference()

    Decrements the reference count by one.

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

    Returns:

      the updated reference count.

  inline int GetReferenceCount() const

    Fetch current reference count.

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

    Returns:

      the current reference count.

  void Release()

    Drop a reference to this object, and destroy if no longer referenced.

  virtual int IsGeometryIgnored() const

    Determine whether the geometry can be omitted when fetching features.

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

    Starting with GDAL 1.11, this method returns GetGeomFieldDefn(0)->IsIgnored().

    Returns:

      ignore state

  virtual void SetGeometryIgnored(int bIgnore)

    Set whether the geometry can be omitted when fetching features.

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

    Starting with GDAL 1.11, this method calls GetGeomFieldDefn(0)->SetIgnored().

    Parameters:

      bIgnore -- ignore state

  inline virtual bool IsStyleIgnored() const

    Determine whether the style can be omitted when fetching features.

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

    Returns:

      ignore state

  inline virtual void SetStyleIgnored(bool bIgnore)

    Set whether the style can be omitted when fetching features.

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

    Parameters:

      bIgnore -- ignore state

  virtual int IsSame(const OGRFeatureDefn *poOtherFeatureDefn) const

    Test if the feature definition is identical to the other one.

    Parameters:

      poOtherFeatureDefn -- the other feature definition to compare to.

    Returns:

      TRUE if the feature definition is identical to the other one.

  std::vector<int> ComputeMapForSetFrom(const OGRFeatureDefn *poSrcFDefn, bool bForgiving = true) const

    Compute the map from source to target field that can be passed to SetFrom().

    Since

      GDAL 2.3

    Parameters:

      - poSrcFDefn -- the feature definition of source features later passed to SetFrom()

      - bForgiving -- true if the operation should continue despite lacking output fields matching some of the source fields.

    Returns:

      an array of size poSrcFDefn->GetFieldCount() if everything succeeds, or empty in case a source field definition was not found in the target layer and bForgiving == true.

  void Seal(bool bSealFields)

    Seal a OGRFeatureDefn.

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

    This method also call OGRFieldDefn::Seal() and OGRGeomFieldDefn::Seal() on its fields and geometry fields.

    This method should only be called by driver implementations.

    Since

      GDAL 3.9

    Parameters:

      bSealFields -- Whether fields and geometry fields should be sealed. This is generally desirabled, but in case of deferred resolution of them, this parameter should be set to false.

  void Unseal(bool bUnsealFields)

    Unseal a OGRFeatureDefn.

    Undo OGRFeatureDefn::Seal()

    This method also call OGRFieldDefn::Unseal() and OGRGeomFieldDefn::Unseal() on its fields and geometry fields.

    Using GetTemporaryUnsealer() is recommended for most use cases.

    This method should only be called by driver implementations.

    Since

      GDAL 3.9

    Parameters:

      bUnsealFields -- Whether fields and geometry fields should be unsealed. This is generally desirabled, but in case of deferred resolution of them, this parameter should be set to false.

  TemporaryUnsealer GetTemporaryUnsealer(bool bSealFields = true)

    Return an object that temporary unseals the OGRFeatureDefn.

    The returned object calls Unseal() initially, and when it is destroyed it calls Seal(). This method should be called on a OGRFeatureDefn that has been sealed previously. GetTemporaryUnsealer() calls may be nested, in which case only the first one has an effect (similarly to a recursive mutex locked in a nested way from the same thread).

    This method should only be called by driver implementations.

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

    Since

      GDAL 3.9

    Parameters:

      bSealFields -- Whether fields and geometry fields should be unsealed and resealed. This is generally desirabled, but in case of deferred resolution of them, this parameter should be set to false.

  Public Static Functions

  static OGRFeatureDefn *CreateFeatureDefn(const char *pszName = nullptr)

    Create a new feature definition object.

    Parameters:

      pszName -- name

    Returns:

      new feature definition object.

  static void DestroyFeatureDefn(OGRFeatureDefn*)

    Destroy a feature definition.

    Parameters:

      poDefn -- feature definition.

  static inline OGRFeatureDefnH ToHandle(OGRFeatureDefn *poFeatureDefn)

    Convert a OGRFeatureDefn* to a OGRFeatureDefnH.

    Since

      GDAL 2.3

  static inline OGRFeatureDefn *FromHandle(OGRFeatureDefnH hFeatureDefn)

    Convert a OGRFeatureDefnH to a OGRFeatureDefn*.

    Since

      GDAL 2.3

## OGRFieldDefn class

class OGRFieldDefn

  Definition of an attribute of an OGRFeatureDefn.

  A field is described by :

  - a name. See SetName() / GetNameRef()

  - an alternative name (optional): alternative descriptive name for the field (sometimes referred to as an "alias"). See SetAlternativeName() / GetAlternativeNameRef()

  - a type: OFTString, OFTInteger, OFTReal, ... See SetType() / GetType()

  - a subtype (optional): OFSTBoolean, ... See SetSubType() / GetSubType()

  - a width (optional): maximal number of characters. See SetWidth() / GetWidth()

  - a precision (optional): number of digits after decimal point. See SetPrecision() / GetPrecision()

  - a NOT NULL constraint (optional). See SetNullable() / IsNullable()

  - a UNIQUE constraint (optional). See SetUnique() / IsUnique()

  - a default value (optional). See SetDefault() / GetDefault()

  - a boolean to indicate whether it should be ignored when retrieving features. See SetIgnored() / IsIgnored()

  - a field domain name (optional). See SetDomainName() / Get DomainName()

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

  Public Functions

  OGRFieldDefn(const char*, OGRFieldType)

    Constructor.

    By default, fields have no width, precision, are nullable and not ignored.

    Parameters:

      - pszNameIn -- the name of the new field.

      - eTypeIn -- the type of the new field.

  explicit OGRFieldDefn(const OGRFieldDefn*)

    Constructor.

    Create by cloning an existing field definition.

    Parameters:

      poPrototype -- the field definition to clone.

  void SetName(const char*)

    Reset the name of this field.

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

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

    Parameters:

      pszNameIn -- the new name to apply.

  inline const char *GetNameRef() const

    Fetch name of this field.

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

    Returns:

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

  void SetAlternativeName(const char*)

    Reset the alternative name (or "alias") for this field.

    The alternative name is an optional attribute for a field which can provide a more user-friendly, descriptive name of a field which is not subject to the usual naming constraints defined by the data provider.

    This is a metadata style attribute only: the alternative name cannot be used in place of the actual field name during SQL queries or other field name dependent API calls.

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

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

    Since

      GDAL 3.2

    Parameters:

      pszAlternativeNameIn -- the new alternative name to apply.

  inline const char *GetAlternativeNameRef() const

    Fetch the alternative name (or "alias") for this field.

    The alternative name is an optional attribute for a field which can provide a more user-friendly, descriptive name of a field which is not subject to the usual naming constraints defined by the data provider.

    This is a metadata style attribute only: the alternative name cannot be used in place of the actual field name during SQL queries or other field name dependent API calls.

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

    Since

      GDAL 3.2

    Returns:

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

  inline OGRFieldType GetType() const

    Fetch type of this field.

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

    Returns:

      field type.

  void SetType(OGRFieldType eTypeIn)

    Set the type of this field.

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

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

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

    Parameters:

      eTypeIn -- the new field type.

  inline OGRFieldSubType GetSubType() const

    Fetch subtype of this field.

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

    Since

      GDAL 2.0

    Returns:

      field subtype.

  void SetSubType(OGRFieldSubType eSubTypeIn)

    Set the subtype of this field.

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

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

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

    Since

      GDAL 2.0

    Parameters:

      eSubTypeIn -- the new field subtype.

  inline OGRJustification GetJustify() const

    Get the justification for this field.

    Note: no driver is know to use the concept of field justification.

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

    Returns:

      the justification.

  inline void SetJustify(OGRJustification eJustifyIn)

    Set the justification for this field.

    Note: no driver is know to use the concept of field justification.

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

    Parameters:

      eJustify -- the new justification.

  inline int GetWidth() const

    Get the formatting width for this field.

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

    Returns:

      the width, zero means no specified width.

  void SetWidth(int nWidthIn)

    Set the formatting width for this field in characters.

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

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

    Parameters:

      nWidthIn -- the new width.

  inline int GetPrecision() const

    Get the formatting precision for this field.

    This should normally be zero for fields of types other than OFTReal.

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

    Returns:

      the precision.

  void SetPrecision(int nPrecisionIn)

    Set the formatting precision for this field in characters.

    This should normally be zero for fields of types other than OFTReal.

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

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

    Parameters:

      nPrecisionIn -- the new precision.

  inline int GetTZFlag() const

    Get the time zone flag.

    Only applies to OFTTime, OFTDate and OFTDateTime fields.

    Cf OGR_TZFLAG_UNKNOWN, OGR_TZFLAG_LOCALTIME, OGR_TZFLAG_MIXED_TZ and OGR_TZFLAG_UTC

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

    Since

      GDAL 3.8

    Returns:

      the time zone flag.

  void SetTZFlag(int nTZFlag)

    Set the time zone flag.

    Only applies to OFTTime, OFTDate and OFTDateTime fields.

    Cf OGR_TZFLAG_UNKNOWN, OGR_TZFLAG_LOCALTIME, OGR_TZFLAG_MIXED_TZ and OGR_TZFLAG_UTC

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

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

    Since

      GDAL 3.8

    Parameters:

      nTZFlag -- the new time zone flag.

  void Set(const char*, OGRFieldType, int = 0, int = 0, OGRJustification = OJUndefined)

    Set defining parameters for a field in one call.

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

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

    Parameters:

      - pszNameIn -- the new name to assign.

      - eTypeIn -- the new type (one of the OFT values like OFTInteger).

      - nWidthIn -- the preferred formatting width. Defaults to zero indicating undefined.

      - nPrecisionIn -- number of decimals places for formatting, defaults to zero indicating undefined.

      - eJustifyIn -- the formatting justification (OJLeft or OJRight), defaults to OJUndefined.

  void SetDefault(const char*)

    Set default field value.

    The default field value is taken into account by drivers (generally those with a SQL interface) that support it at field creation time. OGR will generally not automatically set the default field value to null fields by itself when calling OGRFeature::CreateFeature() / OGRFeature::SetFeature(), but will let the low-level layers to do the job. So retrieving the feature from the layer is recommended.

    The accepted values are NULL, a numeric value, a literal value enclosed between single quote characters (and inner single quote characters escaped by repetition of the single quote character), CURRENT_TIMESTAMP, CURRENT_TIME, CURRENT_DATE or a driver specific expression (that might be ignored by other drivers). For a datetime literal value, format should be 'YYYY/MM/DD HH:MM:SS[.sss]' (considered as UTC time).

    Drivers that support writing DEFAULT clauses will advertise the GDAL_DCAP_DEFAULT_FIELDS driver metadata item.

    This function is the same as the C function OGR_Fld_SetDefault().

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

    Since

      GDAL 2.0

    Parameters:

      pszDefaultIn -- new default field value or NULL pointer.

  const char *GetDefault() const

    Get default field value.

    This function is the same as the C function OGR_Fld_GetDefault().

    Since

      GDAL 2.0

    Returns:

      default field value or NULL.

  int IsDefaultDriverSpecific() const

    Returns whether the default value is driver specific.

    Driver specific default values are those that are not NULL, a numeric value, a literal value enclosed between single quote characters, CURRENT_TIMESTAMP, CURRENT_TIME, CURRENT_DATE or datetime literal value.

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

    Since

      GDAL 2.0

    Returns:

      TRUE if the default value is driver specific.

  inline int IsIgnored() const

    Return whether this field should be omitted when fetching features.

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

    Returns:

      ignore state

  inline void SetIgnored(int bIgnoreIn)

    Set whether this field should be omitted when fetching features.

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

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

    Parameters:

      ignore -- ignore state

  inline int IsNullable() const

    Return whether this 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.

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

    Since

      GDAL 2.0

    Returns:

      TRUE if the field is authorized to be null.

  void SetNullable(int bNullableIn)

    Set whether this 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_FIELDS driver metadata item.

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

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

    Since

      GDAL 2.0

    Parameters:

      bNullableIn -- FALSE if the field must have a not-null constraint.

  inline int IsUnique() const

    Return whether this field has a unique constraint.

    By default, fields have no unique constraint.

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

    Since

      GDAL 3.2

    Returns:

      TRUE if the field has a unique constraint.

  void SetUnique(int bUniqueIn)

    Set whether this field has a unique constraint.

    By default, fields have no unique constraint, so this method is generally called with TRUE to set a unique constraint.

    Drivers that support writing unique constraint will advertise the GDAL_DCAP_UNIQUE_FIELDS driver metadata item.

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

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

    Since

      GDAL 3.2

    Parameters:

      bUniqueIn -- TRUE if the field must have a unique constraint.

  inline const std::string &GetDomainName() const

    Return the name of the field domain for this field.

    By default, none (empty string) is returned.

    Field domains (OGRFieldDomain class) are attached at the GDALDataset level and should be retrieved with GDALDataset::GetFieldDomain().

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

    Since

      GDAL 3.3

    Returns:

      the field domain name, or an empty string if there is none.

  void SetDomainName(const std::string &osDomainName)

    Set the name of the field domain for this field.

    Field domains (OGRFieldDomain) are attached at the GDALDataset level.

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

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

    Since

      GDAL 3.3

    Parameters:

      osDomainName -- Field domain name.

  inline const std::string &GetComment() const

    Return the (optional) comment for this field.

    By default, none (empty string) is returned.

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

    Since

      GDAL 3.7

    Returns:

      the field comment, or an empty string if there is none.

  void SetComment(const std::string &osComment)

    Set the comment for this field.

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

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

    Since

      GDAL 3.7

    Parameters:

      osComment -- Field comment.

  int IsSame(const OGRFieldDefn*) const

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

    Parameters:

      poOtherFieldDefn -- the other field definition to compare to.

    Returns:

      TRUE if the field definition is identical to the other one.

  void Seal()

    Seal a OGRFieldDefn.

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

    This method should only be called by driver implementations.

    Since

      GDAL 3.9

  void Unseal()

    Unseal a OGRFieldDefn.

    Undo OGRFieldDefn::Seal()

    Using GetTemporaryUnsealer() is recommended for most use cases.

    This method should only be called by driver implementations.

    Since

      GDAL 3.9

  TemporaryUnsealer GetTemporaryUnsealer()

    Return an object that temporary unseals the OGRFieldDefn.

    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(poFieldDefn)->some_method()

    Since

      GDAL 3.9

  Public Static Functions

  static const char *GetFieldTypeName(OGRFieldType)

    Fetch human readable name for a field type.

    This static method is the same as the C function OGR_GetFieldTypeName().

    Parameters:

      eType -- the field type to get name for.

    Returns:

      pointer to an internal static name string. It should not be modified or freed.

  static const char *GetFieldSubTypeName(OGRFieldSubType)

    Fetch human readable name for a field subtype.

    This static method is the same as the C function OGR_GetFieldSubTypeName().

    Since

      GDAL 2.0

    Parameters:

      eSubType -- the field subtype to get name for.

    Returns:

      pointer to an internal static name string. It should not be modified or freed.

  static inline OGRFieldDefnH ToHandle(OGRFieldDefn *poFieldDefn)

    Convert a OGRFieldDefn* to a OGRFieldDefnH.

    Since

      GDAL 2.3

  static inline OGRFieldDefn *FromHandle(OGRFieldDefnH hFieldDefn)

    Convert a OGRFieldDefnH to a OGRFieldDefn*.

    Since

      GDAL 2.3

## OGRGeomFieldDefn class

class OGRGeomFieldDefn

  Definition of a geometry field of an OGRFeatureDefn.

  A geometry field is described by :

  - a name. See SetName() / GetNameRef()

  - a type: wkbPoint, wkbLineString, ... See SetType() / GetType()

  - a spatial reference system (optional). See SetSpatialRef() / GetSpatialRef()

  - a NOT NULL constraint (optional). See SetNullable() / IsNullable()

  - a boolean to indicate whether it should be ignored when retrieving features. See SetIgnored() / IsIgnored()

  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().

  Since

    OGR 1.11

  Public Functions

  OGRGeomFieldDefn(const char *pszNameIn, OGRwkbGeometryType eGeomTypeIn)

    Constructor.

    Since

      GDAL 1.11

    Parameters:

      - pszNameIn -- the name of the new field.

      - eGeomTypeIn -- the type of the new field.

  explicit OGRGeomFieldDefn(const OGRGeomFieldDefn*)

    Constructor.

    Create by cloning an existing geometry field definition.

    Since

      GDAL 1.11

    Parameters:

      poPrototype -- the geometry field definition to clone.

  void SetName(const char*)

    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()->GetGeomFieldDefn(). Instead, OGRLayer::AlterGeomFieldDefn() should be called on a new instance of OGRFieldDefn, for drivers that support AlterFieldDefn().

    Since

      GDAL 1.11

    Parameters:

      pszNameIn -- the new name to apply.

  inline const char *GetNameRef() const

    Fetch name of this field.

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

    Since

      GDAL 1.11

    Returns:

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

  inline OGRwkbGeometryType GetType() const

    Fetch geometry type of this field.

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

    Since

      GDAL 1.11

    Returns:

      field geometry type.

  void 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()->GetGeomFieldDefn(). Instead, OGRLayer::AlterGeomFieldDefn() should be called on a new instance of OGRFieldDefn, for drivers that support AlterFieldDefn().

    Since

      GDAL 1.11

    Parameters:

      eTypeIn -- the new field geometry type.

  virtual const OGRSpatialReference *GetSpatialRef() const

    Fetch spatial reference system of this field.

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

    Since

      GDAL 1.11

    Returns:

      field spatial reference system.

  void 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()->GetGeomFieldDefn(). Instead, OGRLayer::AlterGeomFieldDefn() should be called on a new instance of OGRFieldDefn, for drivers that support AlterFieldDefn().

    Since

      GDAL 1.11

    Parameters:

      poSRSIn -- the new SRS to apply.

  inline int IsIgnored() const

    Return whether this field should be omitted when fetching features.

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

    Since

      GDAL 1.11

    Returns:

      ignore state

  inline void SetIgnored(int bIgnoreIn)

    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()->GetGeomFieldDefn(). Instead, the OGRLayer::SetIgnoredFields() method should be called.

    Since

      GDAL 1.11

    Parameters:

      ignore -- ignore state

  inline int IsNullable() const

    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().

    Since

      GDAL 2.0

    Returns:

      TRUE if the field is authorized to be null.

  void 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()->GetGeomFieldDefn(). Instead, OGRLayer::AlterGeomFieldDefn() should be called on a new instance of OGRFieldDefn, for drivers that support AlterFieldDefn().

    Since

      GDAL 2.0

    Parameters:

      bNullableIn -- FALSE if the field must have a not-null constraint.

  inline const OGRGeomCoordinatePrecision &GetCoordinatePrecision() const

    Return the coordinate precision associated to this geometry field.

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

    Since

      GDAL 3.9

    Returns:

      the coordinate precision

  void 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()->GetGeomFieldDefn().

    Since

      GDAL 3.9

    Parameters:

      prec -- Coordinate precision

  int IsSame(const OGRGeomFieldDefn*) const

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

    Since

      GDAL 1.11

    Parameters:

      poOtherFieldDefn -- the other field definition to compare to.

    Returns:

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

  void 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

  void 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

  TemporaryUnsealer 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

  Public Static Functions

  static inline OGRGeomFieldDefnH ToHandle(OGRGeomFieldDefn *poGeomFieldDefn)

    Convert a OGRGeomFieldDefn* to a OGRGeomFieldDefnH.

    Since

      GDAL 2.3

  static inline OGRGeomFieldDefn *FromHandle(OGRGeomFieldDefnH hGeomFieldDefn)

    Convert a OGRGeomFieldDefnH to a OGRGeomFieldDefn*.

    Since

      GDAL 2.3

## OGRFieldDomain class

class OGRFieldDomain

  Definition of a field domain.

  A field domain is a set of constraints that apply to one or several fields.

  This is a concept found in File Geodatabase or GeoPackage (using the schema extension) for example.

  A field domain can be:

  - OGRCodedFieldDomain: an enumerated list of (code, value) tuples.

  - OGRRangeFieldDomain: a range constraint (min, max).

  - OGRGlobFieldDomain: a glob expression.

  Since

    GDAL 3.3

  Subclassed by OGRCodedFieldDomain, OGRGlobFieldDomain, OGRRangeFieldDomain

  Public Functions

  virtual ~OGRFieldDomain() = 0

    Destructor.

    This is the same as the C function OGR_FldDomain_Destroy().

  virtual OGRFieldDomain *Clone() const = 0

    Clone.

    Return a cloned object, or nullptr in case of error.

  inline const std::string &GetName() const

    Get the name of the field domain.

    This is the same as the C function OGR_FldDomain_GetName().

  inline const std::string &GetDescription() const

    Get the description of the field domain.

    Empty string if there is none.

    This is the same as the C function OGR_FldDomain_GetDescription().

  inline OGRFieldDomainType GetDomainType() const

    Get the type of the field domain.

    This is the same as the C function OGR_FldDomain_GetDomainType().

  inline OGRFieldType GetFieldType() const

    Get the field type.

    This is the same as the C function OGR_FldDomain_GetFieldType().

  inline OGRFieldSubType GetFieldSubType() const

    Get the field subtype.

    This is the same as the C function OGR_FldDomain_GetFieldSubType().

  inline OGRFieldDomainSplitPolicy GetSplitPolicy() const

    Get the split policy.

    This is the same as the C function OGR_FldDomain_GetSplitPolicy().

  inline void SetSplitPolicy(OGRFieldDomainSplitPolicy policy)

    Set the split policy.

    This is the same as the C function OGR_FldDomain_SetSplitPolicy().

  inline OGRFieldDomainMergePolicy GetMergePolicy() const

    Get the merge policy.

    This is the same as the C function OGR_FldDomain_GetMergePolicy().

  inline void SetMergePolicy(OGRFieldDomainMergePolicy policy)

    Set the merge policy.

    This is the same as the C function OGR_FldDomain_SetMergePolicy().

  Public Static Functions

  static inline OGRFieldDomainH ToHandle(OGRFieldDomain *poFieldDomain)

    Convert a OGRFieldDomain* to a OGRFieldDomainH.

  static inline OGRFieldDomain *FromHandle(OGRFieldDomainH hFieldDomain)

    Convert a OGRFieldDomainH to a OGRFieldDomain*.

### OGRCodedFieldDomain class

class OGRCodedFieldDomain : public OGRFieldDomain

  Definition of a coded / enumerated field domain.

  A code field domain is a domain for which only a limited set of codes, associated with their expanded value, are allowed. The type of the code should be the one of the field domain.

  Public Functions

  OGRCodedFieldDomain(const std::string &osName, const std::string &osDescription, OGRFieldType eFieldType, OGRFieldSubType eFieldSubType, std::vector<OGRCodedValue> &&asValues)

    Constructor.

    This is the same as the C function OGR_CodedFldDomain_Create() (except that the C function copies the enumeration, whereas the C++ method moves it)

    Parameters:

      - osName -- Domain name.

      - osDescription -- Domain description.

      - eFieldType -- Field type. Generally numeric. Potentially OFTDateTime

      - eFieldSubType -- Field subtype.

      - asValues -- Enumeration as (code, value) pairs. Each code should appear only once, but it is the responsibility of the user to check it.

  virtual OGRCodedFieldDomain *Clone() const override

    Clone.

    Return a cloned object, or nullptr in case of error.

  inline const OGRCodedValue *GetEnumeration() const

    Get the enumeration as (code, value) pairs.

    The end of the enumeration is signaled by code == NULL.

    This is the same as the C function OGR_CodedFldDomain_GetEnumeration().

### OGRRangeFieldDomain class

class OGRRangeFieldDomain : public OGRFieldDomain

  Definition of a numeric field domain with a range of validity for values.

  Public Functions

  OGRRangeFieldDomain(const std::string &osName, const std::string &osDescription, OGRFieldType eFieldType, OGRFieldSubType eFieldSubType, const OGRField &sMin, bool bMinIsInclusive, const OGRField &sMax, bool bMaxIsInclusive)

    Constructor.

    This is the same as the C function OGR_RangeFldDomain_Create().

    Parameters:

      - osName -- Domain name.

      - osDescription -- Domain description.

      - eFieldType -- Field type. One among OFTInteger, OFTInteger64, OFTReal or OFTDateTime

      - eFieldSubType -- Field subtype.

      - sMin -- Minimum value. Which member in the OGRField enum must be read depends on the field type. If no minimum is set (might not be supported by all backends), then initialize the value with OGR_RawField_SetUnset().

      - bMinIsInclusive -- Whether the minimum value is included in the range.

      - sMax -- Minimum value. Which member in the OGRField enum must be read depends on the field type. If no maximum is set (might not be supported by all backends), then initialize the value with OGR_RawField_SetUnset().

      - bMaxIsInclusive -- Whether the minimum value is included in the range.

  inline virtual OGRRangeFieldDomain *Clone() const override

    Clone.

    Return a cloned object, or nullptr in case of error.

  inline const OGRField &GetMin(bool &bIsInclusiveOut) const

    Get the minimum value.

    Which member in the returned OGRField enum must be read depends on the field type.

    If no minimum value is set, the OGR_RawField_IsUnset() will return true when called on the result.

    This is the same as the C function OGR_RangeFldDomain_GetMin().

    Parameters:

      bIsInclusiveOut -- set to true if the minimum is included in the range.

  inline const OGRField &GetMax(bool &bIsInclusiveOut) const

    Get the maximum value.

    Which member in the returned OGRField enum must be read depends on the field type.

    If no maximum value is set, the OGR_RawField_IsUnset() will return true when called on the result.

    This is the same as the C function OGR_RangeFldDomain_GetMax().

    Parameters:

      bIsInclusiveOut -- set to true if the maximum is included in the range.

### OGRGlobFieldDomain class

class OGRGlobFieldDomain : public OGRFieldDomain

  Definition of a field domain for field content validated by a glob.

  Globs are matching expression like "*[a-z][0-1]?"

  Public Functions

  OGRGlobFieldDomain(const std::string &osName, const std::string &osDescription, OGRFieldType eFieldType, OGRFieldSubType eFieldSubType, const std::string &osBlob)

    Constructor.

    This is the same as the C function OGR_GlobFldDomain_Create().

    Parameters:

      - osName -- Domain name.

      - osDescription -- Domain description.

      - eFieldType -- Field type.

      - eFieldSubType -- Field subtype.

      - osBlob -- Blob expression

  inline virtual OGRGlobFieldDomain *Clone() const override

    Clone.

    Return a cloned object, or nullptr in case of error.

  inline const std::string &GetGlob() const

    Get the glob expression.

    This is the same as the C function OGR_GlobFldDomain_GetGlob().