OGR
Public Member Functions | List of all members
OGRGenSQLResultsLayer Class Reference
Inheritance diagram for OGRGenSQLResultsLayer:
OGRLayer

Public Member Functions

virtual OGRGeometryGetSpatialFilter ()
 This method returns the current spatial filter for this layer. More...
 
virtual void ResetReading ()
 Reset feature reading to start on the first feature. More...
 
virtual OGRFeatureGetNextFeature ()
 Fetch the next available feature from this layer. More...
 
virtual OGRErr SetNextByIndex (long nIndex)
 Move read cursor to the nIndex'th feature in the current resultset. More...
 
virtual OGRFeatureGetFeature (long nFID)
 Fetch a feature by its identifier. More...
 
virtual OGRFeatureDefnGetLayerDefn ()
 Fetch the schema information for this layer. More...
 
virtual int GetFeatureCount (int bForce=TRUE)
 Fetch the feature count in this layer. More...
 
virtual OGRErr GetExtent (OGREnvelope *psExtent, int bForce=TRUE)
 Fetch the extent of this layer. More...
 
virtual OGRErr GetExtent (int iGeomField, OGREnvelope *psExtent, int bForce=TRUE)
 Fetch the extent of this layer, on the specified geometry field. More...
 
virtual int TestCapability (const char *)
 Test if this layer supported the named capability. More...
 
virtual void SetSpatialFilter (OGRGeometry *poGeom)
 Set a new spatial filter. More...
 
virtual void SetSpatialFilter (int iGeomField, OGRGeometry *)
 Set a new spatial filter. More...
 
virtual OGRErr SetAttributeFilter (const char *)
 Set a new attribute query. More...
 
- Public Member Functions inherited from OGRLayer
virtual void SetSpatialFilterRect (double dfMinX, double dfMinY, double dfMaxX, double dfMaxY)
 Set a new rectangular spatial filter. More...
 
virtual void SetSpatialFilterRect (int iGeomField, double dfMinX, double dfMinY, double dfMaxX, double dfMaxY)
 Set a new rectangular spatial filter. More...
 
virtual OGRErr SetFeature (OGRFeature *poFeature)
 Rewrite an existing feature. More...
 
virtual OGRErr CreateFeature (OGRFeature *poFeature)
 Create and write a new feature within a layer. More...
 
virtual OGRErr DeleteFeature (long nFID)
 Delete feature from layer. More...
 
virtual const char * GetName ()
 Return the layer name. More...
 
virtual OGRwkbGeometryType GetGeomType ()
 Return the layer geometry type. More...
 
virtual int FindFieldIndex (const char *pszFieldName, int bExactMatch)
 Find the index of field in the layer. More...
 
virtual OGRSpatialReferenceGetSpatialRef ()
 Fetch the spatial reference system for this layer. More...
 
virtual const char * GetInfo (const char *)
 Fetch metadata from layer. More...
 
virtual OGRErr CreateField (OGRFieldDefn *poField, int bApproxOK=TRUE)
 Create a new field on a layer. More...
 
virtual OGRErr DeleteField (int iField)
 Delete an existing field on a layer. More...
 
virtual OGRErr ReorderFields (int *panMap)
 Reorder all the fields of a layer. More...
 
virtual OGRErr AlterFieldDefn (int iField, OGRFieldDefn *poNewFieldDefn, int nFlags)
 Alter the definition of an existing field on a layer. More...
 
virtual OGRErr CreateGeomField (OGRGeomFieldDefn *poField, int bApproxOK=TRUE)
 Create a new geometry field on a layer. More...
 
virtual OGRErr SyncToDisk ()
 Flush pending changes to disk. More...
 
virtual OGRStyleTableGetStyleTable ()
 Returns layer style table. More...
 
virtual void SetStyleTableDirectly (OGRStyleTable *poStyleTable)
 Set layer style table. More...
 
virtual void SetStyleTable (OGRStyleTable *poStyleTable)
 Set layer style table. More...
 
virtual const char * GetFIDColumn ()
 This method returns the name of the underlying database column being used as the FID column, or "" if not supported. More...
 
virtual const char * GetGeometryColumn ()
 This method returns the name of the underlying database column being used as the geometry column, or "" if not supported. More...
 
virtual OGRErr SetIgnoredFields (const char **papszFields)
 Set which fields can be omitted when retrieving features from the layer. More...
 
OGRErr Intersection (OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions=NULL, GDALProgressFunc pfnProgress=NULL, void *pProgressArg=NULL)
 Intersection of two layers. More...
 
OGRErr Union (OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions=NULL, GDALProgressFunc pfnProgress=NULL, void *pProgressArg=NULL)
 Union of two layers. More...
 
OGRErr SymDifference (OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions, GDALProgressFunc pfnProgress, void *pProgressArg)
 Symmetrical difference of two layers. More...
 
OGRErr Identity (OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions=NULL, GDALProgressFunc pfnProgress=NULL, void *pProgressArg=NULL)
 Identify the features of this layer with the ones from the identity layer. More...
 
OGRErr Update (OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions=NULL, GDALProgressFunc pfnProgress=NULL, void *pProgressArg=NULL)
 Update this layer with features from the update layer. More...
 
OGRErr Clip (OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions=NULL, GDALProgressFunc pfnProgress=NULL, void *pProgressArg=NULL)
 Clip off areas that are not covered by the method layer. More...
 
OGRErr Erase (OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions=NULL, GDALProgressFunc pfnProgress=NULL, void *pProgressArg=NULL)
 Remove areas that are covered by the method layer. More...
 
int Reference ()
 Increment layer reference count. More...
 
