@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.11 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import e from"../../config.js";import r from"../../core/Error.js";import o from"../Portal.js";import{project as t}from"../../rest/geometryService/project.js";import i from"../../rest/support/ProjectParameters.js";async function n(t=null,i){if(e.geometryServiceUrl)return e.geometryServiceUrl;if(!t)throw new r("internal:geometry-service-url-not-configured","No geometryServiceUrl in configuration");let n;n="portal"in t?t.portal||o.getDefault():t,await n.load({signal:i});const a=n.helperServices?.geometry?.url;if(!a)throw new r("internal:geometry-service-url-not-configured","No geometryServiceUrl in configuration");return a}async function a(e,o,a=null,c){const l=await n(a,c),m=new i({geometries:[e],outSpatialReference:o}),s=await t(l,m,{signal:c});if(s&&Array.isArray(s)&&1===s.length)return s[0];throw new r("internal:geometry-service-projection-failed","Geometry projection failed on service")}export{n as getGeometryServiceURL,a as projectGeometry};