UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 1.7 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{GeometryCursor as e}from"../../../geometry/GeometryCursor.js";import t from"../../../geometry/SpatialReference.js";import{getCursorBoundsXY as n}from"../../../geometry/support/boundsUtils.js";import{GeometricEffectEnclosingPolygonMethod as r}from"../enums.js";class o{static{this.instance=null}static local(){return null===o.instance&&(o.instance=new o),o.instance}execute(e,t,n,r,o){return new s(e,t,n,o)}}class s{constructor(e,t,n,r){this._inputGeometries=e,this._medhod=t.method,this._geometryEngine=r}next(){let e=this._inputGeometries.next();const t=this._medhod;for(;null!=e;){if(e.totalSize>0)switch(t){case r.RectangularBox:return i(e);case r.ConvexHull:return this._constructConvexHull(e);default:return u(e)}e=this._inputGeometries.next()}return null}_constructConvexHull(n){switch(n.geometryType){case"esriGeometryPolyline":case"esriGeometryPolygon":{const r=this._geometryEngine;if(null==r)return null;const o=r.convexHull(t.WebMercator,n.asJSON());return o?e.fromJSONCIM(o):null}case"esriGeometryEnvelope":return n;default:return null}}}function i(t){const r=n(t),o={xmin:r[0],ymin:r[1],xmax:r[2],ymax:r[3]};return e.fromJSONCIM(o)}function u(t){switch(t.geometryType){case"esriGeometryPolyline":{const n=[];for(;t.nextPath();)l(t,n);return e.fromJSONCIM({rings:n})}case"esriGeometryPolygon":case"esriGeometryEnvelope":return t;default:return null}}function l(e,t){if(e.seekPathStart(),!e.nextPoint())return;const n=e.x,r=e.y,o=[[n,r]];for(t.push(o);e.nextPoint();)o.push([e.x,e.y]);o.push([n,r])}export{o as EffectEnclosingPolygon};