GDAL

Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | List of all members
OGRGNMWrappedResultLayer Class Reference

The OGRGNMWrappedResultLayer class for search paths queries results. More...

`#include <gnm.h>`

Inheritance diagram for OGRGNMWrappedResultLayer:

## Public Types
typedef std::vector< std::unique_ptr< OGRSpatialReference, OGRSpatialReferenceReleaser > > | GetSupportedSRSListRetType
| Return type of OGRLayer::GetSupportedSRSList()

## Public Member Functions
| OGRGNMWrappedResultLayer (GDALDataset *poDS, OGRLayer *poLayer)
| Constructor.
virtual void | ResetReading () override
| Reset feature reading to start on the first feature.
virtual OGRFeature * | GetNextFeature () override
| Fetch the next available feature from this layer.
virtual OGRErr | SetNextByIndex (GIntBig nIndex) override
| Move read cursor to the nIndex'th feature in the current resultset.
virtual OGRFeature * | GetFeature (GIntBig nFID) override
| Fetch a feature by its identifier.
virtual OGRFeatureDefn * | GetLayerDefn () override
| Fetch the schema information for this layer.
virtual GIntBig | GetFeatureCount (int bForce=TRUE) override
| Fetch the feature count in this layer.
virtual int | TestCapability (const char *pszCap) override
| Test if this layer supported the named capability.
virtual OGRErr | CreateField (const OGRFieldDefn *poField, int bApproxOK=TRUE) override
| Create a new field on a layer.
virtual OGRErr | CreateGeomField (const OGRGeomFieldDefn *poField, int bApproxOK=TRUE) override
| Create a new geometry field on a layer.
virtual const char * | GetFIDColumn () override
| This method returns the name of the underlying database column being used as the FID column, or "" if not supported.
virtual const char * | GetGeometryColumn () override
| This method returns the name of the underlying database column being used as the geometry column, or "" if not supported.
virtual OGRSpatialReference * | GetSpatialRef () override
| Fetch the spatial reference system for this layer.
virtual OGRErr | InsertFeature (OGRFeature *poFeature, const CPLString &soLayerName, int nPathNo, bool bIsEdge)
| Undocumented.
FeatureIterator | begin ()
| Return begin of feature iterator.
FeatureIterator | end ()
| Return end of feature iterator.
virtual OGRGeometry * | GetSpatialFilter ()
| This method returns the current spatial filter for this layer.
virtual void | SetSpatialFilter (OGRGeometry *)
| Set a new spatial filter.
virtual void | SetSpatialFilter (int iGeomField, OGRGeometry *)
| Set a new spatial filter.
virtual void | SetSpatialFilterRect (double dfMinX, double dfMinY, double dfMaxX, double dfMaxY)
| Set a new rectangular spatial filter.
virtual void | SetSpatialFilterRect (int iGeomField, double dfMinX, double dfMinY, double dfMaxX, double dfMaxY)
| Set a new rectangular spatial filter.
virtual OGRErr | SetAttributeFilter (const char *)
| Set a new attribute query.
virtual GDALDataset * | GetDataset ()
| Return the dataset associated with this layer.
virtual bool | GetArrowStream (struct ArrowArrayStream *out_stream, CSLConstList papszOptions=nullptr)
| Get a Arrow C stream.
virtual bool | IsArrowSchemaSupported (const struct ArrowSchema *schema, CSLConstList papszOptions, std::string &osErrorMsg) const
| Returns whether the provided ArrowSchema is supported for writing.
virtual bool | CreateFieldFromArrowSchema (const struct ArrowSchema *schema, CSLConstList papszOptions=nullptr)
| Creates a field from an ArrowSchema.
virtual bool | WriteArrowBatch (const struct ArrowSchema *schema, struct ArrowArray *array, CSLConstList papszOptions=nullptr)
| Writes a batch of rows from an ArrowArray.
OGRErr | SetFeature (OGRFeature *poFeature)
| Rewrite/replace an existing feature.
OGRErr | CreateFeature (OGRFeature *poFeature)
| Create and write a new feature within a layer.
OGRErr | UpsertFeature (OGRFeature *poFeature)
| Rewrite/replace an existing feature or create a new feature within a layer.
OGRErr | UpdateFeature (OGRFeature *poFeature, int nUpdatedFieldsCount, const int *panUpdatedFieldsIdx, int nUpdatedGeomFieldsCount, const int *panUpdatedGeomFieldsIdx, bool bUpdateStyleString)
| Update (part of) an existing feature.
virtual OGRErr | DeleteFeature (GIntBig nFID)
| Delete feature from layer.
virtual const char * | GetName ()
| Return the layer name.
virtual OGRwkbGeometryType | GetGeomType ()
| Return the layer geometry type.
virtual int | FindFieldIndex (const char *pszFieldName, int bExactMatch)
| Find the index of field in the layer.
virtual const GetSupportedSRSListRetType & | GetSupportedSRSList (int iGeomField)
| Get the list of SRS supported.
virtual OGRErr | SetActiveSRS (int iGeomField, const OGRSpatialReference *poSRS)
| Change the active SRS.
virtual OGRErr | GetExtent (OGREnvelope *psExtent, int bForce=TRUE)
| Fetch the extent of this layer.
virtual OGRErr | GetExtent (int iGeomField, OGREnvelope *psExtent, int bForce=TRUE)
| Fetch the extent of this layer, on the specified geometry field.
virtual OGRErr | GetExtent3D (int iGeomField, OGREnvelope3D *psExtent3D, int bForce=TRUE)
| Fetch the 3D extent of this layer, on the specified geometry field.
virtual OGRErr | Rename (const char *pszNewName)
| Rename layer.
virtual OGRErr | DeleteField (int iField)
| Delete an existing field on a layer.
virtual OGRErr | ReorderFields (int *panMap)
| Reorder all the fields of a layer.
virtual OGRErr | AlterFieldDefn (int iField, OGRFieldDefn *poNewFieldDefn, int nFlagsIn)
| Alter the definition of an existing field on a layer.
virtual OGRErr | AlterGeomFieldDefn (int iGeomField, const OGRGeomFieldDefn *poNewGeomFieldDefn, int nFlagsIn)
| Alter the definition of an existing geometry field on a layer.
virtual OGRErr | SyncToDisk ()
| Flush pending changes to disk.
virtual OGRStyleTable * | GetStyleTable ()
| Returns layer style table.
virtual void | SetStyleTableDirectly (OGRStyleTable *poStyleTable)
| Set layer style table.
virtual void | SetStyleTable (OGRStyleTable *poStyleTable)
| Set layer style table.
virtual OGRErr | StartTransaction ()
| For datasources which support transactions, StartTransaction creates a transaction.
virtual OGRErr | CommitTransaction ()
| For datasources which support transactions, CommitTransaction commits a transaction.
virtual OGRErr | RollbackTransaction ()
| For datasources which support transactions, RollbackTransaction will roll back a datasource to its state before the start of the current transaction.
virtual OGRErr | SetIgnoredFields (CSLConstList papszFields)
| Set which fields can be omitted when retrieving features from the layer.
virtual OGRGeometryTypeCounter * | GetGeometryTypes (int iGeomField, int nFlagsGGT, int &nEntryCountOut, GDALProgressFunc pfnProgress, void *pProgressData)
| Get actual geometry types found in features.
OGRErr | Intersection (OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions=nullptr, GDALProgressFunc pfnProgress=nullptr, void *pProgressArg=nullptr)
| Intersection of two layers.
OGRErr | Union (OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions=nullptr, GDALProgressFunc pfnProgress=nullptr, void *pProgressArg=nullptr)
| Union of two layers.
OGRErr | SymDifference (OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions, GDALProgressFunc pfnProgress, void *pProgressArg)
| Symmetrical difference of two layers.
OGRErr | Identity (OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions=nullptr, GDALProgressFunc pfnProgress=nullptr, void *pProgressArg=nullptr)
| Identify the features of this layer with the ones from the identity layer.
OGRErr | Update (OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions=nullptr, GDALProgressFunc pfnProgress=nullptr, void *pProgressArg=nullptr)
| Update this layer with features from the update layer.
OGRErr | Clip (OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions=nullptr, GDALProgressFunc pfnProgress=nullptr, void *pProgressArg=nullptr)
| Clip off areas that are not covered by the method layer.
OGRErr | Erase (OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions=nullptr, GDALProgressFunc pfnProgress=nullptr, void *pProgressArg=nullptr)
| Remove areas that are covered by the method layer.
int | Reference ()
| Increment layer reference count.
int | Dereference ()
| Decrement layer reference count.
int | GetRefCount () const
| Fetch reference count.
OGRErr | ReorderField (int iOldFieldPos, int iNewFieldPos)
| Reorder an existing field on a layer.
int | GetMOFlags () const
| Returns the GMO_ flags.
void | SetMOFlags (int nFlagsIn)
| Assign GMO_flags.
virtual const char * | GetDescription () const
| Fetch object description.
virtual void | SetDescription (const char *)
| Set object description.
virtual char ** | GetMetadataDomainList ()
| Fetch list of metadata domains.
virtual char ** | GetMetadata (const char *pszDomain="")
| Fetch metadata.
virtual CPLErr | SetMetadata (char **papszMetadata, const char *pszDomain="")
| Set metadata.
virtual const char * | GetMetadataItem (const char *pszName, const char *pszDomain="")
| Fetch single metadata item.
virtual CPLErr | SetMetadataItem (const char *pszName, const char *pszValue, const char *pszDomain="")
| Set single metadata item.

## Static Public Member Functions
static OGRLayerH | ToHandle (OGRLayer *poLayer)
| Convert a OGRLayer* to a OGRLayerH.
static GDALMajorObjectH | ToHandle (GDALMajorObject *poMajorObject)
| Convert a GDALMajorObject* to a GDALMajorObjectH.
static OGRLayer * | FromHandle (OGRLayerH hLayer)
| Convert a OGRLayerH to a OGRLayer*.

## Static Public Attributes
static constexpr const char * | DEFAULT_ARROW_FID_NAME = "OGC_FID"
| Field name used by GetArrowSchema() for a FID column when GetFIDColumn() is not set.
static constexpr const char * | DEFAULT_ARROW_GEOMETRY_NAME = "wkb_geometry"
| Field name used by GetArrowSchema() for the name of the (single) geometry column (returned by GetGeometryColumn()) is not set.

## Protected Member Functions
virtual OGRErr | ISetFeature (OGRFeature *poFeature) override
| Rewrite/replace an existing feature.
virtual OGRErr | ICreateFeature (OGRFeature *poFeature) override
| Create and write a new feature within a layer.
virtual OGRErr | IUpsertFeature (OGRFeature *poFeature)
| Rewrite/replace an existing feature or create a new feature within a layer.
virtual OGRErr | IUpdateFeature (OGRFeature *poFeature, int nUpdatedFieldsCount, const int *panUpdatedFieldsIdx, int nUpdatedGeomFieldsCount, const int *panUpdatedGeomFieldsIdx, bool bUpdateStyleString)
| Update (part of) an existing feature.
virtual int | GetArrowSchema (struct ArrowArrayStream *, struct ArrowSchema *out_schema)
| Default implementation of the ArrowArrayStream::get_schema() callback.
virtual int | GetNextArrowArray (struct ArrowArrayStream *, struct ArrowArray *out_array)
| Default implementation of the ArrowArrayStream::get_next() callback.
virtual bool | CanPostFilterArrowArray (const struct ArrowSchema *schema) const
| Whether the PostFilterArrowArray() can work on the schema to remove rows that aren't selected by the spatial or attribute filter.
void | PostFilterArrowArray (const struct ArrowSchema *schema, struct ArrowArray *array, CSLConstList papszOptions) const
| Remove rows that aren't selected by the spatial or attribute filter.
char ** | BuildMetadataDomainList (char **papszList, int bCheckNonEmpty,...) CPL_NULL_TERMINATED
| Helper function for custom implementations of GetMetadataDomainList()

## Static Protected Member Functions
static void | ReleaseArray (struct ArrowArray *array)
| Release a ArrowArray.
static void | ReleaseSchema (struct ArrowSchema *schema)
| Release a ArrowSchema.
static void | ReleaseStream (struct ArrowArrayStream *stream)
| Release a ArrowArrayStream.
static int | StaticGetArrowSchema (struct ArrowArrayStream *, struct ArrowSchema *out_schema)
| Default implementation of the ArrowArrayStream::get_schema() callback.
static int | StaticGetNextArrowArray (struct ArrowArrayStream *, struct ArrowArray *out_array)
| Default implementation of the ArrowArrayStream::get_next() callback.
static const char * | GetLastErrorArrowArrayStream (struct ArrowArrayStream *)
| Default implementation of the ArrowArrayStream::get_last_error() callback.
static struct ArrowSchema * | CreateSchemaForWKBGeometryColumn (const OGRGeomFieldDefn *poFieldDefn, const char *pszArrowFormat, const char *pszExtensionName)
| Return a ArrowSchema* corresponding to the WKB encoding of a geometry column.

