UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 2.71 kB
import{isSome as t}from"../../../../../../core/maybe.js";import{pt2px as e}from"../../../../../../core/screenUtils.js";import{premultiplyAlphaRGBA as i}from"../../color.js";import{BITSET_GENERIC_LOCK_COLOR as s,BITSET_LINE_SCALE_DASH as r,BITSET_GENERIC_CONSIDER_ALPHA_ONLY as o,SPRITE_PADDING as a,MIN_MAX_ZOOM_PRECISION_FACTOR as l}from"../../definitions.js";import{i1616to32 as h}from"../../number.js";import{LineMaterialKey as n}from"../../materialKey/MaterialKey.js";import{isFunction as c,getLimitCosine as m,getMinMaxZoom as p}from"./util.js";import _ from"./WGLBaseLineTemplate.js";import f from"./WGLDynamicMeshTemplate.js";import{ok as d}from"../../util/Result.js";class y extends(_(f)){constructor(a,n,p){super(a),this._minMaxZoom=h(Math.round(n*l),Math.round(p*l)),this._cimLineLayer=a;let _=0;c(a.width)||(_=.5*e(a.width));const f=(t,i,s)=>c(a.width)?.5*e(a.width(t,i,s)):_;this._dynamicPropertyMap.set("_halfWidth",f),c(a.cap)?this._dynamicPropertyMap.set("_capType",a.cap):this._capType=a.cap,c(a.join)?this._dynamicPropertyMap.set("_joinType",a.join):this._joinType=a.join;const d=a.color;if(c(d)){const t=(t,e,s)=>i(d(t,e,s));this._dynamicPropertyMap.set("_fillColor",t)}else this._fillColor=d&&i(d)||0;const y=a.miterLimit;if(c(y)){const t=(t,e,i)=>m(y(t,e,i));this._dynamicPropertyMap.set("_miterLimitCosine",t)}else this._miterLimitCosine=m(y);if(t(a.effects)){const t=a.effects;c(t)?this._dynamicPropertyMap.set("_effects",t):this._effects=t}this._scaleFactor=a.scaleFactor||1,this._isDashed=null!=a.dashTemplate;const P=a.colorLocked?s:0,u=a.scaleDash?r:0,j=a.sampleAlphaOnly?o:0;this.tessellationProperties._bitset=P|u|j,this._materialKey=a.materialKey,this._initializeTessellator(!0)}static fromCIMLine(t,e){const[i,s]=p(t.scaleInfo,e);return new y(t,i,s)}bindFeature(t,e,i){const s=t.readLegacyFeature();this._dynamicPropertyMap.forEach(((t,r)=>{this[r]=t(s,e,i)})),this._halfWidth*=this._scaleFactor;const r=this._materialCache,o=(0,this._cimLineLayer.materialHash)(s,e,i),l=r.get(o);let c=null;if(l&&d(l.spriteMosaicItem)&&(c=l.spriteMosaicItem),c){this._hasPattern=!0;const{rect:t,width:e,height:i}=c,s=t.x+a,r=t.y+a,o=s+e,l=r+i;this.tessellationProperties._tl=h(s,r),this.tessellationProperties._br=h(o,l)}else this._hasPattern=!1,this.tessellationProperties._tl=0,this.tessellationProperties._br=0;this.tessellationProperties._fillColor=this._fillColor,this.tessellationProperties._halfWidth=this._halfWidth,this.tessellationProperties.offset=0,this.tessellationProperties._halfReferenceWidth=this.tessellationProperties._halfWidth;const m=n.load(this._materialKey);c&&(m.sdf=c.sdf,m.pattern=!0,m.textureBinding=c.textureBinding),this._materialKey=m.data}}export{y as default};