Class: QgsArcGisRestUtils

Utility functions for working with ArcGIS REST services.

Added in version 3.18.

List of all members, including inherited members

Enums

FeatureToJsonFlag

Flags which control the behavior of converting features to JSON.

Methods

FeatureToJsonFlags

Static Methods

convertColor

Converts ESRI JSON color data to a QColor object.

convertDateTime

Converts a date time value to a QDateTime.

convertFieldType

Converts an ESRI REST field type to a QVariant type.

convertFillStyle

Converts an ESRI fill style to a Qt brush style.

convertGeometry

Converts an ESRI REST geometry JSON definition to a QgsAbstractGeometry.

convertGeometryType

Converts an ESRI REST geometry type to a WKB type.

convertLabeling

Converts labeling JSON data to an equivalent QGIS vector labeling.

convertLabelingExpression

Converts an ESRI labeling expression to a QGIS expression string.

convertLineStyle

Converts an ESRI line style to a Qt pen style.

convertRectangle

Converts a rectangle value to a QgsRectangle.

convertRenderer

Converts renderer JSON data to an equivalent QgsFeatureRenderer.

convertSpatialReference

Converts a spatial reference JSON definition to a QgsCoordinateReferenceSystem value.

convertSymbol

Converts a symbol JSON definition to a QgsSymbol.

crsToJson

Converts a crs to an ArcGIS REST JSON representation.

featureToJson

Converts a feature to an ArcGIS REST JSON representation.

fieldDefinitionToJson

Converts a field's definition to an ArcGIS REST JSON representation.

geometryToJson

Converts a geometry to an ArcGIS REST JSON representation.

serviceTypeFromString

Converts a string value to a REST service type.

variantToAttributeValue

Converts a variant to a REST attribute value.

class qgis.core.QgsArcGisRestUtils[source]

Bases: object

class FeatureToJsonFlag(*values)

Bases: IntFlag

Flags which control the behavior of converting features to JSON.

Added in version 3.28.

  • IncludeGeometry: Whether to include the geometry definition

  • IncludeNonObjectIdAttributes: Whether to include any non-objectId attributes

  • SkipUnsetAttributes: Skip unset attributes.

    Added in version 3.44.

IncludeGeometry = 1
IncludeNonObjectIdAttributes = 2
SkipUnsetAttributes = 4
FeatureToJsonFlags()
static convertColor(data: Any) QColor[source]

Converts ESRI JSON color data to a QColor object.

Parameters:

data (Any)

Return type:

QColor

static convertDateTime(value: Any) QDateTime[source]

Converts a date time value to a QDateTime.

Parameters:

value (Any)

Return type:

QDateTime

static convertFieldType(type: str | None) QMetaType.Type[source]

Converts an ESRI REST field type to a QVariant type.

Parameters:

type (Optional[str])

Return type:

QMetaType.Type

static convertFillStyle(style: str | None) Qt.BrushStyle[source]

Converts an ESRI fill style to a Qt brush style.

Parameters:

style (Optional[str])

Return type:

Qt.BrushStyle

static convertGeometry(geometry: dict[str | None, Any], esriGeometryType: str | None, hasM: bool, hasZ: bool, allowCurves: bool = True)

Converts an ESRI REST geometry JSON definition to a QgsAbstractGeometry.

Caller takes ownership of the returned object.

Parameters:
  • geometry (dict[Optional[str], Any]) – JSON geometry definition

  • esriGeometryType (Optional[str]) – ESRI geometry type string

  • hasM (bool) – set to True to if geometry includes M values

  • hasZ (bool) – set to True to if geometry includes Z values

  • allowCurves (bool = True) – controls whether the returned geometry can be a curved geometry type (since QGIS 4.0)

Return type:

(Optional[QgsAbstractGeometry], Optional[QgsCoordinateReferenceSystem])

Returns:

  • converted geometry

  • crs: the parsed geometry CRS

static convertGeometryType(type: str | None) Qgis.WkbType[source]

Converts an ESRI REST geometry type to a WKB type.

Parameters:

