UNPKG

@doegis/core

Version:

DOE GIS API

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