## Detailed Description

The OGRGNMWrappedResultLayer class for search paths queries results.

Since
  GDAL 2.1

## Member Function Documentation

## ◆ AlterFieldDefn()

OGRErr OGRLayer::AlterFieldDefn | ( | int | iField,
|  | OGRFieldDefn * | poNewFieldDefn,
|  | int | nFlags
| ) |  |
| virtual inherited

Alter the definition of an existing field on a layer.

You must use this to alter the definition of an existing field of a real layer. Internally the OGRFeatureDefn for the layer will be updated to reflect the altered field. Applications should never modify the OGRFeatureDefn used by a layer directly.

This method should not be called while there are feature objects in existence that were obtained or created with the previous layer definition.

Not all drivers support this method. You can query a layer to check if it supports it with the OLCAlterFieldDefn capability. Some drivers may only support this method while there are still no features in the layer. When it is supported, the existing features of the backing file/database should be updated accordingly. Some drivers might also not support all update flags.

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

Parameters

  iField | index of the field whose definition must be altered.
  poNewFieldDefn | new field definition
  nFlags | combination of ALTER_NAME_FLAG, ALTER_TYPE_FLAG, ALTER_WIDTH_PRECISION_FLAG, ALTER_NULLABLE_FLAG and ALTER_DEFAULT_FLAG to indicate which of the name and/or type and/or width and precision fields and/or nullability from the new field definition must be taken into account.

Returns
  OGRERR_NONE on success.

Since
  OGR 1.9.0

Reimplemented in GNMGenericLayer.

## ◆ AlterGeomFieldDefn()

OGRErr OGRLayer::AlterGeomFieldDefn | ( | int | iGeomField,
|  | const OGRGeomFieldDefn * | poNewGeomFieldDefn,
|  | int | nFlagsIn
| ) |  |
| virtual inherited

Alter the definition of an existing geometry field on a layer.

You must use this to alter the definition of an existing geometry field of a real layer. Internally the OGRFeatureDefn for the layer will be updated to reflect the altered field. Applications should never modify the OGRFeatureDefn used by a layer directly.

Note that altering the SRS does not cause coordinate reprojection to occur: this is simply a modification of the layer metadata (correcting a wrong SRS definition). No modification to existing geometries will ever be performed, so this method cannot be used to e.g. promote single part geometries to their multipart equivalents.

This method should not be called while there are feature objects in existence that were obtained or created with the previous layer definition.

Not all drivers support this method. You can query a layer to check if it supports it with the OLCAlterGeomFieldDefn capability. Some drivers might not support all update flags. The GDAL_DMD_ALTER_GEOM_FIELD_DEFN_FLAGS driver metadata item can be queried to examine which flags may be supported by a driver.

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

Parameters

  iGeomField | index of the field whose definition must be altered.
  poNewGeomFieldDefn | new field definition
  nFlagsIn | combination of ALTER_GEOM_FIELD_DEFN_NAME_FLAG, ALTER_GEOM_FIELD_DEFN_TYPE_FLAG, ALTER_GEOM_FIELD_DEFN_NULLABLE_FLAG, ALTER_GEOM_FIELD_DEFN_SRS_FLAG, ALTER_GEOM_FIELD_DEFN_SRS_COORD_EPOCH_FLAG to indicate which of the name and/or type and/or nullability and/or SRS and/or coordinate epoch from the new field definition must be taken into account. Or ALTER_GEOM_FIELD_DEFN_ALL_FLAG to update all members.

Returns
  OGRERR_NONE on success.

Since
  OGR 3.6.0

## ◆ begin()

OGRLayer::FeatureIterator OGRLayer::begin | ( |  | ) |
| inherited

Return begin of feature 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 the OGRFeatureUniquePtr reference is reused.

Only one iterator per layer can be active at a time.

Since
  GDAL 2.3

## ◆ BuildMetadataDomainList()

char ** GDALMajorObject::BuildMetadataDomainList | ( | char ** | papszList,
|  | int | bCheckNonEmpty,
|  |  | ...
| ) |  |
| protected inherited

Helper function for custom implementations of GetMetadataDomainList()

Parameters

  papszList | initial list of domains. May be NULL. Will become invalid after function call (use return value)
  bCheckNonEmpty | if TRUE, each candidate domain will be tested to be non empty
  ... | NULL terminated variadic list of candidate domains.

Returns
  NULL or a string list. Must be freed with CSLDestroy()

Since
  GDAL 1.11

## ◆ Clip()

OGRErr OGRLayer::Clip | ( | OGRLayer * | pLayerMethod,
|  | OGRLayer * | pLayerResult,
|  | char ** | papszOptions = `nullptr`,
|  | GDALProgressFunc | pfnProgress = `nullptr`,
|  | void * | pProgressArg = `nullptr`
| ) |  |
| inherited

Clip off areas that are not covered by the method layer.

The result layer contains features whose geometries represent areas that are in the input layer and in the method layer. The features in the result layer have the (possibly clipped) areas of features in the input layer and the attributes from the same features. The schema of the result layer can be set by the user or, if it is empty, is initialized to contain all fields in the input layer.

Note
  For best performance use the minimum amount of features in the method layer and copy it into a memory layer.
  This method relies on GEOS support. Do not use unless the GEOS support is compiled in.

The recognized list of options is :

- SKIP_FAILURES=YES/NO. Set it to YES to go on, even when a feature could not be inserted or a GEOS call failed.
- PROMOTE_TO_MULTI=YES/NO. Set to YES to convert Polygons into MultiPolygons, LineStrings to MultiLineStrings or Points to MultiPoints (only since GDAL 3.9.2 for the later)
- INPUT_PREFIX=string. Set a prefix for the field names that will be created from the fields of the input layer.
- METHOD_PREFIX=string. Set a prefix for the field names that will be created from the fields of the method layer.

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

Parameters

  pLayerMethod | the method layer. Should not be NULL.
  pLayerResult | the layer where the features resulting from the operation are inserted. Should not be NULL. See above the note about the schema.
  papszOptions | NULL terminated list of options (may be NULL).
  pfnProgress | a GDALProgressFunc() compatible callback function for reporting progress or NULL.
  pProgressArg | argument to be passed to pfnProgress. May be NULL.

Returns
  an error code if there was an error or the execution was interrupted, OGRERR_NONE otherwise.

Note
  The first geometry field is always used.

Since
  OGR 1.10

## ◆ CommitTransaction()

OGRErr OGRLayer::CommitTransaction | ( |  | ) |
| virtual inherited

For datasources which support transactions, CommitTransaction commits a transaction.

If no transaction is active, or the commit fails, will return OGRERR_FAILURE. Datasources which do not support transactions will always return OGRERR_NONE.

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

Returns
  OGRERR_NONE on success.

Reimplemented in GNMGenericLayer.

## ◆ CreateFeature()

OGRErr OGRLayer::CreateFeature | ( | OGRFeature * | poFeature | ) |
| inherited

Create and write a new feature within a layer.

The passed feature is written to the layer as a new feature, rather than overwriting an existing one. If the feature has a feature id other than OGRNullFID, then the native implementation may use that as the feature id of the new feature, but not necessarily. Upon successful return the passed feature will have been updated with the new feature id.

Starting with GDAL 2.0, drivers should specialize the ICreateFeature() method, since CreateFeature() is no longer virtual.

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

To create a feature, but set it if it exists see OGRLayer::UpsertFeature().

Parameters

  poFeature | the feature to write to disk.

Returns
  OGRERR_NONE on success.

See also
  SetFeature(), UpdateFeature(), UpsertFeature()

## ◆ CreateField()

OGRErr OGRGNMWrappedResultLayer::CreateField | ( | const OGRFieldDefn * | poField,
|  | int | bApproxOK = `TRUE`
| ) |  |
| override virtual

Create a new field on a layer.

You must use this to create new fields on a real layer. Internally the OGRFeatureDefn for the layer will be updated to reflect the new field. Applications should never modify the OGRFeatureDefn used by a layer directly.

This method should not be called while there are feature objects in existence that were obtained or created with the previous layer definition.

Not all drivers support this method. You can query a layer to check if it supports it with the OLCCreateField capability. Some drivers may only support this method while there are still no features in the layer. When it is supported, the existing features of the backing file/database should be updated accordingly.

Drivers may or may not support not-null constraints. If they support creating fields with not-null constraints, this is generally before creating any feature to the layer.

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

Parameters

  poField | field definition to write to disk.
  bApproxOK | If TRUE, the field may be created in a slightly different form depending on the limitations of the format driver.

Returns
  OGRERR_NONE on success.

Reimplemented from OGRLayer.

## ◆ CreateFieldFromArrowSchema()

bool OGRLayer::CreateFieldFromArrowSchema | ( | const struct ArrowSchema * | schema,
|  | CSLConstList | papszOptions = `nullptr`
| ) |  |
| virtual inherited

Creates a field from an ArrowSchema.

This should only be used for attribute fields. Geometry fields should be created with CreateGeomField(). The FID field should also not be passed with this method.

Contrary to the IsArrowSchemaSupported() and WriteArrowBatch() methods, the passed schema must be for an individual field, and thus, is not of type struct (format=+s) (unless writing a set of fields grouped together in the same structure).

Additional field metadata can be speciffed through the ArrowSchema::metadata field with the potential following items:

- "GDAL:OGR:alternative_name": value of OGRFieldDefn::GetAlternativeNameRef()
- "GDAL:OGR:comment": value of OGRFieldDefn::GetComment()
- "GDAL:OGR:default": value of OGRFieldDefn::GetDefault()
- "GDAL:OGR:subtype": value of OGRFieldDefn::GetSubType()
- "GDAL:OGR:width": value of OGRFieldDefn::GetWidth() (serialized as a string)
- "GDAL:OGR:unique": value of OGRFieldDefn::IsUnique() (serialized as "true" or "false")
- "GDAL:OGR:domain_name": value of OGRFieldDefn::GetDomainName()

This method and CreateField() are mutually exclusive in the same session.

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

Parameters

  schema | Schema of the field to create.
  papszOptions | Options (none currently). Null terminated list, or nullptr.

Returns
  true in case of success

Since
  3.8

## ◆ CreateGeomField()

OGRErr OGRGNMWrappedResultLayer::CreateGeomField | ( | const OGRGeomFieldDefn * | poField,
|  | int | bApproxOK = `TRUE`
| ) |  |
| override virtual

Create a new geometry field on a layer.

You must use this to create new geometry fields on a real layer. Internally the OGRFeatureDefn for the layer will be updated to reflect the new field. Applications should never modify the OGRFeatureDefn used by a layer directly.

This method should not be called while there are feature objects in existence that were obtained or created with the previous layer definition.

Not all drivers support this method. You can query a layer to check if it supports it with the OLCCreateGeomField capability. Some drivers may only support this method while there are still no features in the layer. When it is supported, the existing features of the backing file/database should be updated accordingly.

Drivers may or may not support not-null constraints. If they support creating fields with not-null constraints, this is generally before creating any feature to the layer.

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

Parameters

  poField | geometry field definition to write to disk.
  bApproxOK | If TRUE, the field may be created in a slightly different form depending on the limitations of the format driver.

Returns
  OGRERR_NONE on success.

Since
  OGR 1.11

Reimplemented from OGRLayer.

## ◆ DeleteFeature()

OGRErr OGRLayer::DeleteFeature | ( | GIntBig | nFID | ) |
| virtual inherited

Delete feature from layer.

The feature with the indicated feature id is deleted from the layer if supported by the driver. Most drivers do not support feature deletion, and will return OGRERR_UNSUPPORTED_OPERATION. The TestCapability() layer method may be called with OLCDeleteFeature to check if the driver supports feature deletion.

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

Parameters

  nFID | the feature id to be deleted from the layer

Returns
  OGRERR_NONE if the operation works, otherwise an appropriate error code (e.g OGRERR_NON_EXISTING_FEATURE if the feature does not exist).

Reimplemented in GNMGenericLayer.

## ◆ DeleteField()

OGRErr OGRLayer::DeleteField | ( | int | iField | ) |
| virtual inherited

Delete an existing field on a layer.

You must use this to delete existing fields on a real layer. Internally the OGRFeatureDefn for the layer will be updated to reflect the deleted field. Applications should never modify the OGRFeatureDefn used by a layer directly.

This method should not be called while there are feature objects in existence that were obtained or created with the previous layer definition.

Not all drivers support this method. You can query a layer to check if it supports it with the OLCDeleteField capability. Some drivers may only support this method while there are still no features in the layer. When it is supported, the existing features of the backing file/database should be updated accordingly.

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

