Geographic Network C++ API
Include file
gnm.h
Geographic Network C++ API
Defines
-
GNM_MD_NAME
-
GNM_MD_DESCR
-
GNM_MD_SRS
-
GNM_MD_VERSION
-
GNM_MD_RULE
-
GNM_MD_FORMAT
-
GNM_MD_FETCHEDGES
-
GNM_MD_FETCHVERTEX
-
GNM_MD_NUM_PATHS
-
GNM_MD_EMITTER
Typedefs
-
typedef int GNMDirection
Enums
-
class GNMNetwork : public GDALDataset
- #include <gnm.h>
General GNM class which represents a geography network of common format.
- Since
GDAL 2.1
Subclassed by GNMGenericNetwork
Public Functions
-
GNMNetwork()
-
virtual ~GNMNetwork()
-
virtual const OGRSpatialReference *GetSpatialRef() const override
Fetch the spatial reference for this dataset.
Same as the C function GDALGetSpatialRef().
When a projection definition is not available, null is returned. If used on a dataset where there are GCPs and not a geotransform, this method returns null. Use GetGCPSpatialRef() instead.
- Since
GDAL 3.0
- 戻り値:
a pointer to an internal object. It should not be altered or freed. Its lifetime will be the one of the dataset object, or until the next call to this method.
-
virtual char **GetFileList(void) override
Fetch files forming dataset.
Returns a list of files believed to be part of this dataset. If it returns an empty list of files it means there is believed to be no local file system files associated with the dataset (for instance a virtual dataset). The returned file list is owned by the caller and should be deallocated with CSLDestroy().
The returned filenames will normally be relative or absolute paths depending on the path used to originally open the dataset. The strings will be UTF-8 encoded.
This method is the same as the C GDALGetFileList() function.
- 戻り値:
NULL or a NULL terminated array of file names.
-
virtual CPLErr Create(const char *pszFilename, char **papszOptions) = 0
Create network system layers.
Creates the connectivity (the "network path" of data) over the dataset and returns the resulting network. NOTE: This method does not create any connections among features but creates the necessary set of fields, layers, etc. NOTE: After the successful creation the passed dataset must not be modified outside (but can be read as usual). NOTE: For the common network format the creation is forbidden if the passed dataset already has network system layers and OVERWRITE creation option is FALSE.
- パラメータ:
pszFilename -- - A path there the network folder (schema, etc.) will be created. The folder (schema, etc.) name get options.
papszOptions -- - create network options. The create options specific for gnm driver.
- 戻り値:
CE_None on success
-
virtual CPLErr Open(GDALOpenInfo *poOpenInfo) = 0
Open a network.
- パラメータ:
poOpenInfo -- GDALOpenInfo pointer
- 戻り値:
CE_None on success
-
virtual const char *GetName() const
GetName - a network name.
The value provided to create function in GNM_MD_NAME key. While creation this value used to create the folder or db schema name. But can be changed after creation.
- 戻り値:
Network name string
-
inline virtual int GetVersion() const
GetVersion return the network version if applicable.
- 戻り値:
version value
-
virtual CPLErr DisconnectAll() = 0
DisconnectAll method clears the network graph.
- 戻り値:
CE_None on success
-
virtual OGRFeature *GetFeatureByGlobalFID(GNMGFID nGFID) = 0
GetFeatureByGlobalFID search all network layers for given feature identificator.
- パラメータ:
nGFID -- feature identificator.
- 戻り値:
OGRFeature pointer or NULL. The pointer should be freed via OGRFeature::DestroyFeature().
-
virtual OGRLayer *GetPath(GNMGFID nStartFID, GNMGFID nEndFID, GNMGraphAlgorithmType eAlgorithm, char **papszOptions) = 0
Create path between start and end GFIDs.
- パラメータ:
nStartFID -- - start identificator
nEndFID -- - end identificator
eAlgorithm -- - The algorithm to get path
papszOptions -- - algorithm specific options
- 戻り値:
In memory OGRLayer pointer with features constituting the shortest path (or paths). The caller have to free the pointer via
Protected Functions
-
virtual int CheckNetworkExist(const char *pszFilename, char **papszOptions) = 0
Check if network already exist.
- パラメータ:
pszFilename -- - path to network (folder or database
papszOptions -- - create options
- 戻り値:
TRUE if exist and not overwrite or FALSE
-
class GNMGenericNetwork : public GNMNetwork
- #include <gnm.h>
GNM class which represents a geography network of generic format.
- Since
GDAL 2.1
Public Functions
-
GNMGenericNetwork()
-
virtual ~GNMGenericNetwork()
-
virtual int GetLayerCount() override
Get the number of layers in this dataset.
This method is the same as the C function GDALDatasetGetLayerCount(), and the deprecated OGR_DS_GetLayerCount().
In GDAL 1.X, this method used to be in the OGRDataSource class.
- 戻り値:
layer count.
-
virtual OGRLayer *GetLayer(int) override
Fetch a layer by index.
The returned layer remains owned by the GDALDataset and should not be deleted by the application.
See GetLayers() for a C++ iterator version of this method.
This method is the same as the C function GDALDatasetGetLayer() and the deprecated OGR_DS_GetLayer().
In GDAL 1.X, this method used to be in the OGRDataSource class.
参考
- パラメータ:
iLayer -- a layer number between 0 and GetLayerCount()-1.
- 戻り値:
the layer, or NULL if iLayer is out of range or an error occurs.
-
virtual OGRErr DeleteLayer(int) override
Delete the indicated layer from the datasource.
If this method is supported the ODsCDeleteLayer capability will test TRUE on the GDALDataset.
This method is the same as the C function GDALDatasetDeleteLayer() and the deprecated OGR_DS_DeleteLayer().
In GDAL 1.X, this method used to be in the OGRDataSource class.
- パラメータ:
iLayer -- the index of the layer to delete.
- 戻り値:
OGRERR_NONE on success, or OGRERR_UNSUPPORTED_OPERATION if deleting layers is not supported for this datasource.
-
virtual int TestCapability(const char*) override
Test if capability is available.
One of the following dataset capability names can be passed into this method, and a TRUE or FALSE value will be returned indicating whether or not the capability is available for this object.
ODsCCreateLayer: True if this datasource can create new layers.
ODsCDeleteLayer: True if this datasource can delete existing layers.
ODsCCreateGeomFieldAfterCreateLayer: True if the layers of this datasource support CreateGeomField() just after layer creation.
ODsCCurveGeometries: True if this datasource supports curve geometries.
ODsCTransactions: True if this datasource supports (efficient) transactions.
ODsCEmulatedTransactions: True if this datasource supports transactions through emulation.
ODsCRandomLayerRead: True if this datasource has a dedicated GetNextFeature() implementation, potentially returning features from layers in a non sequential way.
ODsCRandomLayerWrite: True if this datasource supports calling CreateFeature() on layers in a non sequential way.
The #define macro forms of the capability names should be used in preference to the strings themselves to avoid misspelling.
This method is the same as the C function GDALDatasetTestCapability() and the deprecated OGR_DS_TestCapability().
In GDAL 1.X, this method used to be in the OGRDataSource class.
- パラメータ:
pszCap -- the capability to test.
- 戻り値:
TRUE if capability available otherwise FALSE.
-
virtual OGRLayer *CopyLayer(OGRLayer *poSrcLayer, const char *pszNewName, char **papszOptions = nullptr) override
Duplicate an existing layer.
This method creates a new layer, duplicate the field definitions of the source layer and then duplicate each features of the source layer. The papszOptions argument can be used to control driver specific creation options. These options are normally documented in the format specific documentation. The source layer may come from another dataset.
This method is the same as the C function GDALDatasetCopyLayer() and the deprecated OGR_DS_CopyLayer().
In GDAL 1.X, this method used to be in the OGRDataSource class.
- パラメータ:
poSrcLayer -- source layer.
pszNewName -- the name of the layer to create.
papszOptions -- a StringList of name=value options. Options are driver specific. There is a common option to set output layer spatial reference: DST_SRSWKT. The option should be in WKT format. Starting with GDAL 3.7, the common option COPY_MD can be set to NO to prevent the default copying of the metadata from the source layer to the target layer.
- 戻り値:
a handle to the layer, or NULL if an error occurs.
-
virtual int CloseDependentDatasets() override
Drop references to any other datasets referenced by this dataset.
This method should release any reference to other datasets (e.g. a VRT dataset to its sources), but not close the current dataset itself.
If at least, one reference to a dependent dataset has been dropped, this method should return TRUE. Otherwise it should return FALSE. (Failure to return the proper value might result in infinite loop)
This method can be called several times on a given dataset. After the first time, it should not do anything and return FALSE.
The driver implementation may choose to destroy its raster bands, so be careful not to call any method on the raster bands afterwards.
Basically the only safe action you can do after calling CloseDependentDatasets() is to call the destructor.
Note: the only legitimate caller of CloseDependentDatasets() is GDALDriverManager::~GDALDriverManager()
- 戻り値:
TRUE if at least one reference to another dataset has been dropped.
-
virtual CPLErr FlushCache(bool bAtClosing) override
Flush all write cached data to disk.
Any raster (or other GDAL) data written via GDAL calls, but buffered internally will be written to disk.
The default implementation of this method just calls the FlushCache() method on each of the raster bands and the SyncToDisk() method on each of the layers. Conceptionally, calling FlushCache() on a dataset should include any work that might be accomplished by calling SyncToDisk() on layers in that dataset.
Using this method does not prevent use from calling GDALClose() to properly close a dataset and ensure that important data not addressed by FlushCache() is written in the file.
This method is the same as the C function GDALFlushCache().
- パラメータ:
bAtClosing -- Whether this is called from a GDALDataset destructor
- 戻り値:
CE_None in case of success (note: return value added in GDAL 3.7)
-
virtual CPLErr Create(const char *pszFilename, char **papszOptions) override = 0
Create network system layers.
Creates the connectivity (the "network path" of data) over the dataset and returns the resulting network. NOTE: This method does not create any connections among features but creates the necessary set of fields, layers, etc. NOTE: After the successful creation the passed dataset must not be modified outside (but can be read as usual). NOTE: For the common network format the creation is forbidden if the passed dataset already has network system layers and OVERWRITE creation option is FALSE.
- パラメータ:
pszFilename -- - A path there the network folder (schema, etc.) will be created. The folder (schema, etc.) name get options.
papszOptions -- - create network options. The create options specific for gnm driver.
- 戻り値:
CE_None on success
-
virtual CPLErr Delete() override
Delete network.
Delete all dependent layers
- 戻り値:
CE_None on success
-
virtual int GetVersion() const override
GetVersion return the network version if applicable.
- 戻り値:
version value
-
virtual GNMGFID GetNewGlobalFID()
GetNewGlobalFID increase the global ID counter.
- 戻り値:
New global feature ID.
-
virtual CPLString GetAlgorithmName(GNMDirection eAlgorithm, bool bShortName)
Get the algorithm name.
- パラメータ:
eAlgorithm -- GNM algorithm type
bShortName -- Indicator which name to return - short or long
- 戻り値:
String with algorithm name
-
virtual CPLErr AddFeatureGlobalFID(GNMGFID nFID, const char *pszLayerName)
AddFeatureGlobalFID add the FID <-> Layer name link to fast access features by global FID.
- パラメータ:
nFID -- - global FID
pszLayerName -- - layer name
- 戻り値:
CE_None on success
-
virtual CPLErr ConnectFeatures(GNMGFID nSrcFID, GNMGFID nTgtFID, GNMGFID nConFID = -1, double dfCost = 1, double dfInvCost = 1, GNMDirection eDir = GNM_EDGE_DIR_BOTH)
Connects two features via third feature (may be virtual, so the identificator should be -1).
The features may be at the same layer or different layers.
- パラメータ:
nSrcFID -- - source feature identificator
nTgtFID -- - target feature identificator
nConFID -- - connection feature identificator (-1 for virtual connection)
dfCost -- - cost moving from source to target (default 1)
dfInvCost -- - cost moving from target to source (default 1)
eDir -- - direction, may be source to target, target to source or both. (default - both)
- 戻り値:
CE_None on success
-
virtual CPLErr DisconnectFeatures(GNMGFID nSrcFID, GNMGFID nTgtFID, GNMGFID nConFID)
Remove features connection.
- パラメータ:
nSrcFID -- - source feature identificator
nTgtFID -- - target feature identificator
nConFID -- - connection feature identificator
- 戻り値:
CE_None on success
-
virtual CPLErr DisconnectFeaturesWithId(GNMGFID nFID)
Find the corresponding identificator in graph (source, target, connector) and remove such connections.
- パラメータ:
nFID -- - identificator to find.
- 戻り値:
CE_None on success
-
virtual CPLErr ReconnectFeatures(GNMGFID nSrcFID, GNMGFID nTgtFID, GNMGFID nConFID, double dfCost = 1, double dfInvCost = 1, GNMDirection eDir = GNM_EDGE_DIR_BOTH)
Change connection attributes.
Search the connection by source feature identificator, target feature identificator and connection identificator.
- パラメータ:
nSrcFID -- - source feature identificator
nTgtFID -- - target feature identificator
nConFID -- - connection feature identificator
dfCost -- - new cost moving from source to target
dfInvCost -- - new cost moving from target to source
eDir -- - new direction
- 戻り値:
CE_None on success
-
virtual CPLErr DisconnectAll() override
DisconnectAll method clears the network graph.
- 戻り値:
CE_None on success
-
virtual OGRFeature *GetFeatureByGlobalFID(GNMGFID nFID) override
GetFeatureByGlobalFID search all network layers for given feature identificator.
- パラメータ:
nGFID -- feature identificator.
- 戻り値:
OGRFeature pointer or NULL. The pointer should be freed via OGRFeature::DestroyFeature().
-
virtual CPLErr CreateRule(const char *pszRuleStr)
Create network rule.
Creates the rule in the network according to the special syntax. These rules are declarative and make an effect for the network when they exist. Each rule for layer can be created only if the corresponding layer existed and removed when the layer is being deleted.
Rules syntax for the common network format in GNM contains the key words (words in capital letters or signs) and the modifiers which refers to the network objects. All the following combinations are available:
Notation: layer1, layer2, layer3 - a layer names (the corresponding layers must be exist; field1 - a field name (field must be exist); constant1 - any double constant; string1 - any string;
Rules describing which layer can be connected or not connected with each other, and (optional) which layer must serve as a connector. By default all connections are forbidden. But while network creation process the rule to allow any connection added. During the connection process each rule tested if this connection can be created.
"ALLOW CONNECTS ANY" "DENY CONNECTS ANY" "DENY CONNECTS layer1 WITH layer2" "ALLOW CONNECTS layer1 WITH layer2 VIA layer3"
- パラメータ:
pszRuleStr -- Rule string which will parsed. If the parsing was successful, the rule will start having effect immediately.
- 戻り値:
CE_None on success.
-
virtual CPLErr DeleteRule(const char *pszRuleStr)
Delete the specified rule.
- パラメータ:
pszRuleStr -- - the rule to delete
- 戻り値:
CE_None on success.
-
virtual char **GetRules() const
Get the rule list.
- 戻り値:
list of rule strings. The caller have to free the lis via CPLDestroy.
-
virtual CPLErr ConnectPointsByLines(char **papszLayerList, double dfTolerance, double dfCost, double dfInvCost, GNMDirection eDir)
Attempts to build the network topology automatically.
The method simply gets point and line or multiline layers from the papszLayerList and searches for each line which connects two points: start and end, so it can be not so effective in performance when it is called on huge networks. Note, when passing your tolerance value: this value will depend of spatial reference system of the network, and especially of its 0,0 position because dfTolerance is just divided by 2 and added/subtracted to/from both sides of each line-feature end point forming thus the square area around it. The first point-feature occurred inside this area will be given as a start/end point for the current connection. So it is also desirable that at least two layers are passed in papszLayerList (one point and one line), and they are already connected "visually" ("geometrically").
- パラメータ:
papszLayerList -- A list of layers to connect. The list should be freed via CSLDestroy.
dfTolerance -- Snapping tolerance.
dfCost -- Direct cost.
dfInvCost -- Inverse cost.
eDir -- Direction.
- 戻り値:
CE_None on success
-
virtual CPLErr ChangeBlockState(GNMGFID nFID, bool bIsBlock)
Change the block state of edge or vertex.
- パラメータ:
nFID -- Identificator
bIsBlock -- Block or unblock
- 戻り値:
CE_None on success
-
virtual CPLErr ChangeAllBlockState(bool bIsBlock = false)
Change all vertices and edges block state.
This is mainly use for unblock all vertices and edges.
- パラメータ:
bIsBlock -- Block or unblock
- 戻り値:
CE_None on success
-
virtual OGRLayer *GetPath(GNMGFID nStartFID, GNMGFID nEndFID, GNMGraphAlgorithmType eAlgorithm, char **papszOptions) override
Create path between start and end GFIDs.
- パラメータ:
nStartFID -- - start identificator
nEndFID -- - end identificator
eAlgorithm -- - The algorithm to get path
papszOptions -- - algorithm specific options
- 戻り値:
In memory OGRLayer pointer with features constituting the shortest path (or paths). The caller have to free the pointer via
Protected Functions
-
virtual CPLErr CheckLayerDriver(const char *pszDefaultDriverName, char **papszOptions)
Check or create layer OGR driver.
- パラメータ:
pszDefaultDriverName -- - default driver name
papszOptions -- - create options
- 戻り値:
CE_None if driver is exist or CE_Failure
-
virtual bool CheckStorageDriverSupport(const char *pszDriverName) = 0
Check if provided OGR driver accepted as storage for network data.
- パラメータ:
pszDriverName -- The driver name
- 戻り値:
true if supported, else false
-
class GNMGenericLayer : public OGRLayer
- #include <gnm.h>
GNM layer which represents a geography network layer of generic format.
The class override some OGRLayer methods to fulfill the network requirements.
- Since
GDAL 2.1
Public Functions
-
GNMGenericLayer(OGRLayer *poLayer, GNMGenericNetwork *poNetwork)
-
virtual ~GNMGenericLayer()
~GNMGenericLayer
-
virtual OGRGeometry *GetSpatialFilter() override
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().
- 戻り値:
spatial filter geometry.
-
virtual void SetSpatialFilter(OGRGeometry*) override
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().
- パラメータ:
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.
-
virtual void SetSpatialFilterRect(double dfMinX, double dfMinY, double dfMaxX, double dfMaxY) override
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().
- パラメータ:
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.
-
virtual void SetSpatialFilter(int iGeomField, OGRGeometry*) override
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().
- Since
GDAL 1.11
- パラメータ:
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.
-
virtual void SetSpatialFilterRect(int iGeomField, double dfMinX, double dfMinY, double dfMaxX, double dfMaxY) override
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().
- Since
GDAL 1.11
- パラメータ:
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.
-
virtual OGRErr SetAttributeFilter(const char*) override
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().
- パラメータ:
pszQuery -- query in restricted SQL WHERE format, or NULL to clear the current query.
- 戻り値:
OGRERR_NONE if successfully installed, or an error code if the query expression is in error, or some other failure occurs.
-
virtual void ResetReading() override
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().
-
virtual OGRFeature *GetNextFeature() override
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().
- 戻り値:
a feature, or NULL if no more features are available.
-
virtual OGRErr SetNextByIndex(GIntBig nIndex) override
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().
- パラメータ:
nIndex -- the index indicating how many steps into the result set to seek.
- 戻り値:
OGRERR_NONE on success or an error code.
-
virtual OGRErr DeleteFeature(GIntBig nFID) override
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().
- パラメータ:
nFID -- the feature id to be deleted from the layer
- 戻り値:
OGRERR_NONE if the operation works, otherwise an appropriate error code (e.g OGRERR_NON_EXISTING_FEATURE if the feature does not exist).
-
virtual const char *GetName() override
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().
- Since
OGR 1.8.0
- 戻り値:
the layer name (must not been freed)
-
virtual OGRwkbGeometryType GetGeomType() override
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().
- Since
OGR 1.8.0
- 戻り値:
the geometry type
-
virtual OGRFeatureDefn *GetLayerDefn() override
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().
- 戻り値:
feature definition.
-
virtual int FindFieldIndex(const char *pszFieldName, int bExactMatch) override
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().
- 戻り値:
field index, or -1 if the field doesn't exist
-
virtual OGRSpatialReference *GetSpatialRef() override
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().
- 戻り値:
spatial reference, or NULL if there isn't one.
-
virtual GIntBig GetFeatureCount(int bForce = TRUE) override
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)
- パラメータ:
bForce -- Flag indicating whether the count should be computed even if it is expensive.
- 戻り値:
feature count, -1 if count not known.
-
virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE) override
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().
- パラメータ:
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.
- 戻り値:
OGRERR_NONE on success, OGRERR_FAILURE if extent not known.
-
virtual OGRErr GetExtent(int iGeomField, OGREnvelope *psExtent, int bForce = TRUE) override
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().
- パラメータ:
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.
- 戻り値:
OGRERR_NONE on success, OGRERR_FAILURE if extent not known.
-
virtual int TestCapability(const char*) override
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().
- パラメータ:
pszCap -- the name of the capability to test.
- 戻り値:
TRUE if the layer has the requested capability, or FALSE otherwise. OGRLayers will return FALSE for any unrecognized capabilities.
-
virtual OGRErr CreateField(const OGRFieldDefn *poField, int bApproxOK = TRUE) override
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().
- パラメータ:
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.
- 戻り値:
OGRERR_NONE on success.
-
virtual OGRErr DeleteField(int iField) override
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().
- Since
OGR 1.9.0
- パラメータ:
iField -- index of the field to delete.
- 戻り値:
OGRERR_NONE on success.
-
virtual OGRErr ReorderFields(int *panMap) override
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().
- Since
OGR 1.9.0
- パラメータ:
panMap -- an array of GetLayerDefn()->OGRFeatureDefn::GetFieldCount() elements which is a permutation of [0, GetLayerDefn()->OGRFeatureDefn::GetFieldCount()-1].
- 戻り値:
OGRERR_NONE on success.
-
virtual OGRErr AlterFieldDefn(int iField, OGRFieldDefn *poNewFieldDefn, int nFlagsIn) override
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().
- Since
OGR 1.9.0
- パラメータ:
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.
- 戻り値:
OGRERR_NONE on success.
-
virtual OGRErr CreateGeomField(const OGRGeomFieldDefn *poField, int bApproxOK = TRUE) override
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().
- Since
OGR 1.11
- パラメータ:
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.
- 戻り値:
OGRERR_NONE on success.
-
virtual OGRErr SyncToDisk() override
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().
- 戻り値:
OGRERR_NONE if no error occurs (even if nothing is done) or an error code.
-
virtual OGRStyleTable *GetStyleTable() override
Returns layer style table.
This method is the same as the C function OGR_L_GetStyleTable().
- 戻り値:
pointer to a style table which should not be modified or freed by the caller.
-
virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable) override
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().
- パラメータ:
poStyleTable -- pointer to style table to set
-
virtual void SetStyleTable(OGRStyleTable *poStyleTable) override
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().
- パラメータ:
poStyleTable -- pointer to style table to set
-
virtual OGRErr StartTransaction() override
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().
- 戻り値:
OGRERR_NONE on success.
-
virtual OGRErr CommitTransaction() override
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().
- 戻り値:
OGRERR_NONE on success.
-
virtual OGRErr RollbackTransaction() override
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().
- 戻り値:
OGRERR_NONE on success.
-
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.
This method is the same as the C function OGR_L_GetFIDColumn().
- 戻り値:
fid column name.
-
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.
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().
- 戻り値:
geometry column name.
-
virtual OGRErr SetIgnoredFields(CSLConstList papszFields) override
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()
- パラメータ:
papszFields -- an array of field names terminated by NULL item. If NULL is passed, the ignored list is cleared.
- 戻り値:
OGRERR_NONE if all field names have been resolved (even if the driver does not support this method)
-
OGRErr Intersection(OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions = nullptr, GDALProgressFunc pfnProgress = nullptr, void *pProgressArg = nullptr)
Intersection.
-
OGRErr Union(OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions = nullptr, GDALProgressFunc pfnProgress = nullptr, void *pProgressArg = nullptr)
Union.
-
OGRErr SymDifference(OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions, GDALProgressFunc pfnProgress, void *pProgressArg)
SymDifference.
-
OGRErr Identity(OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions = nullptr, GDALProgressFunc pfnProgress = nullptr, void *pProgressArg = nullptr)
Identity.
-
OGRErr Update(OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions = nullptr, GDALProgressFunc pfnProgress = nullptr, void *pProgressArg = nullptr)
Update.
-
OGRErr Clip(OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions = nullptr, GDALProgressFunc pfnProgress = nullptr, void *pProgressArg = nullptr)
Clip.
-
OGRErr Erase(OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions = nullptr, GDALProgressFunc pfnProgress = nullptr, void *pProgressArg = nullptr)
Erase.
-
int AttributeFilterEvaluationNeedsGeometry()
AttributeFilterEvaluationNeedsGeometry.
-
class GNMRule
- #include <gnm.h>
The simple class for rules.
By now we have only connect rules, so the one class is enough. Maybe in future the set of classes for different rule types will be needed.
- Since
GDAL 2.1
Public Functions
-
GNMRule()
Constructor.
-
explicit GNMRule(const std::string &oRule)
Constructor.
-
explicit GNMRule(const char *pszRule)
Constructor.
-
virtual ~GNMRule()
-
virtual bool IsValid() const
This function indicate if rule string was parsed successfully.
- 戻り値:
true if rule is valid
-
virtual bool IsAcceptAny() const
Indicator of any layer state.
- 戻り値:
true if accept any layer
-
virtual GNMRuleType GetType() const
This is for future use to indicate the rule type/ Now return only GRTConnection type.
- 戻り値:
the rule type
-
virtual bool CanConnect(const CPLString &soSrcLayerName, const CPLString &soTgtLayerName, const CPLString &soConnLayerName = "")
Check if connection can take place.
- パラメータ:
soSrcLayerName -- - the layer name
soTgtLayerName -- - the layer name
soConnLayerName -- - the layer name
- 戻り値:
true if can connect features from soSrcLayerName and soTgtLayerName via soConnLayerName
-
const char *c_str() const
Return rule as a string.
-
operator const char*(void) const
Return rule as a string.
-
class OGRGNMWrappedResultLayer : public OGRLayer
- #include <gnm.h>
The OGRGNMWrappedResultLayer class for search paths queries results.
- Since
GDAL 2.1
Public Functions
-
OGRGNMWrappedResultLayer(GDALDataset *poDS, OGRLayer *poLayer)
Constructor.
-
~OGRGNMWrappedResultLayer()
-
virtual void ResetReading() override
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().
-
virtual OGRFeature *GetNextFeature() override
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().
- 戻り値:
a feature, or NULL if no more features are available.
-
virtual OGRErr SetNextByIndex(GIntBig nIndex) override
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().
- パラメータ:
nIndex -- the index indicating how many steps into the result set to seek.
- 戻り値:
OGRERR_NONE on success or an error code.
-
virtual OGRFeature *GetFeature(GIntBig nFID) override
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().
- パラメータ:
nFID -- the feature id of the feature to read.
- 戻り値:
a feature now owned by the caller, or NULL on failure.
-
virtual OGRFeatureDefn *GetLayerDefn() override
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().
- 戻り値:
feature definition.
-
virtual GIntBig GetFeatureCount(int bForce = TRUE) override
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)
- パラメータ:
bForce -- Flag indicating whether the count should be computed even if it is expensive.
- 戻り値:
feature count, -1 if count not known.
-
virtual int TestCapability(const char *pszCap) override
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().
- パラメータ:
pszCap -- the name of the capability to test.
- 戻り値:
TRUE if the layer has the requested capability, or FALSE otherwise. OGRLayers will return FALSE for any unrecognized capabilities.
-
virtual OGRErr CreateField(const OGRFieldDefn *poField, int bApproxOK = TRUE) override
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().
- パラメータ:
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.
- 戻り値:
OGRERR_NONE on success.
-
virtual OGRErr CreateGeomField(const OGRGeomFieldDefn *poField, int bApproxOK = TRUE) override
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().
- Since
OGR 1.11
- パラメータ:
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.
- 戻り値:
OGRERR_NONE on success.
-
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.
This method is the same as the C function OGR_L_GetFIDColumn().
- 戻り値:
fid column name.
-
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.
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().
- 戻り値:
geometry column name.
-
virtual OGRSpatialReference *GetSpatialRef() override
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().
- 戻り値:
spatial reference, or NULL if there isn't one.
-
virtual OGRErr InsertFeature(OGRFeature *poFeature, const CPLString &soLayerName, int nPathNo, bool bIsEdge)
Undocumented.
Protected Functions
-
virtual OGRErr ISetFeature(OGRFeature *poFeature) override
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.
参考
- Since
GDAL 2.0
- パラメータ:
poFeature -- the feature to write.
- 戻り値:
OGRERR_NONE if the operation works, otherwise an appropriate error code (e.g OGRERR_NON_EXISTING_FEATURE if the feature does not exist).
-
virtual OGRErr ICreateFeature(OGRFeature *poFeature) override
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.
- Since
GDAL 2.0
- パラメータ:
poFeature -- the feature to write to disk.
- 戻り値:
OGRERR_NONE on success.