int Dereference ()
 Decrement layer reference count. More...
 
int GetRefCount () const
 Fetch reference count. More...
 
OGRErr ReorderField (int iOldFieldPos, int iNewFieldPos)
 Reorder an existing field on a layer. More...
 

Member Function Documentation

virtual OGRErr OGRGenSQLResultsLayer::GetExtent ( OGREnvelope psExtent,
int  bForce = TRUE 
)
inlinevirtual

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
psExtentthe structure in which the extent value will be returned.
bForceFlag indicating whether the extent should be computed even if it is expensive.
Returns
OGRERR_NONE on success, OGRERR_FAILURE if extent not known.

Reimplemented from OGRLayer.

References OGRLayer::GetExtent(), GetExtent(), and OGRLayer::TestCapability().

Referenced by GetExtent().

OGRErr OGRGenSQLResultsLayer::GetExtent ( int  iGeomField,
OGREnvelope psExtent,
int  bForce = TRUE 
)
virtual

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 implementators: 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
iGeomFieldthe index of the geometry field on which to compute the extent.
psExtentthe structure in which the extent value will be returned.
bForceFlag indicating whether the extent should be computed even if it is expensive.
Returns
OGRERR_NONE on success, OGRERR_FAILURE if extent not known.

Reimplemented from OGRLayer.

References CPLError(), OGRLayer::GetExtent(), and wkbNone.

OGRFeature * OGRGenSQLResultsLayer::GetFeature ( long  nFID)
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
nFIDthe feature id of the feature to read.
Returns
a feature now owned by the caller, or NULL on failure.

Reimplemented from OGRLayer.

References OGRFeature::SetFID().

int OGRGenSQLResultsLayer::GetFeatureCount ( int  bForce = TRUE)
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().

Parameters
bForceFlag indicating whether the count should be computed even if it is expensive.
Returns
feature count, -1 if count not known.

Reimplemented from OGRLayer.

References OGRLayer::GetFeatureCount().

OGRFeatureDefn * OGRGenSQLResultsLayer::GetLayerDefn ( )
virtual
OGRFeature * OGRGenSQLResultsLayer::GetNextFeature ( )
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.

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.

References OGRFeature::GetGeomFieldRef().

OGRGeometry * OGRGenSQLResultsLayer::GetSpatialFilter ( )
virtual

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 from OGRLayer.

void OGRGenSQLResultsLayer::ResetReading ( )
virtual

Reset feature reading to start on the first feature.

This affects GetNextFeature().

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

Implements OGRLayer.

OGRErr OGRGenSQLResultsLayer::SetAttributeFilter ( const char *  pszQuery)
virtual

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 restricted form of SQL WHERE clause as described in the "WHERE" section of the OGR SQL tutorial. In some cases (RDBMS backed drivers) the native capabilities of the database may be used to interprete 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
pszQueryquery 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 from OGRLayer.

References OGRLayer::SetAttributeFilter().

OGRErr OGRGenSQLResultsLayer::SetNextByIndex ( long  nIndex)
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
nIndexthe index indicating how many steps into the result set to seek.
Returns
OGRERR_NONE on success or an error code.

Reimplemented from OGRLayer.

virtual void OGRGenSQLResultsLayer::SetSpatialFilter ( OGRGeometry poFilter)
inlinevirtual

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 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
poFilterthe 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 from OGRLayer.

References OGRLayer::SetAttributeFilter(), OGRLayer::SetSpatialFilter(), and SetSpatialFilter().

Referenced by SetSpatialFilter().

void OGRGenSQLResultsLayer::SetSpatialFilter ( int  iGeomField,
OGRGeometry poFilter 
)
virtual

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()->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 implementators: 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
iGeomFieldindex of the geometry field on which the spatial filter operates.
poFilterthe 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 from OGRLayer.

References OGRLayer::SetSpatialFilter().

int OGRGenSQLResultsLayer::TestCapability ( const char *  pszCap)
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 returned 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 returned 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 ... ie. 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 ... ie. 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.

  • 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.

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

Parameters
pszCapthe name of the capability to test.
Returns
TRUE if the layer has the requested capability, or FALSE otherwise. OGRLayers will return FALSE for any unrecognised capabilities.

Implements OGRLayer.

References CPLError(), CPLEscapeString(), OGRFeature::GetDefnRef(), OGRFeature::GetFID(), OGRFeature::GetFieldAsDouble(), OGRFeature::GetFieldAsInteger(), OGRFeature::GetFieldAsString(), OGRFeatureDefn::GetFieldCount(), OGRFeatureDefn::GetFieldDefn(), OGRGeometry::getGeometryType(), OGRFeature::GetGeomFieldDefnRef(), OGRFeature::GetGeomFieldRef(), OGRLayer::GetLayerDefn(), OGRFieldDefn::GetNameRef(), OGRLayer::GetNextFeature(), OGRFeature::GetRawFieldRef(), OGRFeature::GetStyleString(), OGRFieldDefn::GetType(), OGRGeomFieldDefn::GetType(), OGRFeature::IsFieldSet(), OFTInteger, OFTReal, OFTString, OGR_G_ForceToLineString(), OGR_G_ForceToMultiLineString(), OGR_G_ForceToMultiPolygon(), OGR_G_ForceToPolygon(), OGRLayer::ResetReading(), OGRLayer::SetAttributeFilter(), OGRFeature::SetFID(), OGRFeature::SetField(), OGRFeature::SetGeomField(), OGRFeature::SetStyleString(), wkbGeometryCollection, wkbLineString, wkbMultiLineString, wkbMultiPolygon, and wkbPolygon.


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

Generated for GDAL by doxygen 1.8.11.