Parameters

  iField | index of the field to delete.

Returns
  OGRERR_NONE on success.

Since
  OGR 1.9.0

Reimplemented in GNMGenericLayer.

## ◆ Dereference()

int OGRLayer::Dereference | ( |  | ) |
| inherited

Decrement layer reference count.

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

Returns
  the reference count after decrementing.

## ◆ Erase()

OGRErr OGRLayer::Erase | ( | OGRLayer * | pLayerMethod,
|  | OGRLayer * | pLayerResult,
|  | char ** | papszOptions = `nullptr`,
|  | GDALProgressFunc | pfnProgress = `nullptr`,
|  | void * | pProgressArg = `nullptr`
| ) |  |
| inherited

Remove areas that are covered by the method layer.

The result layer contains features whose geometries represent areas that are in the input layer but not in the method layer. The features in the result layer have attributes from the input layer. The schema of the result layer can be set by the user or, if it is empty, is initialized to contain all fields in the input layer.

Note
  For best performance use the minimum amount of features in the method layer and copy it into a memory layer.
  This method relies on GEOS support. Do not use unless the GEOS support is compiled in.

The recognized list of options is :

- SKIP_FAILURES=YES/NO. Set it to YES to go on, even when a feature could not be inserted or a GEOS call failed.
- PROMOTE_TO_MULTI=YES/NO. Set to YES to convert Polygons into MultiPolygons, LineStrings to MultiLineStrings or Points to MultiPoints (only since GDAL 3.9.2 for the later)
- INPUT_PREFIX=string. Set a prefix for the field names that will be created from the fields of the input layer.
- METHOD_PREFIX=string. Set a prefix for the field names that will be created from the fields of the method layer.

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

Parameters

  pLayerMethod | the method layer. Should not be NULL.
  pLayerResult | the layer where the features resulting from the operation are inserted. Should not be NULL. See above the note about the schema.
  papszOptions | NULL terminated list of options (may be NULL).
  pfnProgress | a GDALProgressFunc() compatible callback function for reporting progress or NULL.
  pProgressArg | argument to be passed to pfnProgress. May be NULL.

Returns
  an error code if there was an error or the execution was interrupted, OGRERR_NONE otherwise.

Note
  The first geometry field is always used.

Since
  OGR 1.10

## ◆ FindFieldIndex()

int OGRLayer::FindFieldIndex | ( | const char * | pszFieldName,
|  | int | bExactMatch
| ) |  |
| virtual inherited

Find the index of field in the layer.

The returned number is the index of the field in the layers, or -1 if the field doesn't exist.

If bExactMatch is set to FALSE and the field doesn't exists in the given form the driver might apply some changes to make it match, like those it might do if the layer was created (eg. like LAUNDER in the OCI driver).

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

Returns
  field index, or -1 if the field doesn't exist

Reimplemented in GNMGenericLayer.

## ◆ FromHandle()

static OGRLayer * OGRLayer::FromHandle | ( | OGRLayerH | hLayer | ) |
| inline static inherited

Convert a OGRLayerH to a OGRLayer*.

Since
  GDAL 2.3

## ◆ GetArrowSchema()

int OGRLayer::GetArrowSchema | ( | struct ArrowArrayStream * | ,
|  | struct ArrowSchema * | out_schema
| ) |  |
| protected virtual inherited

Default implementation of the ArrowArrayStream::get_schema() callback.

To be used by driver implementations that have a custom GetArrowStream() implementation.

Since
  GDAL 3.6

## ◆ GetArrowStream()

bool OGRLayer::GetArrowStream | ( | struct ArrowArrayStream * | out_stream,
|  | CSLConstList | papszOptions = `nullptr`
| ) |  |
| virtual inherited

Get a Arrow C stream.

On successful return, and when the stream interfaces is no longer needed, it must must be freed with out_stream->release(out_stream). Please carefully read https://arrow.apache.org/docs/format/CStreamInterface.html for more details on using Arrow C stream.

The method may take into account ignored fields set with SetIgnoredFields() (the default implementation does), and should take into account filters set with SetSpatialFilter() and SetAttributeFilter(). Note however that specialized implementations may fallback to the default (slower) implementation when filters are set. Drivers that have a specialized implementation should advertise the OLCFastGetArrowStream capability.

There are extra precautions to take into account in a OGR context. Unless otherwise specified by a particular driver implementation, the get_schema(), get_next() and get_last_error() function pointers of the ArrowArrayStream structure should no longer be used after the OGRLayer, from which the ArrowArrayStream structure was initialized, has been destroyed (typically at dataset closing). The reason is that those function pointers will typically point to methods of the OGRLayer instance. However, the ArrowSchema and ArrowArray structures filled from those callbacks can be used and must be released independently from the ArrowArrayStream or the layer.

Furthermore, unless otherwise specified by a particular driver implementation, only one ArrowArrayStream can be active at a time on a given layer (that is the last active one must be explicitly released before a next one is asked). Changing filter state, ignored columns, modifying the schema or using ResetReading()/GetNextFeature() while using a ArrowArrayStream is strongly discouraged and may lead to unexpected results. As a rule of thumb, no OGRLayer methods that affect the state of a layer should be called on a layer, while an ArrowArrayStream on it is active.

Starting with GDAL 3.8, the ArrowSchema::metadata field filled by the get_schema() callback may be set with the potential following items:

- "GDAL:OGR:alternative_name": value of OGRFieldDefn::GetAlternativeNameRef()
- "GDAL:OGR:comment": value of OGRFieldDefn::GetComment()
- "GDAL:OGR:default": value of OGRFieldDefn::GetDefault()
- "GDAL:OGR:subtype": value of OGRFieldDefn::GetSubType()
- "GDAL:OGR:width": value of OGRFieldDefn::GetWidth() (serialized as a string)
- "GDAL:OGR:unique": value of OGRFieldDefn::IsUnique() (serialized as "true" or "false")
- "GDAL:OGR:domain_name": value of OGRFieldDefn::GetDomainName()

A potential usage can be:

struct ArrowArrayStream stream;
if( !poLayer->GetArrowStream(&stream, nullptr))
{
CPLError(CE_Failure, CPLE_AppDefined, "GetArrowStream() failed\n");
exit(1);
}
struct ArrowSchema schema;
if( stream.get_schema(&stream, &schema) == 0 )
{
// Do something useful
schema.release(schema);
}
while( true )
{
struct ArrowArray array;
// Look for an error (get_next() returning a non-zero code), or
// end of iteration (array.release == nullptr)
if( stream.get_next(&stream, &array) != 0 ||
array.release == nullptr )
{
break;
}
// Do something useful
array.release(&array);
}
stream.release(&stream);
CPLE_AppDefined
#define CPLE_AppDefined
Application defined error.
Definition cpl_error.h:100

A full example is available in the Reading From OGR using the Arrow C Stream data interface tutorial.

Options may be driver specific. The default implementation recognizes the following options:

