QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
|
Utilities for working with OGR features and layers. More...
#include <qgsogrutils.h>
Static Public Member Functions | |
static OGRFieldDomainH | convertFieldDomain (const QgsFieldDomain *domain) |
Converts a QGIS field domain definition to an OGR field domain equivalent. More... | |
static std::unique_ptr< QgsFieldDomain > | convertFieldDomain (OGRFieldDomainH domain) |
Converts an OGR field domain definition to a QgsFieldDomain equivalent. More... | |
static gdal::relationship_unique_ptr | convertRelationship (const QgsWeakRelation &relation, QString &error) |
Converts a QGIS relation to a GDAL relationship equivalent. More... | |
static QgsWeakRelation | convertRelationship (GDALRelationshipH relationship, const QString &datasetUri) |
Converts an GDAL relationship definition to a QgsWeakRelation equivalent. More... | |
static OGRSpatialReferenceH | crsToOGRSpatialReference (const QgsCoordinateReferenceSystem &crs) |
Returns a OGRSpatialReferenceH corresponding to the specified crs object. More... | |
static QStringList | cStringListToQStringList (char **stringList) |
Converts a c string list to a QStringList. More... | |
static QVariant | getOgrFeatureAttribute (OGRFeatureH ogrFet, const QgsField &field, int attIndex, QTextCodec *encoding, bool *ok=nullptr) |
Retrieves an attribute value from an OGR feature, using a provided field definition. More... | |
static QVariant | getOgrFeatureAttribute (OGRFeatureH ogrFet, const QgsFields &fields, int attIndex, QTextCodec *encoding, bool *ok=nullptr) |
Retrieves an attribute value from an OGR feature. More... | |
static QList< QgsVectorDataProvider::NativeType > | nativeFieldTypesForDriver (GDALDriverH driver) |
Returns the list of native field types supported for a driver. More... | |
static QVariant | OGRFieldtoVariant (const OGRField *value, OGRFieldType type) |
Converts an OGRField value of the specified type into a QVariant. More... | |
static void | ogrFieldTypeToQVariantType (OGRFieldType ogrType, OGRFieldSubType ogrSubType, QVariant::Type &variantType, QVariant::Type &variantSubType) |
Converts an OGR field type and sub type to the best matching QVariant::Type equivalent. More... | |
static QgsGeometry | ogrGeometryToQgsGeometry (OGRGeometryH geom) |
Converts an OGR geometry representation to a QgsGeometry object. More... | |
static Qgis::WkbType | ogrGeometryTypeToQgsWkbType (OGRwkbGeometryType ogrGeomType) |
Converts a OGRwkbGeometryType to QgsWkbTypes::Type. More... | |
static QgsCoordinateReferenceSystem | OGRSpatialReferenceToCrs (OGRSpatialReferenceH srs) |
Returns a QgsCoordinateReferenceSystem corresponding to the specified OGR srs object, or an invalid QgsCoordinateReferenceSystem if srs could not be converted. More... | |
static QString | OGRSpatialReferenceToWkt (OGRSpatialReferenceH srs) |
Returns a WKT string corresponding to the specified OGR srs object. More... | |
static int | OGRTZFlagFromQt (const QDateTime &datetime) |
Gets the value of OGRField::Date::TZFlag from the timezone of a QDateTime. More... | |
static QVariantMap | parseStyleString (const QString &string) |
Parses an OGR style string to a variant map containing the style string components. More... | |
static QgsFeature | readOgrFeature (OGRFeatureH ogrFet, const QgsFields &fields, QTextCodec *encoding) |
Reads an OGR feature and converts it to a QgsFeature. More... | |
static bool | readOgrFeatureAttributes (OGRFeatureH ogrFet, const QgsFields &fields, QgsFeature &feature, QTextCodec *encoding) |
Reads all attributes from an OGR feature into a QgsFeature. More... | |
static bool | readOgrFeatureGeometry (OGRFeatureH ogrFet, QgsFeature &feature) |
Reads the geometry from an OGR feature into a QgsFeature. More... | |
static QgsFields | readOgrFields (OGRFeatureH ogrFet, QTextCodec *encoding) |
Reads an OGR feature and returns a corresponding fields collection. More... | |
static QString | readShapefileEncoding (const QString &path) |
Reads the encoding of the shapefile at the specified path (where path is the location of the ".shp" file). More... | |
static QString | readShapefileEncodingFromCpg (const QString &path) |
Reads the encoding of the shapefile at the specified path (where path is the location of the ".shp" file), from the CPG specified encoding. More... | |
static QString | readShapefileEncodingFromLdid (const QString &path) |
Reads the encoding of the shapefile at the specified path (where path is the location of the ".shp" file), from the DBF LDID encoding. More... | |
static QgsFeatureList | stringToFeatureList (const QString &string, const QgsFields &fields, QTextCodec *encoding) |
Attempts to parse a string representing a collection of features using OGR. More... | |
static QgsFields | stringToFields (const QString &string, QTextCodec *encoding) |
Attempts to retrieve the fields from a string representing a collection of features using OGR. More... | |
static QVariant | stringToVariant (OGRFieldType type, OGRFieldSubType subType, const QString &string) |
Converts a string to a variant, using the provider OGR field type and subType to determine the most appropriate variant type. More... | |
static std::unique_ptr< QgsSymbol > | symbolFromStyleString (const QString &string, Qgis::SymbolType type) |
Creates a new QgsSymbol matching an OGR style string. More... | |
static std::unique_ptr< OGRField > | variantToOGRField (const QVariant &value) |
Converts a QVariant to an OGRField value. More... | |
static void | variantTypeToOgrFieldType (QVariant::Type variantType, OGRFieldType &ogrType, OGRFieldSubType &ogrSubType) |
Converts an QVariant type to the best matching OGR field type and sub type. More... | |
Utilities for working with OGR features and layers.
Contains helper utilities for assisting work with both OGR features and layers.
Definition at line 192 of file qgsogrutils.h.
|
static |
Converts a QGIS field domain definition to an OGR field domain equivalent.
Definition at line 2151 of file qgsogrutils.cpp.
|
static |
Converts an OGR field domain definition to a QgsFieldDomain equivalent.
Definition at line 2058 of file qgsogrutils.cpp.
|
static |
Converts a QGIS relation to a GDAL relationship equivalent.
Definition at line 2385 of file qgsogrutils.cpp.
|
static |
Converts an GDAL relationship definition to a QgsWeakRelation equivalent.
Definition at line 2261 of file qgsogrutils.cpp.
|
static |
Returns a OGRSpatialReferenceH corresponding to the specified crs object.
Definition at line 1114 of file qgsogrutils.cpp.
|
static |
Converts a c string list to a QStringList.
Presumes a null terminated string list.
Definition at line 1050 of file qgsogrutils.cpp.
|
static |
Retrieves an attribute value from an OGR feature, using a provided field definition.
ogrFet | OGR feature handle |
field | definition of corresponding field |
attIndex | index of attribute to retrieve from ogrFet |
encoding | text encoding |
ok | optional storage for success of retrieval |
Definition at line 397 of file qgsogrutils.cpp.
|
static |
Retrieves an attribute value from an OGR feature.
ogrFet | OGR feature handle |
fields | fields collection corresponding to feature |
attIndex | index of attribute to retrieve |
encoding | text encoding |
ok | optional storage for success of retrieval |
Definition at line 384 of file qgsogrutils.cpp.
|
static |
Returns the list of native field types supported for a driver.
Definition at line 1938 of file qgsogrutils.cpp.
|
static |
Converts an OGRField value of the specified type into a QVariant.
Definition at line 143 of file qgsogrutils.cpp.
|
static |
Converts an OGR field type and sub type to the best matching QVariant::Type equivalent.
ogrType | OGR field type |
ogrSubType | OGR field sub type |
variantType | will be set to matching QVariant type |
variantSubType | will be set to matching QVariant sub type, for list, map and other complex OGR field types. |
Definition at line 1759 of file qgsogrutils.cpp.
|
static |
Converts an OGR geometry representation to a QgsGeometry object.
geom | OGR geometry handle |
Definition at line 839 of file qgsogrutils.cpp.
|
static |
Converts a OGRwkbGeometryType to QgsWkbTypes::Type.
Definition at line 753 of file qgsogrutils.cpp.
|
static |
Returns a QgsCoordinateReferenceSystem corresponding to the specified OGR srs object, or an invalid QgsCoordinateReferenceSystem if srs could not be converted.
Definition at line 1081 of file qgsogrutils.cpp.
|
static |
Returns a WKT string corresponding to the specified OGR srs object.
The WKT string format will be selected using the most appropriate format (usually WKT2 if GDAL 3 is available).
Definition at line 1065 of file qgsogrutils.cpp.
|
static |
Gets the value of OGRField::Date::TZFlag from the timezone of a QDateTime.
Definition at line 228 of file qgsogrutils.cpp.
|
static |
Parses an OGR style string to a variant map containing the style string components.
Definition at line 1195 of file qgsogrutils.cpp.
|
static |
Reads an OGR feature and converts it to a QgsFeature.
ogrFet | OGR feature handle |
fields | fields collection corresponding to feature |
encoding | text encoding |
Definition at line 302 of file qgsogrutils.cpp.
|
static |
Reads all attributes from an OGR feature into a QgsFeature.
ogrFet | OGR feature handle |
fields | fields collection corresponding to feature |
feature | QgsFeature to store attributes in |
encoding | text encoding |
true
if attribute read was successful Definition at line 623 of file qgsogrutils.cpp.
|
static |
Reads the geometry from an OGR feature into a QgsFeature.
ogrFet | OGR feature handle |
feature | QgsFeature to store geometry in |
true
if geometry read was successful Definition at line 644 of file qgsogrutils.cpp.
|
static |
Reads an OGR feature and returns a corresponding fields collection.
ogrFet | OGR feature handle |
encoding | text encoding |
Definition at line 327 of file qgsogrutils.cpp.
|
static |
Reads the encoding of the shapefile at the specified path (where path is the location of the ".shp" file).
This method considers both the CPG specified encoding and the DBF LDID encoding (priority goes to CPG based encoding)
Definition at line 1172 of file qgsogrutils.cpp.
|
static |
Reads the encoding of the shapefile at the specified path (where path is the location of the ".shp" file), from the CPG specified encoding.
Return an empty string if CPG based encoding was not found.
Definition at line 1181 of file qgsogrutils.cpp.
|
static |
Reads the encoding of the shapefile at the specified path (where path is the location of the ".shp" file), from the DBF LDID encoding.
Return an empty string if LDID based encoding was not found.
Definition at line 1188 of file qgsogrutils.cpp.
|
static |
Attempts to parse a string representing a collection of features using OGR.
For example, this method can be used to convert a GeoJSON encoded collection to a list of QgsFeatures.
string | string to parse |
fields | fields collection to use for parsed features ( |
encoding | text encoding |
Definition at line 968 of file qgsogrutils.cpp.
|
static |
Attempts to retrieve the fields from a string representing a collection of features using OGR.
string | string to parse |
encoding | text encoding |
Definition at line 1010 of file qgsogrutils.cpp.
|
static |
Converts a string to a variant, using the provider OGR field type and subType to determine the most appropriate variant type.
Definition at line 1887 of file qgsogrutils.cpp.
|
static |
Creates a new QgsSymbol matching an OGR style string.
Definition at line 1242 of file qgsogrutils.cpp.
|
static |
Converts a QVariant to an OGRField value.
Definition at line 235 of file qgsogrutils.cpp.
|
static |
Converts an QVariant type to the best matching OGR field type and sub type.
variantType | QVariant field type |
ogrType | will be set to matching OGR type |
ogrSubType | will be set to matching OGR sub type |
Definition at line 1832 of file qgsogrutils.cpp.