UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

74 lines (71 loc) 4.15 kB
/** * Provides a utility method that normalizes geometries that intersect the central * meridian or fall outside the world extent so they stay within the coordinate system * of the view. Support is limited to geometries in Web Mercator and WGS-84 spatial references. * * @since 4.3 */ import type Extent from "../Extent.js"; import type Mesh from "../Mesh.js"; import type Multipoint from "../Multipoint.js"; import type Point from "../Point.js"; import type Polygon from "../Polygon.js"; import type Polyline from "../Polyline.js"; import type { RequestOptions } from "../../request/types.js"; export type Geometry = Extent | Multipoint | Point | Polygon | Polyline | Mesh; /** * Normalizes geometries that intersect the central meridian or fall outside the * world extent so they stay within the coordinate system of the view. Only supported * for Web Mercator and WGS84 spatial references. * * @param geometries - An array of geometries to normalize. * @param url - A geometry service URL used to * perform the normalization. If this value is `null` then the default geometry service URL in * [esriConfig.geometryServiceUrl](https://developers.arcgis.com/javascript/latest/references/core/config/#Config-geometryServiceUrl) is used. * @param requestOptions - Additional [options](https://developers.arcgis.com/javascript/latest/references/core/request/#request) to be used for the data request. * @returns Resolves to an array of the normalized geometries. * @example * // create a non-normalized line that crosses the dateline * const polyline = new Polyline({ * paths: [ * [170, 52.68], * [190, 49.5] * ] * }); * * normalizeUtils.normalizeCentralMeridian([polyline]) * .then(function(polylines){ * // returns a line representing the same geometry, but * // now is normalized between -180 and 180 on the x-coordinate. * // but represents the same feature * const graphic = new Graphic({ * geometry: polylines[0], * symbol: { type: "simple-line" } * }); */ export function normalizeCentralMeridian(geometries: (Geometry | null | undefined) | (Geometry | null | undefined)[], url?: string | null, requestOptions?: RequestOptions): Promise<(Geometry | null | undefined)[]>; /** * Returns an [Extent](https://developers.arcgis.com/javascript/latest/references/core/geometry/Extent/) over the dateline that is smaller than the normalized width if it visually contains the * geometry. The input geometry must be normalized and its [Geometry.spatialReference](https://developers.arcgis.com/javascript/latest/references/core/geometry/Geometry/#spatialReference) must be Web Mercator or WGS84. * * @param geometry - The geometry used to create the denormalized extent. The geometry should be * a [Polygon](https://developers.arcgis.com/javascript/latest/references/core/geometry/Polygon/), [Polyline](https://developers.arcgis.com/javascript/latest/references/core/geometry/Polyline/), or a * [Multipoint](https://developers.arcgis.com/javascript/latest/references/core/geometry/Multipoint/) geometry. * This method returns `null` if a [Point](https://developers.arcgis.com/javascript/latest/references/core/geometry/Point/) or a [Multipoint](https://developers.arcgis.com/javascript/latest/references/core/geometry/Multipoint/) * with only one point is used as the input geometry. * It returns a cloned extent if an [Extent](https://developers.arcgis.com/javascript/latest/references/core/geometry/Extent/) is used as the input geometry. * @returns The denormalized extent. The new extent is either the same as the normal extent of the geometry * or a smaller extent. * @since 4.21 * @example * // create an extent that goes over the dateline * // as the points are cross the dateline * const multipoint = new Multipoint({ * points: [ * [158.6082458495678, 59.91028747107214], * [-145.98220825200923, 60.23981116998903] * ] * }); * const extent = normalizeUtils.getDenormalizedExtent(multipoint); */ export function getDenormalizedExtent(geometry: Polygon | Polyline | Multipoint | Extent | null | undefined): Extent | null | undefined;