Class: QgsArcGisRestUtils

Utility functions for working with ArcGIS REST services.

Added in version 3.18.

Enums

FeatureToJsonFlag

Flags which control the behavior of converting features to JSON.

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: IntEnum

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
class FeatureToJsonFlags
class FeatureToJsonFlags(f: QgsArcGisRestUtils.FeatureToJsonFlags | QgsArcGisRestUtils.FeatureToJsonFlag)
class FeatureToJsonFlags(a0: QgsArcGisRestUtils.FeatureToJsonFlags)

Bases: object

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, Any], esriGeometryType: str | None, hasM: bool, hasZ: bool)[source]

Converts an ESRI REST geometry JSON definition to a QgsAbstractGeometry.

Caller takes ownership of the returned object.

Parameters:
  • geometry (Dict[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) -> (Optional[QgsAbstractGeometry]) – set to True to if geometry includes Z values

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[source]

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, Any]) QgsFeatureRenderer | None[source]

Converts renderer JSON data to an equivalent QgsFeatureRenderer.

Caller takes ownership of the returned renderer.

Parameters:

rendererData (Dict[str, Any])

Return type:

Optional[QgsFeatureRenderer]

static convertSpatialReference(spatialReferenceMap: Dict[str, Any]) QgsCoordinateReferenceSystem[source]

Converts a spatial reference JSON definition to a QgsCoordinateReferenceSystem value.

Parameters:

spatialReferenceMap (Dict[str, Any])

Return type:

QgsCoordinateReferenceSystem

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

Converts a symbol JSON definition to a QgsSymbol.

Caller takes ownership of the returned symbol.

Parameters:

definition (Dict[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.FeatureToJsonFlags | 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