/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{clamp as t}from"../../../core/mathUtils.js";import{getMetersPerUnitForSR as n}from"../../../core/units.js";import r from"../../../geometry/Point.js";import e from"../../../geometry/SpatialReference.js";function i(t,n){return[t[0].toFixed(n),t[1].toFixed(n)]}const o=new Map;function u(r,e,i,u=4){if(null==r||!e)return u;if(o.has(r)){const t=o.get(r);if(void 0!==t[i])return t[i]}const s=n(e);if(!Number.isFinite(s)||s<=0)return u;const c=r*s/111320,f="dd"===i?c:"ddm"===i?60*c:3600*c,m=t(Math.ceil(-Math.log10(f)),0,7);return o.has(r)||(o.clear(),o.set(r,{})),o.get(r)[i]=m,m}function s(t){return t>=500?6:t<500&&t>=50?7:t<50&&t>=5?8:9}function c(t,n){const i=t.includes(",")?",":" ",[o,u,s]=t.split(i).map(t=>{const n=t.trim();return n?Number(n):null});if(!f(o)||!f(u))return null;const c=new r({x:o,y:u,spatialReference:n||e.WGS84});return s&&(c.z=s,c.hasZ=!0),c}function f(t){return"number"==typeof t&&isFinite(t)}function m(t){return!!t&&f(t.x)&&f(t.y)}function l(t,n){const[r,e]=i([t.x,t.y],n);return`${r}, ${e}`}const d=["dd","dms","ddm","mgrs","usng","utm"];function a(t){return d.includes(t)}function p(t){return t?t.replaceAll(/(?<![\d.])0+(?=\d)/g,""):t}export{c as fromXY,s as getDegreePrecision,u as getGeometryPrecision,a as isSupportedNotation,m as isValidPoint,l as pointToCoordinate,p as removeLeadingZeros};
