UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 1.77 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import{JSONMap as t}from"../../core/jsonMap.js";import{JSONSupport as s}from"../../core/JSONSupport.js";import{property as r,subclass as o}from"../../core/accessorSupport/decorators.js";import i from"../../geometry/Polygon.js";import{srToRESTValue as n}from"../../geometry/support/spatialReferenceUtils.js";const a=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 s{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 s=this.polygons[0].spatialReference;e.sr=n(s)}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=a.toJSON(this.calculationType)),e}};e([r({type:String,json:{write:!0}})],c.prototype,"areaUnit",void 0),e([r({type:String,json:{write:!0}})],c.prototype,"calculationType",void 0),e([r({type:String,json:{write:!0}})],c.prototype,"lengthUnit",void 0),e([r({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};