@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 3.18 kB
JavaScript
import{isNone as e}from"../../../../../../core/maybe.js";import{THIN_LINE_HALF_WIDTH_THRESHOLD as t}from"../../definitions.js";import{WGLGeometryType as i}from"../../enums.js";import{i1616to32 as r,i8888to32 as s}from"../../number.js";import{LineTessellation as o}from"../../TurboLine.js";import{LineMaterialKey as n,FillMaterialKey as l,hasOutlineFillSymbology as a,hasSimpleSymbology as h}from"../../materialKey/MaterialKey.js";import{clipLinesMarshall as d}from"./templateUtils.js";const m=8,x=16,p=65535,f=r=>class extends r{constructor(...e){super(...e),this.tessellationProperties={},this._tessellationOptions={halfWidth:0,pixelCoordRatio:1,offset:0},this.geometryType=i.LINE}writeGeometry(e,t,i,r){this._writeGeometry(e,t,i,r)}_initializeTessellator(e){const i=n.load(this._materialKey),r=l.load(this._materialKey),s=this._tessellationOptions,h=i.vvSizeFieldStops||i.vvSizeMinMaxValue||i.vvSizeScaleStops||i.vvSizeUnitValue,d=this.tessellationProperties._halfWidth<t&&!e&&!h;this.tessellationProperties.minMaxZoom=this._minMaxZoom,s.wrapDistance=p,s.textured=this._isDashed||this._hasPattern,s.offset=this.tessellationProperties.offset,s.halfWidth=this.tessellationProperties._halfWidth;const m=d?0:1,x=a(r)?v:_;this._lineTessellator=new o(x(this.tessellationProperties,m,m),u(this.tessellationProperties),d)}_write(e,t,i,r){const s="esriGeometryPoint"===t.geometryType;e.recordStart(t.getDisplayId(),this._materialKey,this.geometryType,s),this._writeGeometry(e,t,r,s),e.recordEnd()}_writeGeometry(t,i,r,s){const o=r??i.readLegacyGeometryForDisplay(),n=this._getLines(o,s);e(n)||this._writeVertices(t,i,n)}_getLines(t,i){if(e(t))return null;const r=t.paths||t.rings;if(e(r))return null;return d(r,i?256:16)}_writeVertices(e,t,i){const r=t.getDisplayId(),s=e.vertexCount(),o=this.tessellationProperties,h=this._tessellationOptions;o.out=e,o.id=r,o.indexCount=0,o.vertexCount=0,o.offset=s,h.capType=this._capType,h.joinType=this._joinType;const d=l.load(this._materialKey);this.tessellationProperties.key=a(d)?d:n.load(this._materialKey);for(const{line:n,start:l}of i)h.initialDistance=l%p,this._lineTessellator.tessellate(n,h)}},_=(e,t,i)=>(o,n,l,a,h,d,p,f,_,v,u)=>{const c=r(u,Math.ceil(x*e._halfWidth)),y=s(Math.round(x*p),Math.round(x*f),Math.round(x*_),Math.round(x*v)),W=s(x*h,x*d,0,e._bitset),M=e.out;return M.vertexBounds(o,n,t,i),M.vertexWrite(r(m*o,m*n)),M.vertexWrite(e.id),M.vertexWrite(e._fillColor),M.vertexWrite(y),M.vertexWrite(c),M.vertexWrite(e._tl),M.vertexWrite(e._br),M.vertexWrite(W),M.vertexWrite(r(Math.ceil(x*e._halfReferenceWidth),0)),M.vertexWrite(e.minMaxZoom),M.vertexEnd(),e.offset+e.vertexCount++},v=(e,t,i)=>(o,n,l,a,d,p,f,_,v,u,c)=>{const y=r(x*e._halfWidth,x*e._halfReferenceWidth),W=s(x*f+128,x*_+128,x*v+128,x*u+128),M=e.out,P=e._bitset<<24|e.id;M.vertexBounds(o,n,t,i),M.vertexWrite(r(m*o,m*n)),M.vertexWrite(P),M.vertexWrite(e._fillColor);const T=h(e.key);return T||(M.vertexWrite(0),M.vertexWrite(0)),M.vertexWrite(0),M.vertexWrite(y),M.vertexWrite(W),T||M.vertexWrite(e.minMaxZoom),M.vertexEnd(),e.offset+e.vertexCount++},u=e=>(t,i,r)=>{const s=e.out;s.indexWrite(t),s.indexWrite(i),s.indexWrite(r),e.indexCount+=3};export{f as default};