fromJsonWithSpatialReference static method

Geometry? fromJsonWithSpatialReference(
  1. {required String inputJson,
  2. required SpatialReference? spatialReference}
)

Creates a geometry from an ArcGIS JSON geometry representation.

Geometry can be serialized and de-serialized to and from JSON. The ArcGIS REST API documentation describes the JSON representation of geometry objects. You can use this encoding and decoding mechanism to exchange geometries with REST Web services or to store them in text files.

Parameters:

  • inputJson — JSON representation of geometry.
  • spatialReference — The geometry's spatial reference.

Return Value: Geometry converted from a JSON String.

Implementation

static Geometry? fromJsonWithSpatialReference(
    {required String inputJson,
    required SpatialReference? spatialReference}) {
  _initializeArcGISEnvironmentIfNeeded();
  final coreInputJson = _CString(inputJson);
  final objectHandle = _withThrowingErrorHandler((errorHandler) {
    return runtimecore.RT_Geometry_fromJSONWithSpatialReference(
        coreInputJson.bytes,
        spatialReference?._handle ?? ffi.nullptr,
        errorHandler);
  });
  return Geometry._fromHandle(objectHandle);
}