type (Optional[str])

Return type:

Qgis.WkbType

static convertLabeling(data: Iterable[Any]) QgsAbstractVectorLayerLabeling | None

Converts labeling JSON data to an equivalent QGIS vector labeling.

Caller takes ownership of the returned object.

Parameters:

data (Iterable[Any])

Return type:

Optional[QgsAbstractVectorLayerLabeling]

static convertLabelingExpression(string: str | None) str[source]

Converts an ESRI labeling expression to a QGIS expression string.

Parameters:

string (Optional[str])

Return type:

str

static convertLineStyle(style: str | None) Qt.PenStyle[source]

Converts an ESRI line style to a Qt pen style.

Parameters:

style (Optional[str])

Return type:

Qt.PenStyle

static convertRectangle(value: Any) QgsRectangle[source]

Converts a rectangle value to a QgsRectangle.

Returns a null rectangle if the value cannot be converted.

Added in version 3.34.

Parameters:

value (Any)

Return type:

QgsRectangle

static convertRenderer(rendererData: dict[str | None, Any]) QgsFeatureRenderer | None

Converts renderer JSON data to an equivalent QgsFeatureRenderer.

Caller takes ownership of the returned renderer.

Parameters:

rendererData (dict[Optional[str], Any])

Return type:

Optional[QgsFeatureRenderer]

static convertSpatialReference(spatialReferenceMap: dict[str | None, Any]) QgsCoordinateReferenceSystem[source]

Converts a spatial reference JSON definition to a QgsCoordinateReferenceSystem value.

Parameters:

spatialReferenceMap (dict[Optional[str], Any])

Return type:

QgsCoordinateReferenceSystem

static convertSymbol(definition: dict[str | None, Any]) QgsSymbol | None

Converts a symbol JSON definition to a QgsSymbol.

Caller takes ownership of the returned symbol.

Parameters:

definition (dict[Optional[str], Any])

Return type:

Optional[QgsSymbol]

static crsToJson(crs: QgsCoordinateReferenceSystem) dict[str, Any][source]

Converts a crs to an ArcGIS REST JSON representation.

Returns an empty map if the crs is not valid.

Added in version 3.28.

Parameters:

crs (QgsCoordinateReferenceSystem)

Return type:

dict[str, Any]

static featureToJson(feature: QgsFeature, context: QgsArcGisRestContext, crs: QgsCoordinateReferenceSystem = QgsCoordinateReferenceSystem(), flags: QgsArcGisRestUtils.FeatureToJsonFlag = QgsArcGisRestUtils.FeatureToJsonFlags(unknown - type(QgsArcGisRestUtils.FeatureToJsonFlag.IncludeGeometry) | unknown - type(QgsArcGisRestUtils.FeatureToJsonFlag.IncludeNonObjectIdAttributes))) dict[str, Any][source]

Converts a feature to an ArcGIS REST JSON representation.

Added in version 3.28.

Parameters:
Return type:

dict[str, Any]

static fieldDefinitionToJson(field: QgsField) dict[str, Any][source]

Converts a field’s definition to an ArcGIS REST JSON representation.

Added in version 3.28.

Parameters:

field (QgsField)

Return type:

dict[str, Any]

static geometryToJson(geometry: QgsGeometry, context: QgsArcGisRestContext, crs: QgsCoordinateReferenceSystem = QgsCoordinateReferenceSystem()) dict[str, Any][source]

Converts a geometry to an ArcGIS REST JSON representation.

Returns an empty map if the geometry cannot be converted.

Added in version 3.28.

Parameters:
Return type:

dict[str, Any]

static serviceTypeFromString(type: str | None) Qgis.ArcGisRestServiceType[source]

Converts a string value to a REST service type.

Added in version 3.28.

Parameters:

type (Optional[str])

Return type:

Qgis.ArcGisRestServiceType

static variantToAttributeValue(variant: Any, expectedType: QMetaType.Type, context: QgsArcGisRestContext) Any[source]

Converts a variant to a REST attribute value.

Added in version 3.28.

Parameters:
Return type:

Any