@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 3.37 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 n from"../core/Error.js";import{i as e,b as t,P as r,a as o,l as i,c as l,d as u,e as a,f as s}from"../chunks/pe.js";import c from"./Point.js";import d from"./SpatialReference.js";import{parseNumber as f}from"../intl/number.js";function _(){return e()}function S(){return s()}function E(){return i()}function w(n,e){const r=k(e),o=n.replaceAll(/[\u00B0\u00BA]/g,"^").replaceAll("′","'").replaceAll("″",'"'),i=[];return t.dmsToGeog(r,1,[o],i)?new c(i[0][0],i[0][1],e||d.WGS84):null}function g(n){return n&&_()?f(n)??w(`0° 0' 0" N | ${n}`)?.longitude??w(`0 N | ${n}`)?.longitude??null:null}function m(n){return n&&_()?f(n)??w(`${n} | 0° 0' 0" E`)?.latitude??w(`${n} | 0 E`)?.latitude??null:null}function T(n,e,t){const r=[],o=A(t);if(-1===o)return console.warn(`invalid conversionMode: ${t}`),null;const i=k(e);return a.mgrsToGeogExtended(i,1,[n],o,r)?new c(r[0][0],r[0][1],e||d.WGS84):null}function P(n,e){const t=[];!e&&/\(.+27/.test(n)&&(e=d.GCS_NAD_1927);const r=k(e);return l.usngToGeog(r,1,[n],t)?new c(t[0][0],t[0][1],e||d.WGS84):null}function G(n,e,t){const r=[],o=D(t);if(-1===o)return console.warn(`invalid conversionMode: ${t}`),null;const i=k(e);return u.utmToGeog(i,1,[n],o,r)?new c(r[0][0],r[0][1],e||d.WGS84):null}function p(n,e,r=0){const o=[[n.x,n.y]],i=[],l=k(n.spatialReference);let u=0;switch(e){case"dd":u=t.geogToDd(l,1,o,r,i);break;case"ddm":u=t.geogToDdm(l,1,o,r,i);break;case"dms":u=t.geogToDms(l,1,o,r,i);break;default:return console.warn(`invalid format: ${e}`),null}return u?i[0]:null}function M(n,e,t=0,r=!1){const o=[[n.x,n.y]],i=[],l=k(n.spatialReference);let u=A(e);if(-1===u)return console.warn(`invalid conversionMode: ${e}`),null;r&&(u|=a.PE_MGRS_ADD_SPACES);return a.geogToMgrsExtended(l,1,o,t,!1,u,i)?i[0]:null}function v(n,e=0,t=!1){const r=[[n.x,n.y]],o=[],i=k(n.spatialReference);return l.geogToUsng(i,1,r,e,!1,t,o)?o[0]:null}function R(n,e,t=!1){const r=[[n.x,n.y]],o=[],i=k(n.spatialReference);let l=D(e);if(-1===l)return console.warn(`invalid conversionMode: ${e}`),null;t&&(l|=u.PE_UTM_OPTS_ADD_SPACES);return u.geogToUtm(i,1,r,l,o)?o[0]:null}function k(e){if(e??=d.WGS84,e.wkid){const t=r.geogcs(e.wkid);if(!t)throw new n("coordinate-formatter:invalid-spatial-reference","wkid is not valid");return t}const t=e.wkt2??e.wkt;if(t){const e=r.fromString(o.PE_TYPE_GEOGCS,t);if(!e)throw new n("coordinate-formatter:invalid-spatial-reference","wkt is not valid");return e}throw new n("coordinate-formatter:invalid-spatial-reference","wkid and wkt are missing")}function A(n){switch(n){case"automatic":return a.PE_MGRS_STYLE_AUTO;case"new-180-in-zone-01":return a.PE_MGRS_STYLE_NEW|a.PE_MGRS_180_ZONE_1_PLUS;case"new-180-in-zone-60":return a.PE_MGRS_STYLE_NEW;case"old-180-in-zone-01":return a.PE_MGRS_STYLE_OLD|a.PE_MGRS_180_ZONE_1_PLUS;case"old-180-in-zone-60":return a.PE_MGRS_STYLE_OLD;default:return-1}}function D(n){switch(n){case"latitude-band-indicators":return u.PE_UTM_OPTS_NONE;case"north-south-indicators":return u.PE_UTM_OPTS_NS;default:return-1}}export{m as fromLatitude,w as fromLatitudeLongitude,g as fromLongitude,T as fromMgrs,P as fromUsng,G as fromUtm,_ as isLoaded,S as isSupported,E as load,p as toLatitudeLongitude,M as toMgrs,v as toUsng,R as toUtm};