@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 1.7 kB
JavaScript
import"../../../geometry.js";import{isNone as t}from"../../../core/maybe.js";import{isExtent as e,isPolygon as s,isPolyline as i}from"../../../geometry/support/jsonUtils.js";import{clipPolygonToTileExtent as n,clipPolylineToTileExtent as o}from"../CIMEffects.js";import{CurveHelper as r,PIXEL_TOLERANCE as f}from"../CurveHelper.js";import{GeometricEffectOffsetMethod as m}from"../enums.js";import h from"../../../geometry/SpatialReference.js";class a{static local(){return null===a.instance&&(a.instance=new a),a.instance}execute(t,e,s,i,n){return new l(t,e,s,i,n)}}a.instance=null;class l{constructor(t,e,s,i,n){this._inputGeometries=t,this._tileKey=i,this._geometryEngine=n,this._curveHelper=new r,this._offset=(e.offset??1)*s,this._method=e.method,this._option=e.option,this._offsetFlattenError=f*s}next(){let r;for(;r=this._inputGeometries.next();){if(0===this._offset)return r;if(e(r)){if(this._method===m.Rounded&&this._offset>0){const t=[[r.xmin,r.ymin],[r.xmin,r.ymax],[r.xmax,r.ymax],[r.xmax,r.ymin],[r.xmin,r.ymin]],e=this._curveHelper.offset(t,-this._offset,this._method,4,this._offsetFlattenError);return e?{rings:[e]}:null}if(Math.min(r.xmax-r.xmin,r.ymax-r.ymin)+2*this._offset>0)return{xmin:r.xmin-this._offset,xmax:r.xmax+this._offset,ymin:r.ymin-this._offset,ymax:r.ymax+this._offset}}const f=this._geometryEngine;if(t(f))return null;let a=r;if(s(r)){if(this._tileKey&&(a=n(r,Math.abs(this._offset)+1),!a||!a.rings||0===a.rings.length))continue}else if(i(r)&&this._tileKey&&(a=o(r,Math.abs(this._offset)+1),!a||!a.paths||0===a.paths.length))continue;return f.offset(h.WebMercator,a,-this._offset,1,this._method,4,this._offsetFlattenError)}return null}}export{a as EffectOffset};