UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 6.83 kB
import t from"../../../../../core/Error.js";import{isMapAligned as e}from"../alignmentUtils.js";import{WGLSymbologyType as s,WGLGeometryType as i,WGLVVFlag as a,WGLVVTarget as r}from"../enums.js";function n(t,e,s){const n=a.SIZE_FIELD_STOPS|a.SIZE_MINMAX_VALUE|a.SIZE_SCALE_STOPS|a.SIZE_UNIT_VALUE,o=(e&(r.FIELD_TARGETS_OUTLINE|r.MINMAX_TARGETS_OUTLINE|r.SCALE_TARGETS_OUTLINE|r.UNIT_TARGETS_OUTLINE))>>>4;return t===i.LINE&&s.isOutline||t===i.FILL&&_(s.symbologyType)?n&o:n&~o}const o=0,v=8,l=7,h=8,S=11,u=11,p=12,c=13,y=14,V=15,d=16,g=17,T=18,m=19,z=20,E=21,L=26,M=Object.keys(s).filter((t=>"number"==typeof s[t])).reduce(((t,e)=>({...t,[e]:s[e]})),{});function I(t){return t===s.SIMPLE||t===s.OUTLINE_FILL_SIMPLE}function _(t){return t===s.OUTLINE_FILL||t===s.OUTLINE_FILL_SIMPLE}function b(t){return I(t.symbologyType)}function O(t){return _(t.symbologyType)}function f(t,e){switch(t){case i.FILL:return w.from(e);case i.LINE:return C.from(e);case i.MARKER:return N.from(e);case i.TEXT:return P.from(e);case i.LABEL:return Z.from(e);default:throw new Error(`Unable to createMaterialKey for unknown geometryType ${t}`)}}function A(t){switch(U.load(t).geometryType){case i.MARKER:return new N(t);case i.FILL:return new w(t);case i.LINE:return new C(t);case i.TEXT:return new P(t);case i.LABEL:return new Z(t)}}class U{static load(t){const e=this.shared;return e.data=t,e}constructor(t){this._data=0,this._data=t}set data(t){this._data=t??0}get data(){return this._data}get geometryType(){return this.bits(h,S)}set geometryType(t){this.setBits(t,h,S)}get mapAligned(){return!!this.bit(z)}set mapAligned(t){this.setBit(z,t)}get sdf(){return!!this.bit(u)}set sdf(t){this.setBit(u,t??!1)}get pattern(){return!!this.bit(p)}set pattern(t){this.setBit(p,t)}get textureBinding(){return this.bits(o,v)}set textureBinding(t){this.setBits(t,o,v)}get symbologyType(){return this.bits(E,L)}set symbologyType(t){this.setBits(t,E,L)}get geometryTypeString(){switch(this.geometryType){case i.FILL:return"fill";case i.MARKER:return"marker";case i.LINE:return"line";case i.TEXT:return"text";case i.LABEL:return"label";default:throw new t(`Unable to handle unknown geometryType: ${this.geometryType}`)}}setBit(t,e){const s=1<<t;e?this._data|=s:this._data&=~s}bit(t){return(this._data&1<<t)>>t}setBits(t,e,s){for(let i=e,a=0;i<s;i++,a++)this.setBit(i,0!=(t&1<<a))}bits(t,e){let s=0;for(let i=t,a=0;i<e;i++,a++)s|=this.bit(i)<<a;return s}hasVV(){return!1}setVV(t,e){}getVariation(){return{mapAligned:this.mapAligned,pattern:this.pattern,sdf:this.sdf,symbologyType:{value:s[this.symbologyType],options:M,namespace:"SYMBOLOGY_TYPE"}}}getVariationHash(){return this._data&~(l&this.textureBinding)}}U.shared=new U(0);const F=t=>class extends t{get vvSizeMinMaxValue(){return 0!==this.bit(d)}set vvSizeMinMaxValue(t){this.setBit(d,t)}get vvSizeScaleStops(){return 0!==this.bit(g)}set vvSizeScaleStops(t){this.setBit(g,t)}get vvSizeFieldStops(){return 0!==this.bit(T)}set vvSizeFieldStops(t){this.setBit(T,t)}get vvSizeUnitValue(){return 0!==this.bit(m)}set vvSizeUnitValue(t){this.setBit(m,t)}hasVV(){return super.hasVV()||this.vvSizeMinMaxValue||this.vvSizeScaleStops||this.vvSizeFieldStops||this.vvSizeUnitValue}setVV(t,e){super.setVV(t,e);const s=n(this.geometryType,t,e)&t;this.vvSizeMinMaxValue=!!(s&a.SIZE_MINMAX_VALUE),this.vvSizeFieldStops=!!(s&a.SIZE_FIELD_STOPS),this.vvSizeUnitValue=!!(s&a.SIZE_UNIT_VALUE),this.vvSizeScaleStops=!!(s&a.SIZE_SCALE_STOPS)}},x=t=>class extends t{get vvRotation(){return 0!==this.bit(V)}set vvRotation(t){this.setBit(V,t)}hasVV(){return super.hasVV()||this.vvRotation}setVV(t,e){super.setVV(t,e),this.vvRotation=!e.isOutline&&!!(t&a.ROTATION)}},B=t=>class extends t{get vvColor(){return 0!==this.bit(c)}set vvColor(t){this.setBit(c,t)}hasVV(){return super.hasVV()||this.vvColor}setVV(t,e){super.setVV(t,e),this.vvColor=!e.isOutline&&!!(t&a.COLOR)}},R=t=>class extends t{get vvOpacity(){return 0!==this.bit(y)}set vvOpacity(t){this.setBit(y,t)}hasVV(){return super.hasVV()||this.vvOpacity}setVV(t,e){super.setVV(t,e),this.vvOpacity=!e.isOutline&&!!(t&a.OPACITY)}};class w extends(B(R(F(U)))){static load(t){const e=this.shared;return e.data=t,e}static from(t){const{symbologyType:e,vvFlags:a}=t,r=this.load(0);return r.geometryType=i.FILL,r.symbologyType=e,e!==s.DOT_DENSITY&&r.setVV(a,t),r.data}getVariation(){return{...super.getVariation(),vvColor:this.vvColor,vvOpacity:this.vvOpacity,vvSizeFieldStops:this.vvSizeFieldStops,vvSizeMinMaxValue:this.vvSizeMinMaxValue,vvSizeScaleStops:this.vvSizeScaleStops,vvSizeUnitValue:this.vvSizeUnitValue}}}w.shared=new w(0);class N extends(B(R(x(F(U))))){static load(t){const e=this.shared;return e.data=t,e}static from(t){const{symbologyType:e,vvFlags:a}=t,r=this.load(0);return r.geometryType=i.MARKER,r.symbologyType=e,e!==s.HEATMAP&&r.setVV(a,t),r.data}getVariation(){return{...super.getVariation(),vvColor:this.vvColor,vvRotation:this.vvRotation,vvOpacity:this.vvOpacity,vvSizeFieldStops:this.vvSizeFieldStops,vvSizeMinMaxValue:this.vvSizeMinMaxValue,vvSizeScaleStops:this.vvSizeScaleStops,vvSizeUnitValue:this.vvSizeUnitValue}}}N.shared=new N(0);class C extends(B(R(F(U)))){static load(t){const e=this.shared;return e.data=t,e}static from(t){const e=this.load(0);return e.geometryType=i.LINE,e.symbologyType=t.symbologyType,e.setVV(t.vvFlags,t),e.data}getVariation(){return{...super.getVariation(),vvColor:this.vvColor,vvOpacity:this.vvOpacity,vvSizeFieldStops:this.vvSizeFieldStops,vvSizeMinMaxValue:this.vvSizeMinMaxValue,vvSizeScaleStops:this.vvSizeScaleStops,vvSizeUnitValue:this.vvSizeUnitValue}}}C.shared=new C(0);class P extends(B(R(x(F(U))))){static load(t){const e=this.shared;return e.data=t,e}static from(t){const e=this.load(0);return e.geometryType=i.TEXT,e.symbologyType=t.symbologyType,e.setVV(t.vvFlags,t),e.data}getVariation(){return{...super.getVariation(),vvColor:this.vvColor,vvOpacity:this.vvOpacity,vvRotation:this.vvRotation,vvSizeFieldStops:this.vvSizeFieldStops,vvSizeMinMaxValue:this.vvSizeMinMaxValue,vvSizeScaleStops:this.vvSizeScaleStops,vvSizeUnitValue:this.vvSizeUnitValue}}}P.shared=new P(0);class Z extends(F(U)){static load(t){const e=this.shared;return e.data=t,e}static from(t){const s=this.load(0);return s.geometryType=i.LABEL,s.symbologyType=t.symbologyType,s.setVV(t.vvFlags,t),s.mapAligned=e(t.placement),s.data}getVariation(){return{...super.getVariation(),vvSizeFieldStops:this.vvSizeFieldStops,vvSizeMinMaxValue:this.vvSizeMinMaxValue,vvSizeScaleStops:this.vvSizeScaleStops,vvSizeUnitValue:this.vvSizeUnitValue}}}Z.shared=new Z(0);export{w as FillMaterialKey,Z as LabelMaterialKey,C as LineMaterialKey,N as MarkerMaterialKey,U as MaterialKeyBase,P as TextMaterialKey,f as createMaterialKey,O as hasOutlineFillSymbology,b as hasSimpleSymbology,A as hydrateMaterialKey,_ as isOutlineFillSymbology,I as isSimpleSymbology};