@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.94 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{GeometryCursor as t}from"../../../geometry/GeometryCursor.js";import{collectPath as e}from"../../../geometry/geometryCursorCollectUtils.js";import s from"../../../geometry/SpatialReference.js";import{isExtent as o}from"../../../geometry/support/jsonUtils.js";import{clipCursorToTileExtent as i}from"../CIMEffects.js";import{CurveHelper as r,pixelTolerance as n}from"../CurveHelper.js";import{GeometricEffectOffsetMethod as f}from"../enums.js";const m=10;class h{static local(){return null===h.instance&&(h.instance=new h),h.instance}execute(t,e,s,o,i,r,n){return new l(t,e,s,o,i,r,n)}}h.instance=null;class l{constructor(t,e,s,o,i,f,h){this._preventClipping=h,this._inputGeometries=t,this._tileKey=o,this._geometryEngine=i,this._curveHelper=new r,this._offset=(e.offset??1)*s,this._method=e.method,this._maxInflateSize=Math.max(Math.abs(f*s),m),this._option=e.option,this._offsetFlattenError=n*s}next(){let r;for(;r=this._inputGeometries.next();){if(0===this._offset)return r.clone();if("esriGeometryEnvelope"===r.geometryType){if(this._method===f.Rounded&&this._offset>0){const s=e(r),o=this._curveHelper.offset(s,-this._offset,this._method,4,this._offsetFlattenError);if(o){const e=t.createEmptyOptimizedCIM(r.geometryType);return e.pushPath(o),e}return null}const s=r.asJSON();if(o(s)&&Math.min(s.xmax-s.xmin,s.ymax-s.ymin)+2*this._offset>0)return t.fromJSONCIM({xmin:s.xmin-this._offset,xmax:s.xmax+this._offset,ymin:s.ymin-this._offset,ymax:s.ymax+this._offset})}const n=this._geometryEngine;if(null==n)continue;const m=!this._preventClipping&&this._tileKey?i(r,this._maxInflateSize):r.clone();if(!m)continue;const h=n.offset(s.WebMercator,m.asJSON(),-this._offset,1,this._method,4,this._offsetFlattenError);return h?t.fromJSONCIM(h):null}return null}}export{h as EffectOffset};