@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.95 kB
JavaScript
/*
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 t}from"../../../geometry/GeometryCursor.js";import{collectPath as e}from"../../../geometry/geometryCursorCollectUtils.js";import s from"../../../geometry/SpatialReference.js";import{isExtent as i}from"../../../geometry/support/jsonUtils.js";import{clipCursorToTileExtent as o}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{this.instance=null}static local(){return null===h.instance&&(h.instance=new h),h.instance}execute(t,e,s,i,o,r,n){return new l(t,e,s,i,o,r,n)}}class l{constructor(t,e,s,i,o,f,h){this._preventClipping=h,this._inputGeometries=t,this._tileKey=i,this._geometryEngine=o,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),i=this._curveHelper.offset(s,-this._offset,this._method,4,this._offsetFlattenError);if(i){const e=t.createEmptyOptimizedCIM(r.geometryType);return e.pushPath(i),e}return null}const s=r.asJSON();if(i(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?o(r,this._maxInflateSize,!0):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};