@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
34 lines (32 loc) • 2.08 kB
TypeScript
/**
* Provides utility methods for working with ArcGIS JSON geometry objects.
*
* @since 4.0
* @see [Geometry](https://developers.arcgis.com/javascript/latest/references/core/geometry/Geometry/)
* @see [Using fromJSON() to create a class instance](https://developers.arcgis.com/javascript/latest/using-fromjson)
*/
import type { GeometryUnion } from "../types.js";
import type { GeometryType } from "../../portal/jsonTypes.js";
/**
* Creates a new instance of an appropriate [Geometry](https://developers.arcgis.com/javascript/latest/references/core/geometry/Geometry/) class and initializes it with values from a JSON object
* generated from an ArcGIS product. The object passed into the input `json`
* parameter often comes from a response to a query operation in the REST API or a
* [toJSON()](https://pro.arcgis.com/en/pro-app/latest/tool-reference/conversion/features-to-json.htm)
* method from another ArcGIS product. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/using-fromjson)
* topic in the Guide for details and examples of when and how to use this function.
*
* @param json - A JSON representation of the instance in the ArcGIS format. See
* the [ArcGIS REST API documentation](https://developers.arcgis.com/documentation/common-data-types/overview-of-common-data-types.htm)
* for examples of the structure of various input JSON objects.
* @returns Returns a new instance of an appropriate Geometry class.
*/
export function fromJSON(json: object | null | undefined): GeometryUnion | null | undefined;
/**
* Returns the type for a given geometry in the JSON format used by ArcGIS.
* This only applies to geometries that can be processed by the server.
*
* @param geometry - The input geometry object.
* @returns Returns the [Geometry.type](https://developers.arcgis.com/javascript/latest/references/core/geometry/Geometry/#type) as
* represented on the server.
*/
export function getJsonType(geometry: GeometryUnion | null | undefined): GeometryType | null | undefined;