UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 3.5 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{Cyclical as t}from"../../../../core/Cyclical.js";import{formatRelativeVerticalLength as n,formatVerticalLength as e,formatLength as r,formatRelativeLength as i,formatArea as o,formatAngle as l}from"../../../../core/quantityFormatUtils.js";import{createAngle as u,toUnit as a,createScalar as c}from"../../../../core/quantityUtils.js";import{fromLongitude as s,fromLatitude as f,isLoaded as g,fromLatitudeLongitude as m}from"../../../../geometry/coordinateFormatter.js";import{parseNumber as p,formatNumber as d}from"../../../../intl/number.js";import{getDegreesGeographic as h}from"../../../support/angularMeasurementUtils.js";const v=1,y=6;function D(t,l){return{angleRelative:x,direction:j,directionRelative:R,directionRelativeBilateral:$,latitudeDecimalDegrees:L,longitudeDecimalDegrees:F,area:(n,e)=>o(t,n,e??l.area),length:(n,e,i)=>r(t,n,e??l.length,i),lengthRelative:(n,e)=>i(t,n,e??l.length),totalLength:(n,e)=>r(t,n,e??l.length),verticalLength:(n,r)=>e(t,n,r??l.verticalLength),verticalLengthRelative:(e,r)=>n(t,e,r??l.verticalLength),percentage:z,scalar:Z,scale:T}}function x(t){return d(t,{signDisplay:"exceptZero",...b(v)})}function j(t){return l(t,t.rotationType,v)}function R(t){const n=h(t);return d(n,{style:"unit",unitDisplay:"narrow",unit:"degree",signDisplay:n>0?"never":"exceptZero",...b(v)})}function $(t){return l(t,t.rotationType,v)}function F(t){return U(t,N)}function L(t){return U(t,O)}function w(t){return q(t,N)}function A(t){return q(t,O)}function U(t,n){const e=!1,r="geographic";return l(a(t,"degrees"),r,y,n,e)}function q(t,n){const e=!1,r=n.normalize(a(t,"degrees").value,void 0,e);return Z(c(r),y)}function z(t){return d(t.value,{style:"percent"})}function T(t){return d(t,{style:"percent",maximumFractionDigits:0})}function Z(t,n){return d(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=p(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:r}of M){r.lastIndex=0;const i=t.match(r);if(!i)continue;const o=p(k(i[1],n,e)),l=p(k(i[2],n,e));if(null!=o&&null!=l)return{x:c(o),y:c(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!=p(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?u(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};