- INCLUDE_FID=YES/NO. Whether to include the FID column. Defaults to YES.
- MAX_FEATURES_IN_BATCH=integer. Maximum number of features to retrieve in a ArrowArray batch. Defaults to 65 536.
- TIMEZONE="unknown", "UTC", "(+|:)HH:MM" or any other value supported by Arrow. (GDAL >= 3.8) Override the timezone flag nominally provided by OGRFieldDefn::GetTZFlag(), and used for the Arrow field timezone declaration, with a user specified timezone. Note that datetime values in Arrow arrays are always stored in UTC, and that the time zone flag used by GDAL to convert to UTC is the one of the OGRField::Date::TZFlag member at the OGRFeature level. The conversion to UTC of a OGRField::Date is only done if both the timezone indicated by OGRField::Date::TZFlag and the one at the OGRFieldDefn level (or set by this TIMEZONE option) are not unknown.
- GEOMETRY_METADATA_ENCODING=OGC/GEOARROW (GDAL >= 3.8). The default is OGC, which will lead to setting the Arrow geometry column metadata to ARROW:extension:name=ogc.wkb. If setting to GEOMETRY_METADATA_ENCODING to GEOARROW, ARROW:extension:name=geoarrow.wkb and ARROW:extension:metadata={"crs": <projjson CRS representation>> are set.

The Arrow/Parquet drivers recognize the following option:

- GEOMETRY_ENCODING=WKB. To force a fallback to the generic implementation when the native geometry encoding is not WKB. Otherwise the geometry will be returned with its native Arrow encoding (possibly using GeoArrow encoding).

Parameters

  out_stream | Output stream. Must not be NULL. The content of the structure does not need to be initialized.
  papszOptions | NULL terminated list of key=value options.

Returns
  true in case of success.

Since
  GDAL 3.6

## ◆ GetDataset()

GDALDataset * OGRLayer::GetDataset | ( |  | ) |
| virtual inherited

Return the dataset associated with this layer.

As of GDAL 3.9, GetDataset() is implemented on all in-tree drivers that have CreateLayer() capability. It may not be implemented in read-only drivers or out-of-tree drivers.

It is currently only used by the GetRecordBatchSchema() method to retrieve the field domain associated with a field, to fill the dictionary field of a struct ArrowSchema. It is also used by CreateFieldFromArrowSchema() to determine which field types and subtypes are supported by the layer, by inspecting the driver metadata, and potentially use fallback types when needed.

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

Returns
  dataset, or nullptr when unknown.

Since
  GDAL 3.6

## ◆ GetDescription()

const char * GDALMajorObject::GetDescription | ( |  | ) | const
| virtual inherited

Fetch object description.

The semantics of the returned description are specific to the derived type. For GDALDatasets it is the dataset name. For GDALRasterBands it is actually a description (if supported) or "".

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

Returns
  non-null pointer to internal description string.

## ◆ GetExtent() [1/2]

OGRErr OGRLayer::GetExtent | ( | int | iGeomField,
|  | OGREnvelope * | psExtent,
|  | int | bForce = `TRUE`
| ) |  |
| virtual inherited

Fetch the extent of this layer, on the specified geometry field.

Returns the extent (MBR) of the data in the layer. If bForce is FALSE, and it would be expensive to establish the extent then OGRERR_FAILURE will be returned indicating that the extent isn't know. If bForce is TRUE then some implementations will actually scan the entire layer once to compute the MBR of all the features in the layer.

Depending on the drivers, the returned extent may or may not take the spatial filter into account. So it is safer to call GetExtent() without setting a spatial filter.

Layers without any geometry may return OGRERR_FAILURE just indicating that no meaningful extents could be collected.

Note that some implementations of this method may alter the read cursor of the layer.

Note to driver implementer: if you implement GetExtent(int,OGREnvelope*,int), you must also implement GetExtent(OGREnvelope*, int) to make it call GetExtent(0,OGREnvelope*,int).

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

Parameters

  iGeomField | the index of the geometry field on which to compute the extent.
  psExtent | the structure in which the extent value will be returned.
  bForce | Flag indicating whether the extent should be computed even if it is expensive.

Returns
  OGRERR_NONE on success, OGRERR_FAILURE if extent not known.

Reimplemented in GNMGenericLayer.

## ◆ GetExtent() [2/2]

OGRErr OGRLayer::GetExtent | ( | OGREnvelope * | psExtent,
|  | int | bForce = `TRUE`
| ) |  |
| virtual inherited

Fetch the extent of this layer.

Returns the extent (MBR) of the data in the layer. If bForce is FALSE, and it would be expensive to establish the extent then OGRERR_FAILURE will be returned indicating that the extent isn't know. If bForce is TRUE then some implementations will actually scan the entire layer once to compute the MBR of all the features in the layer.

Depending on the drivers, the returned extent may or may not take the spatial filter into account. So it is safer to call GetExtent() without setting a spatial filter.

Layers without any geometry may return OGRERR_FAILURE just indicating that no meaningful extents could be collected.

Note that some implementations of this method may alter the read cursor of the layer.

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

Parameters

  psExtent | the structure in which the extent value will be returned.
  bForce | Flag indicating whether the extent should be computed even if it is expensive.

Returns
  OGRERR_NONE on success, OGRERR_FAILURE if extent not known.

Reimplemented in GNMGenericLayer.

## ◆ GetExtent3D()

OGRErr OGRLayer::GetExtent3D | ( | int | iGeomField,
|  | OGREnvelope3D * | psExtent3D,
|  | int | bForce = `TRUE`
| ) |  |
| virtual inherited

Fetch the 3D extent of this layer, on the specified geometry field.

Returns the 3D extent (MBR) of the data in the layer. If bForce is FALSE, and it would be expensive to establish the extent then OGRERR_FAILURE will be returned indicating that the extent isn't know. If bForce is TRUE then some implementations will actually scan the entire layer once to compute the MBR of all the features in the layer.

(Contrarty to GetExtent() 2D), the returned extent will always take into account the attribute and spatial filters that may be installed.

Layers without any geometry may return OGRERR_FAILURE just indicating that no meaningful extents could be collected.

For layers that have no 3D geometries, the psExtent3D->MinZ and psExtent3D->MaxZ fields will be respectively set to +Infinity and -Infinity.

Note that some implementations of this method may alter the read cursor of the layer.

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

Parameters

  iGeomField | 0-based index of the geometry field to consider.
  psExtent3D | the computed 3D extent of the layer.
  bForce | if TRUE, the extent will be computed even if all the layer features have to be fetched.

Returns
  OGRERR_NONE on success or an error code in case of failure.

Since
  GDAL 3.9

## ◆ GetFeature()

OGRFeature * OGRGNMWrappedResultLayer::GetFeature | ( | GIntBig | nFID | ) |
| override virtual

Fetch a feature by its identifier.

This function will attempt to read the identified feature. The nFID value cannot be OGRNullFID. Success or failure of this operation is unaffected by the spatial or attribute filters (and specialized implementations in drivers should make sure that they do not take into account spatial or attribute filters).

If this method returns a non-NULL feature, it is guaranteed that its feature id (OGRFeature::GetFID()) will be the same as nFID.

Use OGRLayer::TestCapability(OLCRandomRead) to establish if this layer supports efficient random access reading via GetFeature(); however, the call should always work if the feature exists as a fallback implementation just scans all the features in the layer looking for the desired feature.

Sequential reads (with GetNextFeature()) are generally considered interrupted by a GetFeature() call.

The returned feature should be free with OGRFeature::DestroyFeature().

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

Parameters

  nFID | the feature id of the feature to read.

Returns
  a feature now owned by the caller, or NULL on failure.

Reimplemented from OGRLayer.

## ◆ GetFeatureCount()

GIntBig OGRGNMWrappedResultLayer::GetFeatureCount | ( | int | bForce = `TRUE` | ) |
| override virtual

Fetch the feature count in this layer.

Returns the number of features in the layer. For dynamic databases the count may not be exact. If bForce is FALSE, and it would be expensive to establish the feature count a value of -1 may be returned indicating that the count isn't know. If bForce is TRUE some implementations will actually scan the entire layer once to count objects.

The returned count takes the spatial filter into account.

Note that some implementations of this method may alter the read cursor of the layer.

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

Note: since GDAL 2.0, this method returns a GIntBig (previously a int)

Parameters

  bForce | Flag indicating whether the count should be computed even if it is expensive.

Returns
  feature count, -1 if count not known.

Reimplemented from OGRLayer.

## ◆ GetFIDColumn()

const char * OGRGNMWrappedResultLayer::GetFIDColumn | ( |  | ) |
| override virtual

This method returns the name of the underlying database column being used as the FID column, or "" if not supported.

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

Returns
  fid column name.

Reimplemented from OGRLayer.

## ◆ GetGeometryColumn()

const char * OGRGNMWrappedResultLayer::GetGeometryColumn | ( |  | ) |
| override virtual

This method returns the name of the underlying database column being used as the geometry column, or "" if not supported.

For layers with multiple geometry fields, this method only returns the name of the first geometry column. For other columns, use GetLayerDefn()->OGRFeatureDefn::GetGeomFieldDefn(i)->GetNameRef().

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

Returns
  geometry column name.

Reimplemented from OGRLayer.

## ◆ GetGeometryTypes()

OGRGeometryTypeCounter * OGRLayer::GetGeometryTypes | ( | int | iGeomField,
|  | int | nFlagsGGT,
|  | int & | nEntryCountOut,
|  | GDALProgressFunc | pfnProgress,
|  | void * | pProgressData
| ) |  |
| virtual inherited

Get actual geometry types found in features.

This method iterates over features to retrieve their geometry types. This is mostly useful for layers that report a wkbUnknown geometry type with GetGeomType() or GetGeomFieldDefn(iGeomField)->GetType().

By default this method returns an array of nEntryCount entries with each geometry type (in OGRGeometryTypeCounter::eGeomType) and the corresponding number of features (in OGRGeometryTypeCounter::nCount). Features without geometries are reported as eGeomType == wkbNone.

The nFlagsGGT parameter can be a combination (with binary or operator) of the following hints:

- OGR_GGT_COUNT_NOT_NEEDED: to indicate that only the set of geometry types matter, not the number of features per geometry type. Consequently the value of OGRGeometryTypeCounter::nCount should be ignored.
- OGR_GGT_STOP_IF_MIXED: to indicate that the implementation may stop iterating over features as soon as 2 different geometry types (not counting null geometries) are found. The value of OGRGeometryTypeCounter::nCount should be ignored (zero might be systematically reported by some implementations).
- OGR_GGT_GEOMCOLLECTIONZ_TINZ: to indicate that if a geometry is of type wkbGeometryCollection25D and its first sub-geometry is of type wkbTINZ, wkbTINZ should be reported as geometry type. This is mostly useful for the ESRI Shapefile and (Open)FileGDB drivers regarding MultiPatch geometries.

If the layer has no features, a non-NULL returned array with nEntryCount == 0 will be returned.

Spatial and/or attribute filters will be taken into account.

This method will error out on a layer without geometry fields (GetGeomType() == wkbNone).

A cancellation callback may be provided. The progress percentage it is called with is not relevant. The callback should return TRUE if processing should go on, or FALSE if it should be interrupted.

Parameters

  | iGeomField | Geometry field index.
  | nFlagsGGT | Hint flags. 0, or combination of OGR_GGT_COUNT_NOT_NEEDED, OGR_GGT_STOP_IF_MIXED, OGR_GGT_GEOMCOLLECTIONZ_TINZ
  [out] | nEntryCountOut | Number of entries in the returned array.
  | pfnProgress | Cancellation callback. May be NULL.
  | pProgressData | User data for the cancellation callback. May be NULL.

Returns
  an array of nEntryCount that must be freed with CPLFree(), or NULL in case of error

Since
  GDAL 3.6

## ◆ GetGeomType()

OGRwkbGeometryType OGRLayer::GetGeomType | ( |  | ) |
| virtual inherited

Return the layer geometry type.

This returns the same result as GetLayerDefn()->OGRFeatureDefn::GetGeomType(), but for a few drivers, calling GetGeomType() directly can avoid lengthy layer definition initialization.

For layers with multiple geometry fields, this method only returns the geometry type of the first geometry column. For other columns, use GetLayerDefn()->OGRFeatureDefn::GetGeomFieldDefn(i)->GetType(). For layers without any geometry field, this method returns wkbNone.

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

If this method is derived in a driver, it must be done such that it returns the same content as GetLayerDefn()->OGRFeatureDefn::GetGeomType().

Returns
  the geometry type

Since
  OGR 1.8.0

Reimplemented in GNMGenericLayer.

## ◆ GetLastErrorArrowArrayStream()

const char * OGRLayer::GetLastErrorArrowArrayStream | ( | struct ArrowArrayStream * |  | ) |
| static protected inherited

Default implementation of the ArrowArrayStream::get_last_error() callback.

To be used by driver implementations that have a custom GetArrowStream() implementation.

Since
  GDAL 3.6

## ◆ GetLayerDefn()

OGRFeatureDefn * OGRGNMWrappedResultLayer::GetLayerDefn | ( |  | ) |
| override virtual

Fetch the schema information for this layer.

The returned OGRFeatureDefn is owned by the OGRLayer, and should not be modified or freed by the application. It encapsulates the attribute schema of the features of the layer.

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

Returns
  feature definition.

Implements OGRLayer.

## ◆ GetMetadata()

char ** GDALMajorObject::GetMetadata | ( | const char * | pszDomain = `""` | ) |
| virtual inherited

Fetch metadata.

The returned string list is owned by the object, and may change at any time. It is formatted as a "Name=value" list with the last pointer value being NULL. Use the CPL StringList functions such as CSLFetchNameValue() to manipulate it.

Note that relatively few formats return any metadata at this time.

This method does the same thing as the C function GDALGetMetadata().

Parameters

  pszDomain | the domain of interest. Use "" or NULL for the default domain.

Returns
  NULL or a string list.

Reimplemented in GDALPluginDriverProxy, GDALPamDataset, and GDALDataset.

## ◆ GetMetadataDomainList()

char ** GDALMajorObject::GetMetadataDomainList | ( |  | ) |
| virtual inherited

Fetch list of metadata domains.

The returned string list is the list of (non-empty) metadata domains.

This method does the same thing as the C function GDALGetMetadataDomainList().

Returns
  NULL or a string list. Must be freed with CSLDestroy()

Since
  GDAL 1.11

Reimplemented in GDALDataset.

## ◆ GetMetadataItem()

const char * GDALMajorObject::GetMetadataItem | ( | const char * | pszName,
|  | const char * | pszDomain = `""`
| ) |  |
| virtual inherited

Fetch single metadata item.

The C function GDALGetMetadataItem() does the same thing as this method.

Parameters

  pszName | the key for the metadata item to fetch.
  pszDomain | the domain to fetch for, use NULL for the default domain.

Returns
  NULL on failure to find the key, or a pointer to an internal copy of the value string on success.

Reimplemented in GDALPamDataset, GDALRasterBand, and GDALPluginDriverProxy.

## ◆ GetMOFlags()

int GDALMajorObject::GetMOFlags | ( |  | ) | const
| inherited

Returns the GMO_ flags.

Returns
  flags

## ◆ GetName()

const char * OGRLayer::GetName | ( |  | ) |
| virtual inherited

Return the layer name.

This returns the same content as GetLayerDefn()->OGRFeatureDefn::GetName(), but for a few drivers, calling GetName() directly can avoid lengthy layer definition initialization.

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

If this method is derived in a driver, it must be done such that it returns the same content as GetLayerDefn()->OGRFeatureDefn::GetName().

Returns
  the layer name (must not been freed)

Since
  OGR 1.8.0

Reimplemented in GNMGenericLayer.

## ◆ GetNextArrowArray()

int OGRLayer::GetNextArrowArray | ( | struct ArrowArrayStream * | stream,
|  | struct ArrowArray * | out_array
| ) |  |
| protected virtual inherited

Default implementation of the ArrowArrayStream::get_next() callback.

To be used by driver implementations that have a custom GetArrowStream() implementation.

Since
  GDAL 3.6

## ◆ GetNextFeature()

OGRFeature * OGRGNMWrappedResultLayer::GetNextFeature | ( |  | ) |
| override virtual

Fetch the next available feature from this layer.

The returned feature becomes the responsibility of the caller to delete with OGRFeature::DestroyFeature(). It is critical that all features associated with an OGRLayer (more specifically an OGRFeatureDefn) be deleted before that layer/datasource is deleted.

Only features matching the current spatial filter (set with SetSpatialFilter()) will be returned.

This method implements sequential access to the features of a layer. The ResetReading() method can be used to start at the beginning again.

Starting with GDAL 3.6, it is possible to retrieve them by batches, with a column-oriented memory layout, using the GetArrowStream() method.

Features returned by GetNextFeature() may or may not be affected by concurrent modifications depending on drivers. A guaranteed way of seeing modifications in effect is to call ResetReading() on layers where GetNextFeature() has been called, before reading again. Structural changes in layers (field addition, deletion, ...) when a read is in progress may or may not be possible depending on drivers. If a transaction is committed/aborted, the current sequential reading may or may not be valid after that operation and a call to ResetReading() might be needed.

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

Returns
  a feature, or NULL if no more features are available.

Implements OGRLayer.

## ◆ GetRefCount()

int OGRLayer::GetRefCount | ( |  | ) | const
| inherited

Fetch reference count.

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

Returns
  the current reference count for the layer object itself.

## ◆ GetSpatialFilter()

OGRGeometry * OGRLayer::GetSpatialFilter | ( |  | ) |
| virtual inherited

This method returns the current spatial filter for this layer.

The returned pointer is to an internally owned object, and should not be altered or deleted by the caller.

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

Returns
  spatial filter geometry.

Reimplemented in GNMGenericLayer.

## ◆ GetSpatialRef()

OGRSpatialReference * OGRGNMWrappedResultLayer::GetSpatialRef | ( |  | ) |
| override virtual

Fetch the spatial reference system for this layer.

The returned object is owned by the OGRLayer and should not be modified or freed by the application.

Starting with OGR 1.11, several geometry fields can be associated to a feature definition. Each geometry field can have its own spatial reference system, which is returned by OGRGeomFieldDefn::GetSpatialRef(). OGRLayer::GetSpatialRef() is equivalent to GetLayerDefn()->OGRFeatureDefn::GetGeomFieldDefn(0)->GetSpatialRef()

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

Returns
  spatial reference, or NULL if there isn't one.

Reimplemented from OGRLayer.

## ◆ GetStyleTable()

OGRStyleTable * OGRLayer::GetStyleTable | ( |  | ) |
| virtual inherited

Returns layer style table.

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

Returns
  pointer to a style table which should not be modified or freed by the caller.

Reimplemented in GNMGenericLayer.

## ◆ GetSupportedSRSList()

const OGRLayer::GetSupportedSRSListRetType & OGRLayer::GetSupportedSRSList | ( | int | iGeomField | ) |
| virtual inherited

Get the list of SRS supported.

The base implementation of this method will return an empty list. Some drivers (OAPIF, WFS) may return a non-empty list.

One of the SRS returned may be passed to SetActiveSRS() to change the active SRS.

Parameters

  iGeomField | Geometry field index.

Returns
  list of supported SRS.

Since
  GDAL 3.7

## ◆ ICreateFeature()

OGRErr OGRGNMWrappedResultLayer::ICreateFeature | ( | OGRFeature * | poFeature | ) |
| override protected virtual

Create and write a new feature within a layer.

This method is implemented by drivers and not called directly. User code should use CreateFeature() instead.

The passed feature is written to the layer as a new feature, rather than overwriting an existing one. If the feature has a feature id other than OGRNullFID, then the native implementation may use that as the feature id of the new feature, but not necessarily. Upon successful return the passed feature will have been updated with the new feature id.

Parameters

  poFeature | the feature to write to disk.

Returns
  OGRERR_NONE on success.

Since
  GDAL 2.0

See also
  CreateFeature()

Reimplemented from OGRLayer.

## ◆ Identity()

OGRErr OGRLayer::Identity | ( | OGRLayer * | pLayerMethod,
|  | OGRLayer * | pLayerResult,
|  | char ** | papszOptions = `nullptr`,
|  | GDALProgressFunc | pfnProgress = `nullptr`,
|  | void * | pProgressArg = `nullptr`
| ) |  |
| inherited

Identify the features of this layer with the ones from the identity layer.

The result layer contains features whose geometries represent areas that are in the input layer. The features in the result layer have attributes from both input and method layers. The schema of the result layer can be set by the user or, if it is empty, is initialized to contain all fields in input and method layers.

Note
  If the schema of the result is set by user and contains fields that have the same name as a field in input and in method layer, then the attribute in the result feature will get the value from the feature of the method layer (even if it is undefined).
  For best performance use the minimum amount of features in the method layer and copy it into a memory layer.
  This method relies on GEOS support. Do not use unless the GEOS support is compiled in.

The recognized list of options is :

- SKIP_FAILURES=YES/NO. Set it to YES to go on, even when a feature could not be inserted or a GEOS call failed.
- PROMOTE_TO_MULTI=YES/NO. Set to YES to convert Polygons into MultiPolygons, LineStrings to MultiLineStrings or Points to MultiPoints (only since GDAL 3.9.2 for the later)
- INPUT_PREFIX=string. Set a prefix for the field names that will be created from the fields of the input layer.
- METHOD_PREFIX=string. Set a prefix for the field names that will be created from the fields of the method layer.
- USE_PREPARED_GEOMETRIES=YES/NO. Set to NO to not use prepared geometries to pretest intersection of features of method layer with features of this layer.
- KEEP_LOWER_DIMENSION_GEOMETRIES=YES/NO. Set to NO to skip result features with lower dimension geometry that would otherwise be added to the result layer. The default is YES, to add features with lower dimension geometry, but only if the result layer has an unknown geometry type.

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

Parameters

  pLayerMethod | the method layer. Should not be NULL.
  pLayerResult | the layer where the features resulting from the operation are inserted. Should not be NULL. See above the note about the schema.
  papszOptions | NULL terminated list of options (may be NULL).
  pfnProgress | a GDALProgressFunc() compatible callback function for reporting progress or NULL.
  pProgressArg | argument to be passed to pfnProgress. May be NULL.

Returns
  an error code if there was an error or the execution was interrupted, OGRERR_NONE otherwise.

Note
  The first geometry field is always used.

Since
  OGR 1.10

## ◆ Intersection()

OGRErr OGRLayer::Intersection | ( | OGRLayer * | pLayerMethod,
|  | OGRLayer * | pLayerResult,
|  | char ** | papszOptions = `nullptr`,
|  | GDALProgressFunc | pfnProgress = `nullptr`,
|  | void * | pProgressArg = `nullptr`
| ) |  |
| inherited

Intersection of two layers.

The result layer contains features whose geometries represent areas that are common between features in the input layer and in the method layer. The features in the result layer have attributes from both input and method layers. The schema of the result layer can be set by the user or, if it is empty, is initialized to contain all fields in the input and method layers.

Note
  If the schema of the result is set by user and contains fields that have the same name as a field in input and in method layer, then the attribute in the result feature will get the value from the feature of the method layer.
  For best performance use the minimum amount of features in the method layer and copy it into a memory layer.
  This method relies on GEOS support. Do not use unless the GEOS support is compiled in.

The recognized list of options is:

- SKIP_FAILURES=YES/NO. Set to YES to go on, even when a feature could not be inserted or a GEOS call failed.
- PROMOTE_TO_MULTI=YES/NO. Set to YES to convert Polygons into MultiPolygons, LineStrings to MultiLineStrings or Points to MultiPoints (only since GDAL 3.9.2 for the later)
- INPUT_PREFIX=string. Set a prefix for the field names that will be created from the fields of the input layer.
- METHOD_PREFIX=string. Set a prefix for the field names that will be created from the fields of the method layer.
- USE_PREPARED_GEOMETRIES=YES/NO. Set to NO to not use prepared geometries to pretest intersection of features of method layer with features of this layer.
- PRETEST_CONTAINMENT=YES/NO. Set to YES to pretest the containment of features of method layer within the features of this layer. This will speed up the method significantly in some cases. Requires that the prepared geometries are in effect.
- KEEP_LOWER_DIMENSION_GEOMETRIES=YES/NO. Set to NO to skip result features with lower dimension geometry that would otherwise be added to the result layer. The default is YES, to add features with lower dimension geometry, but only if the result layer has an unknown geometry type.

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

Parameters

  pLayerMethod | the method layer. Should not be NULL.
  pLayerResult | the layer where the features resulting from the operation are inserted. Should not be NULL. See above the note about the schema.
  papszOptions | NULL terminated list of options (may be NULL).
  pfnProgress | a GDALProgressFunc() compatible callback function for reporting progress or NULL.
  pProgressArg | argument to be passed to pfnProgress. May be NULL.

Returns
  an error code if there was an error or the execution was interrupted, OGRERR_NONE otherwise.

Note
  The first geometry field is always used.

Since
  OGR 1.10

## ◆ IsArrowSchemaSupported()

bool OGRLayer::IsArrowSchemaSupported | ( | const struct ArrowSchema * | schema,
|  | CSLConstList | papszOptions,
|  | std::string & | osErrorMsg
| ) |  | const
| virtual inherited

Returns whether the provided ArrowSchema is supported for writing.

This method exists since not all drivers may support all Arrow data types.

The ArrowSchema must be of type struct (format=+s)

It is recommended to call this method before calling WriteArrowBatch().

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

Parameters

  | schema | Schema of type struct (format = '+s')
  | papszOptions | Options (none currently). Null terminated list, or nullptr.
  [out] | osErrorMsg | Reason of the failure, when this method returns false.

Returns
  true if the ArrowSchema is supported for writing.

Since
  3.8

## ◆ ISetFeature()

OGRErr OGRGNMWrappedResultLayer::ISetFeature | ( | OGRFeature * | poFeature | ) |
| override protected virtual

Rewrite/replace an existing feature.

This method is implemented by drivers and not called directly. User code should use SetFeature() instead.

This method will write a feature to the layer, based on the feature id within the OGRFeature.

Parameters

  poFeature | the feature to write.

Returns
  OGRERR_NONE if the operation works, otherwise an appropriate error code (e.g OGRERR_NON_EXISTING_FEATURE if the feature does not exist).

Since
  GDAL 2.0

See also
  SetFeature()

Reimplemented from OGRLayer.

## ◆ IUpdateFeature()

OGRErr OGRLayer::IUpdateFeature | ( | OGRFeature * | poFeature,
|  | int | nUpdatedFieldsCount,
|  | const int * | panUpdatedFieldsIdx,
|  | int | nUpdatedGeomFieldsCount,
|  | const int * | panUpdatedGeomFieldsIdx,
|  | bool | bUpdateStyleString
| ) |  |
| protected virtual inherited

Update (part of) an existing feature.

This method is implemented by drivers and not called directly. User code should use UpdateFeature() instead.

Parameters

  poFeature | the feature to update.
  nUpdatedFieldsCount | number of attribute fields to update. May be 0
  panUpdatedFieldsIdx | array of nUpdatedFieldsCount values, each between 0 and GetLayerDefn()->GetFieldCount() - 1, indicating which fields of poFeature must be updated in the layer.
  nUpdatedGeomFieldsCount | number of geometry fields to update. May be 0
  panUpdatedGeomFieldsIdx | array of nUpdatedGeomFieldsCount values, each between 0 and GetLayerDefn()->GetGeomFieldCount() - 1, indicating which geometry fields of poFeature must be updated in the layer.
  bUpdateStyleString | whether the feature style string in the layer should be updated with the one of poFeature.

Returns
  OGRERR_NONE if the operation works, otherwise an appropriate error code (e.g OGRERR_NON_EXISTING_FEATURE if the feature does not exist).

Since
  GDAL 3.7

See also
  UpdateFeature()

## ◆ IUpsertFeature()

OGRErr OGRLayer::IUpsertFeature | ( | OGRFeature * | poFeature | ) |
| protected virtual inherited

Rewrite/replace an existing feature or create a new feature within a layer.

This method is implemented by drivers and not called directly. User code should use UpsertFeature() instead.

This function will write a feature to the layer, based on the feature id within the OGRFeature. If the feature id doesn't exist a new feature will be written. Otherwise, the existing feature will be rewritten.

Parameters

  poFeature | the feature to write to disk.

Returns
  OGRERR_NONE on success.

Since
  GDAL 3.6.0

See also
  UpsertFeature()

## ◆ PostFilterArrowArray()

void OGRLayer::PostFilterArrowArray | ( | const struct ArrowSchema * | schema,
|  | struct ArrowArray * | array,
|  | CSLConstList | papszOptions
| ) |  | const
| protected inherited

Remove rows that aren't selected by the spatial or attribute filter.

Assumes that CanPostFilterArrowArray() has been called and returned true.

## ◆ Reference()

int OGRLayer::Reference | ( |  | ) |
| inherited

Increment layer reference count.

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

Returns
  the reference count after incrementing.

## ◆ ReleaseArray()

void OGRLayer::ReleaseArray | ( | struct ArrowArray * | array | ) |
| static protected inherited

Release a ArrowArray.

To be used by driver implementations that have a custom GetArrowStream() implementation.

Parameters

  array | Arrow array to release.

Since
  GDAL 3.6

## ◆ ReleaseSchema()

void OGRLayer::ReleaseSchema | ( | struct ArrowSchema * | schema | ) |
| static protected inherited

Release a ArrowSchema.

To be used by driver implementations that have a custom GetArrowStream() implementation.

Parameters

  schema | Schema to release.

Since
  GDAL 3.6

## ◆ ReleaseStream()

void OGRLayer::ReleaseStream | ( | struct ArrowArrayStream * | stream | ) |
| static protected inherited

Release a ArrowArrayStream.

To be used by driver implementations that have a custom GetArrowStream() implementation.

Parameters

  stream | Arrow array stream to release.

Since
  GDAL 3.6

## ◆ Rename()

OGRErr OGRLayer::Rename | ( | const char * | pszNewName | ) |
| virtual inherited

Rename layer.

This operation is implemented only by layers that expose the OLCRename capability, and drivers that expose the GDAL_DCAP_RENAME_LAYERS capability

This operation will fail if a layer with the new name already exists.

On success, GetDescription() and GetLayerDefn()->GetName() will return pszNewName.

Renaming the layer may interrupt current feature iteration.

Parameters

  pszNewName | New layer name. Must not be NULL.

Returns
  OGRERR_NONE in case of success

Since
  GDAL 3.5

## ◆ ReorderField()

OGRErr OGRLayer::ReorderField | ( | int | iOldFieldPos,
|  | int | iNewFieldPos
| ) |  |
| inherited

Reorder an existing field on a layer.

This method is a convenience wrapper of ReorderFields() dedicated to move a single field. It is a non-virtual method, so drivers should implement ReorderFields() instead.

You must use this to reorder existing fields on a real layer. Internally the OGRFeatureDefn for the layer will be updated to reflect the reordering of the fields. Applications should never modify the OGRFeatureDefn used by a layer directly.

This method should not be called while there are feature objects in existence that were obtained or created with the previous layer definition.

The field definition that was at initial position iOldFieldPos will be moved at position iNewFieldPos, and elements between will be shuffled accordingly.

For example, let suppose the fields were "0","1","2","3","4" initially. ReorderField(1, 3) will reorder them as "0","2","3","1","4".

Not all drivers support this method. You can query a layer to check if it supports it with the OLCReorderFields capability. Some drivers may only support this method while there are still no features in the layer. When it is supported, the existing features of the backing file/database should be updated accordingly.

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

Parameters

  iOldFieldPos | previous position of the field to move. Must be in the range [0,GetFieldCount()-1].
  iNewFieldPos | new position of the field to move. Must be in the range [0,GetFieldCount()-1].

Returns
  OGRERR_NONE on success.

Since
  OGR 1.9.0

## ◆ ReorderFields()

OGRErr OGRLayer::ReorderFields | ( | int * | panMap | ) |
| virtual inherited

Reorder all the fields of a layer.

You must use this to reorder existing fields on a real layer. Internally the OGRFeatureDefn for the layer will be updated to reflect the reordering of the fields. Applications should never modify the OGRFeatureDefn used by a layer directly.

This method should not be called while there are feature objects in existence that were obtained or created with the previous layer definition.

panMap is such that,for each field definition at position i after reordering, its position before reordering was panMap[i].

For example, let suppose the fields were "0","1","2","3","4" initially. ReorderFields([0,2,3,1,4]) will reorder them as "0","2","3","1","4".

Not all drivers support this method. You can query a layer to check if it supports it with the OLCReorderFields capability. Some drivers may only support this method while there are still no features in the layer. When it is supported, the existing features of the backing file/database should be updated accordingly.

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

Parameters

  panMap | an array of GetLayerDefn()->OGRFeatureDefn::GetFieldCount() elements which is a permutation of [0, GetLayerDefn()->OGRFeatureDefn::GetFieldCount()-1].

Returns
  OGRERR_NONE on success.

Since
  OGR 1.9.0

Reimplemented in GNMGenericLayer.

## ◆ ResetReading()

void OGRGNMWrappedResultLayer::ResetReading | ( |  | ) |
| override virtual

Reset feature reading to start on the first feature.

This affects GetNextFeature() and GetArrowStream().

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

Implements OGRLayer.

## ◆ RollbackTransaction()

OGRErr OGRLayer::RollbackTransaction | ( |  | ) |
| virtual inherited

For datasources which support transactions, RollbackTransaction will roll back a datasource to its state before the start of the current transaction.

If no transaction is active, or the rollback fails, will return OGRERR_FAILURE. Datasources which do not support transactions will always return OGRERR_NONE.

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

Returns
  OGRERR_NONE on success.

Reimplemented in GNMGenericLayer.

## ◆ SetActiveSRS()

OGRErr OGRLayer::SetActiveSRS | ( | int | iGeomField,
|  | const OGRSpatialReference * | poSRS
| ) |  |
| virtual inherited

Change the active SRS.

The passed SRS must be in the list returned by GetSupportedSRSList() (the actual pointer may be different, but should be tested as identical with OGRSpatialReference::IsSame()).

Changing the active SRS affects:

- the SRS in which geometries of returned features are expressed,
- the SRS in which geometries of passed features (CreateFeature(), SetFeature()) are expressed,
- the SRS returned by GetSpatialRef() and GetGeomFieldDefn()->GetSpatialRef(),
- the SRS used to interpret SetSpatialFilter() values.

This also resets feature reading and the spatial filter. Note however that this does not modify the storage SRS of the features of geometries. Said otherwise, this setting is volatile and has no persistent effects after dataset reopening.

Parameters

  iGeomField | Geometry field index.
  poSRS | SRS to use

Returns
  OGRERR_NONE in case of success, or OGRERR_FAILURE if the passed SRS is not in GetSupportedSRSList()

Since
  GDAL 3.7

## ◆ SetAttributeFilter()

OGRErr OGRLayer::SetAttributeFilter | ( | const char * | pszQuery | ) |
| virtual inherited

Set a new attribute query.

This method sets the attribute query string to be used when fetching features via the GetNextFeature() method. Only features for which the query evaluates as true will be returned.

The query string should be in the format of an SQL WHERE clause. For instance "population > 1000000 and population < 5000000" where population is an attribute in the layer. The query format is normally a SQL WHERE clause as described in the "WHERE" section of the OGR SQL dialect documentation. In some cases (RDBMS backed drivers, SQLite, GeoPackage) the native capabilities of the database may be used to to interpret the WHERE clause, in which case the capabilities will be broader than those of OGR SQL.

Note that installing a query string will generally result in resetting the current reading position (ala ResetReading()).

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

Parameters

  pszQuery | query in restricted SQL WHERE format, or NULL to clear the current query.

Returns
  OGRERR_NONE if successfully installed, or an error code if the query expression is in error, or some other failure occurs.

Reimplemented in GNMGenericLayer.

## ◆ SetDescription()

void GDALMajorObject::SetDescription | ( | const char * | pszNewDesc | ) |
| virtual inherited

Set object description.

The semantics of the description are specific to the derived type. For GDALDatasets it is the dataset name. For GDALRasterBands it is actually a description (if supported) or "".

Normally application code should not set the "description" for GDALDatasets. It is handled internally.

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

Reimplemented in GDALPamRasterBand.

## ◆ SetFeature()

OGRErr OGRLayer::SetFeature | ( | OGRFeature * | poFeature | ) |
| inherited

Rewrite/replace an existing feature.

This method will write a feature to the layer, based on the feature id within the OGRFeature.

Use OGRLayer::TestCapability(OLCRandomWrite) to establish if this layer supports random access writing via SetFeature().

The way unset fields in the provided poFeature are processed is driver dependent:

- SQL based drivers which implement SetFeature() through SQL UPDATE will skip unset fields, and thus the content of the existing feature will be preserved.
- The shapefile driver will write a NULL value in the DBF file.
- The GeoJSON driver will take into account unset fields to remove the corresponding JSON member.

Starting with GDAL 2.0, drivers should specialize the ISetFeature() method, since SetFeature() is no longer virtual.

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

To set a feature, but create it if it doesn't exist see OGRLayer::UpsertFeature().

Parameters

  poFeature | the feature to write.

Returns
  OGRERR_NONE if the operation works, otherwise an appropriate error code (e.g OGRERR_NON_EXISTING_FEATURE if the feature does not exist).

See also
  UpdateFeature(), CreateFeature(), UpsertFeature()

## ◆ SetIgnoredFields()

OGRErr OGRLayer::SetIgnoredFields | ( | CSLConstList | papszFields | ) |
| virtual inherited

Set which fields can be omitted when retrieving features from the layer.

If the driver supports this functionality (testable using OLCIgnoreFields capability), it will not fetch the specified fields in subsequent calls to GetFeature() / GetNextFeature() and thus save some processing time and/or bandwidth.

Besides field names of the layers, the following special fields can be passed: "OGR_GEOMETRY" to ignore geometry and "OGR_STYLE" to ignore layer style.

By default, no fields are ignored.

Note that fields that are used in an attribute filter should generally not be set as ignored fields, as most drivers (such as those relying on the OGR SQL engine) will be unable to correctly evaluate the attribute filter.

This method is the same as the C function OGR_L_SetIgnoredFields()

Parameters

  papszFields | an array of field names terminated by NULL item. If NULL is passed, the ignored list is cleared.

Returns
  OGRERR_NONE if all field names have been resolved (even if the driver does not support this method)

Reimplemented in GNMGenericLayer.

## ◆ SetMetadata()

CPLErr GDALMajorObject::SetMetadata | ( | char ** | papszMetadataIn,
|  | const char * | pszDomain = `""`
| ) |  |
| virtual inherited

Set metadata.

The C function GDALSetMetadata() does the same thing as this method.

Parameters

  papszMetadataIn | the metadata in name=value string list format to apply.
  pszDomain | the domain of interest. Use "" or NULL for the default domain.

Returns
  CE_None on success, CE_Failure on failure and CE_Warning if the metadata has been accepted, but is likely not maintained persistently by the underlying object between sessions.

Reimplemented in GDALDataset, GDALRasterBand, GDALPamDataset, and GDALPamRasterBand.

## ◆ SetMetadataItem()

CPLErr GDALMajorObject::SetMetadataItem | ( | const char * | pszName,
|  | const char * | pszValue,
|  | const char * | pszDomain = `""`
| ) |  |
| virtual inherited

Set single metadata item.

The C function GDALSetMetadataItem() does the same thing as this method.

Parameters

  pszName | the key for the metadata item to fetch.
  pszValue | the value to assign to the key.
  pszDomain | the domain to set within, use NULL for the default domain.

Returns
  CE_None on success, or an error code on failure.

Reimplemented in GDALDataset, GDALRasterBand, GDALPamDataset, GDALPamRasterBand, GDALDriver, and GDALPluginDriverProxy.

## ◆ SetMOFlags()

void GDALMajorObject::SetMOFlags | ( | int | nNewFlags | ) |
| inherited

Assign GMO_flags.

Parameters

  nNewFlags | new flags.

## ◆ SetNextByIndex()

OGRErr OGRGNMWrappedResultLayer::SetNextByIndex | ( | GIntBig | nIndex | ) |
| override virtual

Move read cursor to the nIndex'th feature in the current resultset.

This method allows positioning of a layer such that the GetNextFeature() call will read the requested feature, where nIndex is an absolute index into the current result set. So, setting it to 3 would mean the next feature read with GetNextFeature() would have been the 4th feature to have been read if sequential reading took place from the beginning of the layer, including accounting for spatial and attribute filters.

Only in rare circumstances is SetNextByIndex() efficiently implemented. In all other cases the default implementation which calls ResetReading() and then calls GetNextFeature() nIndex times is used. To determine if fast seeking is available on the current layer use the TestCapability() method with a value of OLCFastSetNextByIndex.

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

Parameters

  nIndex | the index indicating how many steps into the result set to seek.

Returns
  OGRERR_NONE on success or an error code.

Reimplemented from OGRLayer.

## ◆ SetSpatialFilter() [1/2]

void OGRLayer::SetSpatialFilter | ( | int | iGeomField,
|  | OGRGeometry * | poFilter
| ) |  |
| virtual inherited

Set a new spatial filter.

This method set the geometry to be used as a spatial filter when fetching features via the GetNextFeature() method. Only features that geometrically intersect the filter geometry will be returned.

Currently this test is may be inaccurately implemented, but it is guaranteed that all features who's envelope (as returned by OGRGeometry::getEnvelope()) overlaps the envelope of the spatial filter will be returned. This can result in more shapes being returned that should strictly be the case.

This method makes an internal copy of the passed geometry. The passed geometry remains the responsibility of the caller, and may be safely destroyed.

For the time being the passed filter geometry should be in the same SRS as the geometry field definition it corresponds to (as returned by GetLayerDefn()->OGRFeatureDefn::GetGeomFieldDefn(iGeomField)->GetSpatialRef()). In the future this may be generalized.

Note that only the last spatial filter set is applied, even if several successive calls are done with different iGeomField values.

Note to driver implementer: if you implement SetSpatialFilter(int,OGRGeometry*), you must also implement SetSpatialFilter(OGRGeometry*) to make it call SetSpatialFilter(0,OGRGeometry*).

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

Parameters

  iGeomField | index of the geometry field on which the spatial filter operates.
  poFilter | the geometry to use as a filtering region. NULL may be passed indicating that the current spatial filter should be cleared, but no new one instituted.

Since
  GDAL 1.11

Reimplemented in GNMGenericLayer.

## ◆ SetSpatialFilter() [2/2]

void OGRLayer::SetSpatialFilter | ( | OGRGeometry * | poFilter | ) |
| virtual inherited

Set a new spatial filter.

This method set the geometry to be used as a spatial filter when fetching features via the GetNextFeature() method. Only features that geometrically intersect the filter geometry will be returned.

Currently this test is may be inaccurately implemented, but it is guaranteed that all features whose envelope (as returned by OGRGeometry::getEnvelope()) overlaps the envelope of the spatial filter will be returned. This can result in more shapes being returned that should strictly be the case.

Starting with GDAL 2.3, features with null or empty geometries will never be considered as matching a spatial filter.

This method makes an internal copy of the passed geometry. The passed geometry remains the responsibility of the caller, and may be safely destroyed.

For the time being the passed filter geometry should be in the same SRS as the layer (as returned by OGRLayer::GetSpatialRef()). In the future this may be generalized.

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

Parameters

  poFilter | the geometry to use as a filtering region. NULL may be passed indicating that the current spatial filter should be cleared, but no new one instituted.

Reimplemented in GNMGenericLayer.

## ◆ SetSpatialFilterRect() [1/2]

void OGRLayer::SetSpatialFilterRect | ( | double | dfMinX,
|  | double | dfMinY,
|  | double | dfMaxX,
|  | double | dfMaxY
| ) |  |
| virtual inherited

Set a new rectangular spatial filter.

This method set rectangle to be used as a spatial filter when fetching features via the GetNextFeature() method. Only features that geometrically intersect the given rectangle will be returned.

The x/y values should be in the same coordinate system as the layer as a whole (as returned by OGRLayer::GetSpatialRef()). Internally this method is normally implemented as creating a 5 vertex closed rectangular polygon and passing it to OGRLayer::SetSpatialFilter(). It exists as a convenience.

The only way to clear a spatial filter set with this method is to call OGRLayer::SetSpatialFilter(NULL).

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

Parameters

  dfMinX | the minimum X coordinate for the rectangular region.
  dfMinY | the minimum Y coordinate for the rectangular region.
  dfMaxX | the maximum X coordinate for the rectangular region.
  dfMaxY | the maximum Y coordinate for the rectangular region.

Reimplemented in GNMGenericLayer.

## ◆ SetSpatialFilterRect() [2/2]

void OGRLayer::SetSpatialFilterRect | ( | int | iGeomField,
|  | double | dfMinX,
|  | double | dfMinY,
|  | double | dfMaxX,
|  | double | dfMaxY
| ) |  |
| virtual inherited

Set a new rectangular spatial filter.

This method set rectangle to be used as a spatial filter when fetching features via the GetNextFeature() method. Only features that geometrically intersect the given rectangle will be returned.

The x/y values should be in the same coordinate system as as the geometry field definition it corresponds to (as returned by GetLayerDefn()->OGRFeatureDefn::GetGeomFieldDefn(iGeomField)->GetSpatialRef()). Internally this method is normally implemented as creating a 5 vertex closed rectangular polygon and passing it to OGRLayer::SetSpatialFilter(). It exists as a convenience.

The only way to clear a spatial filter set with this method is to call OGRLayer::SetSpatialFilter(NULL).

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

Parameters

  iGeomField | index of the geometry field on which the spatial filter operates.
  dfMinX | the minimum X coordinate for the rectangular region.
  dfMinY | the minimum Y coordinate for the rectangular region.
  dfMaxX | the maximum X coordinate for the rectangular region.
  dfMaxY | the maximum Y coordinate for the rectangular region.

Since
  GDAL 1.11

Reimplemented in GNMGenericLayer.

## ◆ SetStyleTable()

void OGRLayer::SetStyleTable | ( | OGRStyleTable * | poStyleTable | ) |
| virtual inherited

Set layer style table.

This method operate exactly as OGRLayer::SetStyleTableDirectly() except that it does not assume ownership of the passed table.

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

Parameters

  poStyleTable | pointer to style table to set

Reimplemented in GNMGenericLayer.

## ◆ SetStyleTableDirectly()

void OGRLayer::SetStyleTableDirectly | ( | OGRStyleTable * | poStyleTable | ) |
| virtual inherited

Set layer style table.

This method operate exactly as OGRLayer::SetStyleTable() except that it assumes ownership of the passed table.

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

Parameters

  poStyleTable | pointer to style table to set

Reimplemented in GNMGenericLayer.

## ◆ StartTransaction()

OGRErr OGRLayer::StartTransaction | ( |  | ) |
| virtual inherited

For datasources which support transactions, StartTransaction creates a transaction.

If starting the transaction fails, will return OGRERR_FAILURE. Datasources which do not support transactions will always return OGRERR_NONE.

Note: as of GDAL 2.0, use of this API is discouraged when the dataset offers dataset level transaction with GDALDataset::StartTransaction(). The reason is that most drivers can only offer transactions at dataset level, and not layer level. Very few drivers really support transactions at layer scope.

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

Returns
  OGRERR_NONE on success.

Reimplemented in GNMGenericLayer.

## ◆ StaticGetArrowSchema()

int OGRLayer::StaticGetArrowSchema | ( | struct ArrowArrayStream * | stream,
|  | struct ArrowSchema * | out_schema
| ) |  |
| static protected inherited

Default implementation of the ArrowArrayStream::get_schema() callback.

To be used by driver implementations that have a custom GetArrowStream() implementation.

Since
  GDAL 3.6

## ◆ StaticGetNextArrowArray()

int OGRLayer::StaticGetNextArrowArray | ( | struct ArrowArrayStream * | stream,
|  | struct ArrowArray * | out_array
| ) |  |
| static protected inherited

Default implementation of the ArrowArrayStream::get_next() callback.

To be used by driver implementations that have a custom GetArrowStream() implementation.

Since
  GDAL 3.6

## ◆ SymDifference()

OGRErr OGRLayer::SymDifference | ( | OGRLayer * | pLayerMethod,
|  | OGRLayer * | pLayerResult,
|  | char ** | papszOptions,
|  | GDALProgressFunc | pfnProgress,
|  | void * | pProgressArg
| ) |  |
| inherited

Symmetrical difference of two layers.

The result layer contains features whose geometries represent areas that are in either in the input layer or in the method layer but not in both. The features in the result layer have attributes from both input and method layers. For features which represent areas that are only in the input or in the method layer the respective attributes have undefined values. The schema of the result layer can be set by the user or, if it is empty, is initialized to contain all fields in the input and method layers.

Note
  If the schema of the result is set by user and contains fields that have the same name as a field in input and in method layer, then the attribute in the result feature will get the value from the feature of the method layer (even if it is undefined).
  For best performance use the minimum amount of features in the method layer and copy it into a memory layer.
  This method relies on GEOS support. Do not use unless the GEOS support is compiled in.

The recognized list of options is :

- SKIP_FAILURES=YES/NO. Set it to YES to go on, even when a feature could not be inserted or a GEOS call failed.
- PROMOTE_TO_MULTI=YES/NO. Set it to YES to convert Polygons into MultiPolygons, or LineStrings to MultiLineStrings.
- INPUT_PREFIX=string. Set a prefix for the field names that will be created from the fields of the input layer.
- METHOD_PREFIX=string. Set a prefix for the field names that will be created from the fields of the method layer.

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

Parameters

  pLayerMethod | the method layer. Should not be NULL.
  pLayerResult | the layer where the features resulting from the operation are inserted. Should not be NULL. See above the note about the schema.
  papszOptions | NULL terminated list of options (may be NULL).
  pfnProgress | a GDALProgressFunc() compatible callback function for reporting progress or NULL.
  pProgressArg | argument to be passed to pfnProgress. May be NULL.

Returns
  an error code if there was an error or the execution was interrupted, OGRERR_NONE otherwise.

Note
  The first geometry field is always used.

Since
  OGR 1.10

## ◆ SyncToDisk()

OGRErr OGRLayer::SyncToDisk | ( |  | ) |
| virtual inherited

Flush pending changes to disk.

This call is intended to force the layer to flush any pending writes to disk, and leave the disk file in a consistent state. It would not normally have any effect on read-only datasources.

Some layers do not implement this method, and will still return OGRERR_NONE. The default implementation just returns OGRERR_NONE. An error is only returned if an error occurs while attempting to flush to disk.

In any event, you should always close any opened datasource with OGRDataSource::DestroyDataSource() that will ensure all data is correctly flushed.

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

Returns
  OGRERR_NONE if no error occurs (even if nothing is done) or an error code.

Reimplemented in GNMGenericLayer.

## ◆ TestCapability()

int OGRGNMWrappedResultLayer::TestCapability | ( | const char * | pszCap | ) |
| override virtual

Test if this layer supported the named capability.

The capability codes that can be tested are represented as strings, but #defined constants exists to ensure correct spelling. Specific layer types may implement class specific capabilities, but this can't generally be discovered by the caller.

- OLCRandomRead / "RandomRead": TRUE if the GetFeature() method is implemented in an optimized way for this layer, as opposed to the default implementation using ResetReading() and GetNextFeature() to find the requested feature id.

- OLCSequentialWrite / "SequentialWrite": TRUE if the CreateFeature() method works for this layer. Note this means that this particular layer is writable. The same OGRLayer class may return FALSE for other layer instances that are effectively read-only.

- OLCRandomWrite / "RandomWrite": TRUE if the SetFeature() method is operational on this layer. Note this means that this particular layer is writable. The same OGRLayer class may return FALSE for other layer instances that are effectively read-only.

- OLCUpsertFeature / "UpsertFeature": TRUE if the UpsertFeature() method is operational on this layer. Note this means that this particular layer is writable. The same OGRLayer class may return FALSE for other layer instances that are effectively read-only.

- OLCFastSpatialFilter / "FastSpatialFilter": TRUE if this layer implements spatial filtering efficiently. Layers that effectively read all features, and test them with the OGRFeature intersection methods should return FALSE. This can be used as a clue by the application whether it should build and maintain its own spatial index for features in this layer.

- OLCFastFeatureCount / "FastFeatureCount": TRUE if this layer can return a feature count (via GetFeatureCount()) efficiently. i.e. without counting the features. In some cases this will return TRUE until a spatial filter is installed after which it will return FALSE.

- OLCFastGetExtent / "FastGetExtent": TRUE if this layer can return its data extent (via GetExtent()) efficiently, i.e. without scanning all the features. In some cases this will return TRUE until a spatial filter is installed after which it will return FALSE.

- OLCFastSetNextByIndex / "FastSetNextByIndex": TRUE if this layer can perform the SetNextByIndex() call efficiently, otherwise FALSE.

- OLCCreateField / "CreateField": TRUE if this layer can create new fields on the current layer using CreateField(), otherwise FALSE.

- OLCCreateGeomField / "CreateGeomField": (GDAL >= 1.11) TRUE if this layer can create new geometry fields on the current layer using CreateGeomField(), otherwise FALSE.

- OLCDeleteField / "DeleteField": TRUE if this layer can delete existing fields on the current layer using DeleteField(), otherwise FALSE.

- OLCReorderFields / "ReorderFields": TRUE if this layer can reorder existing fields on the current layer using ReorderField() or ReorderFields(), otherwise FALSE.

- OLCAlterFieldDefn / "AlterFieldDefn": TRUE if this layer can alter the definition of an existing field on the current layer using AlterFieldDefn(), otherwise FALSE.

- OLCAlterGeomFieldDefn / "AlterGeomFieldDefn": TRUE if this layer can alter the definition of an existing geometry field on the current layer using AlterGeomFieldDefn(), otherwise FALSE.

- OLCDeleteFeature / "DeleteFeature": TRUE if the DeleteFeature() method is supported on this layer, otherwise FALSE.

- OLCStringsAsUTF8 / "StringsAsUTF8": TRUE if values of OFTString fields are assured to be in UTF-8 format. If FALSE the encoding of fields is uncertain, though it might still be UTF-8.

- OLCTransactions / "Transactions": TRUE if the StartTransaction(), CommitTransaction() and RollbackTransaction() methods work in a meaningful way, otherwise FALSE.

- OLCIgnoreFields / "IgnoreFields": TRUE if fields, geometry and style will be omitted when fetching features as set by SetIgnoredFields() method.

- OLCCurveGeometries / "CurveGeometries": TRUE if this layer supports writing curve geometries or may return such geometries. (GDAL 2.0).

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

Parameters

  pszCap | the name of the capability to test.

Returns
  TRUE if the layer has the requested capability, or FALSE otherwise. OGRLayers will return FALSE for any unrecognized capabilities.

Implements OGRLayer.

## ◆ ToHandle() [1/2]

static GDALMajorObjectH GDALMajorObject::ToHandle | ( | GDALMajorObject * | poMajorObject | ) |
| inline static inherited

Convert a GDALMajorObject* to a GDALMajorObjectH.

Since
  GDAL 2.3

## ◆ ToHandle() [2/2]

static OGRLayerH OGRLayer::ToHandle | ( | OGRLayer * | poLayer | ) |
| inline static inherited

Convert a OGRLayer* to a OGRLayerH.

Since
  GDAL 2.3

## ◆ Union()

OGRErr OGRLayer::Union | ( | OGRLayer * | pLayerMethod,
|  | OGRLayer * | pLayerResult,
|  | char ** | papszOptions = `nullptr`,
|  | GDALProgressFunc | pfnProgress = `nullptr`,
|  | void * | pProgressArg = `nullptr`
| ) |  |
| inherited

Union of two layers.

The result layer contains features whose geometries represent areas that are either in the input layer, in the method layer, or in both. The features in the result layer have attributes from both input and method layers. For features which represent areas that are only in the input or in the method layer the respective attributes have undefined values. The schema of the result layer can be set by the user or, if it is empty, is initialized to contain all fields in the input and method layers.

Note
  If the schema of the result is set by user and contains fields that have the same name as a field in input and in method layer, then the attribute in the result feature will get the value from the feature of the method layer (even if it is undefined).
  For best performance use the minimum amount of features in the method layer and copy it into a memory layer.
  This method relies on GEOS support. Do not use unless the GEOS support is compiled in.

The recognized list of options is :

- SKIP_FAILURES=YES/NO. Set it to YES to go on, even when a feature could not be inserted or a GEOS call failed.
- PROMOTE_TO_MULTI=YES/NO. Set to YES to convert Polygons into MultiPolygons, LineStrings to MultiLineStrings or Points to MultiPoints (only since GDAL 3.9.2 for the later)
- INPUT_PREFIX=string. Set a prefix for the field names that will be created from the fields of the input layer.
- METHOD_PREFIX=string. Set a prefix for the field names that will be created from the fields of the method layer.
- USE_PREPARED_GEOMETRIES=YES/NO. Set to NO to not use prepared geometries to pretest intersection of features of method layer with features of this layer.
- KEEP_LOWER_DIMENSION_GEOMETRIES=YES/NO. Set to NO to skip result features with lower dimension geometry that would otherwise be added to the result layer. The default is YES, to add features with lower dimension geometry, but only if the result layer has an unknown geometry type.

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

Parameters

  pLayerMethod | the method layer. Should not be NULL.
  pLayerResult | the layer where the features resulting from the operation are inserted. Should not be NULL. See above the note about the schema.
  papszOptions | NULL terminated list of options (may be NULL).
  pfnProgress | a GDALProgressFunc() compatible callback function for reporting progress or NULL.
  pProgressArg | argument to be passed to pfnProgress. May be NULL.

Returns
  an error code if there was an error or the execution was interrupted, OGRERR_NONE otherwise.

Note
  The first geometry field is always used.

Since
  OGR 1.10

## ◆ Update()

OGRErr OGRLayer::Update | ( | OGRLayer * | pLayerMethod,
|  | OGRLayer * | pLayerResult,
|  | char ** | papszOptions = `nullptr`,
|  | GDALProgressFunc | pfnProgress = `nullptr`,
|  | void * | pProgressArg = `nullptr`
| ) |  |
| inherited

Update this layer with features from the update layer.

The result layer contains features whose geometries represent areas that are either in the input layer or in the method layer. The features in the result layer have areas of the features of the method layer or those ares of the features of the input layer that are not covered by the method layer. The features of the result layer get their attributes from the input layer. The schema of the result layer can be set by the user or, if it is empty, is initialized to contain all fields in the input layer.

Note
  If the schema of the result is set by user and contains fields that have the same name as a field in the method layer, then the attribute in the result feature the originates from the method layer will get the value from the feature of the method layer.
  For best performance use the minimum amount of features in the method layer and copy it into a memory layer.
  This method relies on GEOS support. Do not use unless the GEOS support is compiled in.

The recognized list of options is :

- SKIP_FAILURES=YES/NO. Set it to YES to go on, even when a feature could not be inserted or a GEOS call failed.
- PROMOTE_TO_MULTI=YES/NO. Set to YES to convert Polygons into MultiPolygons, LineStrings to MultiLineStrings or Points to MultiPoints (only since GDAL 3.9.2 for the later)
- INPUT_PREFIX=string. Set a prefix for the field names that will be created from the fields of the input layer.
- METHOD_PREFIX=string. Set a prefix for the field names that will be created from the fields of the method layer.

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

Parameters

  pLayerMethod | the method layer. Should not be NULL.
  pLayerResult | the layer where the features resulting from the operation are inserted. Should not be NULL. See above the note about the schema.
  papszOptions | NULL terminated list of options (may be NULL).
  pfnProgress | a GDALProgressFunc() compatible callback function for reporting progress or NULL.
  pProgressArg | argument to be passed to pfnProgress. May be NULL.

Returns
  an error code if there was an error or the execution was interrupted, OGRERR_NONE otherwise.

Note
  The first geometry field is always used.

Since
  OGR 1.10

## ◆ UpdateFeature()

OGRErr OGRLayer::UpdateFeature | ( | OGRFeature * | poFeature,
|  | int | nUpdatedFieldsCount,
|  | const int * | panUpdatedFieldsIdx,
|  | int | nUpdatedGeomFieldsCount,
|  | const int * | panUpdatedGeomFieldsIdx,
|  | bool | bUpdateStyleString
| ) |  |
| inherited

Update (part of) an existing feature.

This method will update the specified attribute and geometry fields of a feature to the layer, based on the feature id within the OGRFeature.

Use OGRLayer::TestCapability(OLCRandomWrite) to establish if this layer supports random access writing via UpdateFeature(). And to know if the driver supports a dedicated/efficient UpdateFeature() method, test for the OLCUpdateFeature capability.

The way unset fields in the provided poFeature are processed is driver dependent:

- SQL based drivers which implement SetFeature() through SQL UPDATE will skip unset fields, and thus the content of the existing feature will be preserved.
- The shapefile driver will write a NULL value in the DBF file.
- The GeoJSON driver will take into account unset fields to remove the corresponding JSON member.

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

To fully replace a feature, see OGRLayer::SetFeature().

Note that after this call the content of hFeat might have changed, and will not* reflect the content you would get with GetFeature(). In particular for performance reasons, passed geometries might have been "stolen", in particular for the default implementation of UpdateFeature() which relies on GetFeature() + SetFeature().

Parameters

  poFeature | the feature to update.
  nUpdatedFieldsCount | number of attribute fields to update. May be 0
  panUpdatedFieldsIdx | array of nUpdatedFieldsCount values, each between 0 and GetLayerDefn()->GetFieldCount() - 1, indicating which fields of poFeature must be updated in the layer.
  nUpdatedGeomFieldsCount | number of geometry fields to update. May be 0
  panUpdatedGeomFieldsIdx | array of nUpdatedGeomFieldsCount values, each between 0 and GetLayerDefn()->GetGeomFieldCount() - 1, indicating which geometry fields of poFeature must be updated in the layer.
  bUpdateStyleString | whether the feature style string in the layer should be updated with the one of poFeature.

Returns
  OGRERR_NONE if the operation works, otherwise an appropriate error code (e.g OGRERR_NON_EXISTING_FEATURE if the feature does not exist).

Since
  GDAL 3.7

See also
  UpdateFeature(), CreateFeature(), UpsertFeature()

## ◆ UpsertFeature()

OGRErr OGRLayer::UpsertFeature | ( | OGRFeature * | poFeature | ) |
| inherited

Rewrite/replace an existing feature or create a new feature within a layer.

This function will write a feature to the layer, based on the feature id within the OGRFeature. If the feature id doesn't exist a new feature will be written. Otherwise, the existing feature will be rewritten.

Use OGRLayer::TestCapability(OLCUpsertFeature) to establish if this layer supports upsert writing.

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

Parameters

  poFeature | the feature to write to disk.

Returns
  OGRERR_NONE on success.

Since
  GDAL 3.6.0

See also
  SetFeature(), CreateFeature(), UpdateFeature()

## ◆ WriteArrowBatch()

bool OGRLayer::WriteArrowBatch | ( | const struct ArrowSchema * | schema,
|  | struct ArrowArray * | array,
|  | CSLConstList | papszOptions = `nullptr`
| ) |  |
| virtual inherited

Writes a batch of rows from an ArrowArray.

This is semantically close to calling CreateFeature() with multiple features at once.

The ArrowArray must be of type struct (format=+s), and its children generally map to a OGR attribute or geometry field (unless they are struct themselves).

Method IsArrowSchemaSupported() can be called to determine if the schema will be supported by WriteArrowBatch().

OGR fields for the corresponding children arrays must exist and be of a compatible type. For attribute fields, they should generally be created with CreateFieldFromArrowSchema(). This is strictly required for output drivers Arrow or Parquet, and strongly recommended otherwise. For geometry fields, they should be created either implicitly at CreateLayer() type (if geom_type != wkbNone), or explicitly with CreateGeomField().

Starting with GDAL 3.9, some tolerance has been introduced in the base implementation of WriteArrowBatch() for scenarios that involve appending to an already existing output layer when the input Arrow field type and the OGR layer field type are 32/64-bi integers or real number, but do not match exactly, which may cause lossy conversions. The IF_FIELD_NOT_PRESERVED option can be used to control the behavior in case of lossy conversion.

Arrays for geometry columns should be of binary or large binary type and contain WKB geometry.

Note that the passed array may be set to a released state (array->release==NULL) after this call (not by the base implementation, but in specialized ones such as Parquet or Arrow for example)

Supported options of the base implementation are:

- FID=name. Name of the FID column in the array. If not provided, GetFIDColumn() is used to determine it. The special name OGRLayer::DEFAULT_ARROW_FID_NAME is also recognized if neither FID nor GetFIDColumn() are set. The corresponding ArrowArray must be of type int32 (i) or int64 (l). On input, values of the FID column are used to create the feature. On output, the values of the FID column may be set with the FID of the created feature (if the array is not released).
- IF_FID_NOT_PRESERVED=NOTHING/ERROR/WARNING. Action to perform when the input FID is not preserved in the output layer. The default is NOTHING. Setting it to ERROR will cause the function to error out. Setting it to WARNING will cause the function to emit a warning but continue its processing.
- IF_FIELD_NOT_PRESERVED=ERROR/WARNING. (since GDAL 3.9) Action to perform when the input field value is not preserved in the output layer. The default is WARNING, which will cause the function to emit a warning but continue its processing. Setting it to ERROR will cause the function to error out if a lossy conversion is detected.
- GEOMETRY_NAME=name. Name of the geometry column. If not provided, GetGeometryColumn() is used. The special name OGRLayer::DEFAULT_ARROW_GEOMETRY_NAME is also recognized if neither GEOMETRY_NAME nor GetGeometryColumn() are set. Geometry columns are also identified if they have ARROW:extension:name=ogc.wkb as a field metadata. The corresponding ArrowArray must be of type binary (w) or large binary (W).

The following example demonstrates how to copy a layer from one format to another one (assuming it has at most a single geometry column):

def copy_layer(src_lyr, out_filename, out_format, lcos = {}):
stream = src_lyr.GetArrowStream()
schema = stream.GetSchema()
# If the source layer has a FID column and the output driver supports
# a FID layer creation option, set it to the source FID column name.
if src_lyr.GetFIDColumn():
creationOptions = gdal.GetDriverByName(out_format).GetMetadataItem(
"DS_LAYER_CREATIONOPTIONLIST"
)
if creationOptions and '"FID"' in creationOptions:
lcos["FID"] = src_lyr.GetFIDColumn()
with ogr.GetDriverByName(out_format).CreateDataSource(out_filename) as out_ds:
if src_lyr.GetLayerDefn().GetGeomFieldCount() > 1:
out_lyr = out_ds.CreateLayer(
src_lyr.GetName(), geom_type=ogr.wkbNone, options=lcos
)
for i in range(src_lyr.GetLayerDefn().GetGeomFieldCount()):
out_lyr.CreateGeomField(src_lyr.GetLayerDefn().GetGeomFieldDefn(i))
else:
out_lyr = out_ds.CreateLayer(
src_lyr.GetName(),
geom_type=src_lyr.GetGeomType(),
srs=src_lyr.GetSpatialRef(),
options=lcos,
)
success, error_msg = out_lyr.IsArrowSchemaSupported(schema)
assert success, error_msg
src_geom_field_names = [
src_lyr.GetLayerDefn().GetGeomFieldDefn(i).GetName()
for i in range(src_lyr.GetLayerDefn().GetGeomFieldCount())
]
for i in range(schema.GetChildrenCount()):
# GetArrowStream() may return "OGC_FID" for a unnamed source FID
# column and "wkb_geometry" for a unnamed source geometry column.
# Also test GetFIDColumn() and src_geom_field_names if they are
# named.
if (
schema.GetChild(i).GetName()
not in ("OGC_FID", "wkb_geometry", src_lyr.GetFIDColumn())
and schema.GetChild(i).GetName() not in src_geom_field_names
):
out_lyr.CreateFieldFromArrowSchema(schema.GetChild(i))
write_options = []
if src_lyr.GetFIDColumn():
write_options.append("FID=" + src_lyr.GetFIDColumn())
if (
src_lyr.GetLayerDefn().GetGeomFieldCount() == 1
and src_lyr.GetGeometryColumn()
):
write_options.append("GEOMETRY_NAME=" + src_lyr.GetGeometryColumn())
while True:
array = stream.GetNextRecordBatch()
if array is None:
break
out_lyr.WriteArrowBatch(schema, array, write_options)

This method and CreateFeature() are mutually exclusive in the same session.

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

Parameters

  schema | Schema of array
  array | Array of type struct. It may be released (array->release==NULL) after calling this method.
  papszOptions | Options. Null terminated list, or nullptr.

Returns
  true in case of success

Since
  3.8

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

- gnm.h
- gnmresultlayer.cpp