UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.01 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as e}from"../../chunks/tslib.es6.js";import{JSONMap as t}from"../../core/jsonMap.js";import r from"../../core/JSONSupport.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import i from"../../geometry/Polygon.js";import{srToRESTValue as a}from"../../geometry/support/spatialReferenceUtils.js";const n=new t({preserveShape:"preserve-shape",planar:"planar",geodesic:"geodesic"}),p=new t({esriAcres:"acres",esriHectares:"hectares",esriSquareMiles:"square-miles",esriSquareKilometers:"square-kilometers",esriSquareMeters:"square-meters",esriSquareFeet:"square-feet",esriSquareYards:"square-yards",esriAres:"ares"}),l=new t({9001:"meters",9002:"feet",9036:"kilometers",9093:"miles",109012:"nautical-miles",109001:"yards"});let c=class extends r{constructor(e){super(e),this.areaUnit=null,this.calculationType=null,this.lengthUnit=null,this.polygons=null}toJSON(){const e={};if(this.polygons&&this.polygons.length>0){const t=this.polygons.map((e=>e.toJSON()));e.polygons=JSON.stringify(t);const r=this.polygons[0].spatialReference;e.sr=a(r)}if(this.lengthUnit&&(e.lengthUnit=l.toJSON(this.lengthUnit)),this.areaUnit){const t=p.toJSON(this.areaUnit);e.areaUnit="string"==typeof t?JSON.stringify({areaUnit:t}):t}return this.calculationType&&(e.calculationType=n.toJSON(this.calculationType)),e}};e([s({type:String,json:{write:!0}})],c.prototype,"areaUnit",void 0),e([s({type:String,json:{write:!0}})],c.prototype,"calculationType",void 0),e([s({type:String,json:{write:!0}})],c.prototype,"lengthUnit",void 0),e([s({type:[i],json:{write:!0}})],c.prototype,"polygons",void 0),c=e([o("esri.rest.support.AreasAndLengthsParameters")],c);const u=c;export{u as default};