@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 3.54 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"../Dictionary.js";import{StringEnum as n}from"../enum.js";import{ArcadeExecutionError as t,ExecutionErrorCodes as r}from"../executionError.js";import{B as o,w as i,J as l,C as a,j as s,F as f,K as c}from"../../chunks/languageUtils.js";import{getMetersPerVerticalUnitForSR as u,segmentLength3d as m}from"../functions/centroid.js";import{measureToCoordinate as p,pointToCoordinate as d,distanceToCoordinate as w}from"../functions/measures.js";import{getMetersPerUnitForSR as g}from"../../core/unitUtils.js";import y from"../../geometry/Geometry.js";import h from"../../geometry/Point.js";import v from"../../geometry/Polyline.js";import{isArray as j,isNumber as P}from"../../support/guards.js";function x(e,n,i){if(o(e,2,2,n,i),e[0]instanceof y&&e[1]instanceof y);else if(e[0]instanceof y&&null===e[1]);else if(e[1]instanceof y&&null===e[0]);else if(null!==e[0]||null!==e[1])throw new t(n,r.InvalidParameter,i)}function I(e){if("polygon"!==e.type&&"polyline"!==e.type&&"extent"!==e.type)return 0;let n=1;if(e.spatialReference.vcsWkid||e.spatialReference.latestVcsWkid){n=u(e.spatialReference)/g(e.spatialReference)}let t=0;if("polyline"===e.type)for(const r of e.paths)for(let e=1;e<r.length;e++)t+=m(r[e],r[e-1],n);else if("polygon"===e.type)for(const r of e.rings){for(let e=1;e<r.length;e++)t+=m(r[e],r[e-1],n);(r[0][0]!==r[r.length-1][0]||r[0][1]!==r[r.length-1][1]||void 0!==r[0][2]&&r[0][2]!==r[r.length-1][2])&&(t+=m(r[0],r[r.length-1],n))}else"extent"===e.type&&(t+=2*m([e.xmin,e.ymin,0],[e.xmax,e.ymin,0],n),t+=2*m([e.xmin,e.ymin,0],[e.xmin,e.ymax,0],n),t*=2,t+=4*Math.abs(l(e.zmax,0)*n-l(e.zmin,0)*n));return t}const R=(n,i,l)=>{if(l=a(l),o(l,2,2,n,i),null===l[0])return null;let u=l[0];if((j(l[0])||s(l[0]))&&(u=f(l[0],n.spatialReference)),null===u)return null;if(!(u instanceof y))throw new t(n,r.InvalidParameter,i);if(!(u instanceof v))throw new t(n,r.InvalidParameter,i);if(!P(l[1]))throw new t(n,r.InvalidParameter,i);const m=p(u,l[1]);return m?e.convertObjectToArcadeDictionary(m,c(n),!1,!0):null},b=(n,i,l)=>{if(l=a(l),o(l,2,2,n,i),null===l[0])return null;let u=l[0];if((j(l[0])||s(l[0]))&&(u=f(l[0],n.spatialReference)),null===u)return null;if(!(u instanceof y))throw new t(n,r.InvalidParameter,i);if(!(u instanceof v))throw new t(n,r.InvalidParameter,i);const m=l[1];if(null===m)return null;if(!(m instanceof h))throw new t(n,r.InvalidParameter,i);const p=d(u,m);return p?e.convertObjectToArcadeDictionary(p,c(n),!1,!0):null},k=(n,i,l)=>{if(l=a(l),o(l,2,2,n,i),null===l[0])return null;let u=l[0];if((j(l[0])||s(l[0]))&&(u=f(l[0],n.spatialReference)),null===u)return null;if(!(u instanceof y))throw new t(n,r.InvalidParameter,i);if(!(u instanceof v))throw new t(n,r.InvalidParameter,i);if(!P(l[1]))throw new t(n,r.InvalidParameter,i);const m=w(u,l[1]);return m?e.convertObjectToArcadeDictionary(m,c(n),!1,!0):null},D=new n(["geodesic","great-elliptic","loxodrome","normal-section","shape-preserving"]);function A(e){return null==e?"geodesic":D.get(i(e))}const O=new n(["geometric","labelPoint"]);function T(e){return null==e?"geometric":O.get(i(e))}const z=new n(["round","bevel","miter","square"]);function U(e){return null==e?"round":z.lookup(i(e))??"round"}export{x as commonRelationsCheck,k as distanceToCoordinateFunc,R as measureToCoordinateFunc,I as planarLength3D,b as pointToCoordinateFunc,T as toCentroidAlgorithm,A as toCurveType,U as toOffsetJoinType};