@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 3.41 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{Cyclical as t}from"../../../../core/Cyclical.js";import{toUnit as n,createAngle as e,createScalar as r}from"../../../../core/quantity.js";import{formatRelativeVerticalLength as i,formatVerticalLength as o,formatLength as u,formatRelativeLength as l,formatArea as a,formatAngle as c}from"../../../../core/quantityFormatUtils.js";import{fromLongitude as s,fromLatitude as f,isLoaded as g,fromLatitudeLongitude as m}from"../../../../geometry/coordinateFormatter.js";import{formatNumber as p,parseNumber as d}from"../../../../intl/number.js";import{getDegreesGeographic as h}from"../../../support/angularMeasurementUtils.js";const v=1,y=6;function D(t,n){return{angleRelative:x,direction:j,directionRelative:R,directionRelativeBilateral:$,latitudeDecimalDegrees:L,longitudeDecimalDegrees:F,area:(e,r)=>a(t,e,r??n.area),length:(e,r,i)=>u(t,e,r??n.length,i),lengthRelative:(e,r)=>l(t,e,r??n.length),totalLength:(e,r)=>u(t,e,r??n.length),verticalLength:(e,r)=>o(t,e,r??n.verticalLength),verticalLengthRelative:(e,r)=>i(t,e,r??n.verticalLength),percentage:T,scalar:Z,scale:U}}function x(t){return p(t,{signDisplay:"exceptZero",...b(v)})}function j(t){return c(t,t.rotationType,v)}function R(t){const n=h(t);return p(n,{style:"unit",unitDisplay:"narrow",unit:"degree",signDisplay:n>0?"never":"exceptZero",...b(v)})}function $(t){return c(t,t.rotationType,v)}function F(t){return q(t,N)}function L(t){return q(t,O)}function w(t){return z(t,N)}function A(t){return z(t,O)}function q(t,e){const r=!1,i="geographic";return c(n(t,"degrees"),i,y,e,r)}function z(t,e){const i=!1,o=e.normalize(n(t,"degrees").value,void 0,i);return Z(r(o),y)}function T(t){return p(t.value,{style:"percent"})}function U(t){return p(t,{style:"percent",maximumFractionDigits:0})}function Z(t,n){return p(t.value,b(n))}function b(t){return{minimumFractionDigits:t,maximumFractionDigits:t}}function B({createQuantity:t,sanitize:n}){return(e,r)=>{if(null==e)return null;n&&(e=n(e));const i=d(e);return null==i?null:t(i,r)}}function C(t){return t.replaceAll(/[*^~°º]/g,"")}const E=t=>{let n=`[-+]?[0-9${t.thousands}]+`;return""!==t.decimal&&(n+=`${t.decimal}[0-9]+`),new RegExp(`^(${n}\\s*)${t.separator}(\\s*${n})$`,"i")},I=" ",M=[];for(const P of[",","\\|","\\s+"])for(const t of["\\.",",",""])for(const n of["",",","\\.",I,"\\s+"])P!==t&&P!==n&&t!==n&&M.push({separator:P,decimal:t,thousands:n,pattern:E({decimal:t,thousands:n,separator:P})});function Q(t){for(const{decimal:n,thousands:e,pattern:i}of M){i.lastIndex=0;const o=t.match(i);if(!o)continue;const u=d(k(o[1],n,e)),l=d(k(o[2],n,e));if(null!=u&&null!=l)return{x:r(u),y:r(l)}}return null}function k(t,n,e){let r=t.replaceAll(/[\s+]/g,"");return""!==e&&(r=r.replaceAll(e,"")),""!==n&&(r=r.replaceAll(n,".")),r}function G(t){if(!t||null!=d(t)||!g())return null;const n=m(t),e=K(n?.latitude),r=K(n?.longitude);return null!=r&&null!=e?{latitude:e,longitude:r}:null}function H(t){return K(s(t))}function J(t){return K(f(t))}function K(t){return null!=t?e(t,"degrees","geographic"):null}const N=new t(-180,180),O=new t(-90,90);export{k as cleanNumber,K as createGeographicCoordinate,A as formatLatitudeDecimalDegreesForInputMode,w as formatLongitudeDecimalDegreesForInputMode,D as getFormatters,B as makeQuantityParser,J as parseLatitude,G as parseLatitudeLongitude,H as parseLongitude,Q as parseXY,C as sanitizeAngle};