@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 2.47 kB
JavaScript
import{BucketType as t}from"../enums.js";import{VTLSymbol as e}from"./core.js";function s(t,e,s,o,l,i){const r=s-l;if(r>=0)return(e>>r)+(o-(i<<r))*(t>>r);const n=-r;return e-(i-(o<<n))*(t>>n)<<n}class o{constructor(t,e,s){this._rows=Math.ceil(e/s),this._columns=Math.ceil(t/s),this._cellSize=s,this.cells=new Array(this._rows);for(let o=0;o<this._rows;o++){this.cells[o]=new Array(this._columns);for(let t=0;t<this._columns;t++)this.cells[o][t]=[]}}getCell(t,e){const s=Math.min(Math.max(Math.floor(e/this._cellSize),0),this._rows-1),o=Math.min(Math.max(Math.floor(t/this._cellSize),0),this._columns-1);return this.cells[s]&&this.cells[s][o]||null}getCellSpan(t,e,s,o){return[Math.min(Math.max(Math.floor(t/this._cellSize),0),this.columns-1),Math.min(Math.max(Math.floor(e/this._cellSize),0),this.rows-1),Math.min(Math.max(Math.floor(s/this._cellSize),0),this.columns-1),Math.min(Math.max(Math.floor(o/this._cellSize),0),this.rows-1)]}get cellSize(){return this._cellSize}get columns(){return this._columns}get rows(){return this._rows}}function l(t,s,o,l,i,r){const n=s[l++];for(let a=0;a<n;a++){const n=new e(r);n.xTile=s[l++],n.yTile=s[l++],n.hash=s[l++],n.priority=s[l++];const a=s[l++];for(let t=0;t<a;t++){const t=s[l++],e=s[l++],i=s[l++],r=s[l++],a=!!s[l++],c=s[l++],h=o[l++],f=o[l++],u=s[l++],m=s[l++];n.colliders.push({xTile:t,yTile:e,dxPixels:i,dyPixels:r,hard:a,partIndex:c,width:u,height:m,minLod:h,maxLod:f})}const c=t[l++];for(let e=0;e<c;e++)n.textVertexRanges.push([t[l++],t[l++]]);const h=t[l++];for(let e=0;e<h;e++)n.iconVertexRanges.push([t[l++],t[l++]]);i.push(n)}return l}function i(t,e,s){for(const[o,l]of t.symbols)r(t,e,s,l,o)}function r(e,s,o,l,i){const r=e.layerData.get(i);if(r.type===t.SYMBOL){for(const t of l){const s=t.unique;let l;if(t.selectedForRendering){const t=s.parts[0],i=t.startOpacity,r=t.targetOpacity;e.allSymbolsFadingOut=e.allSymbolsFadingOut&&0===r;const n=o?Math.floor(127*i)|r<<7:r?255:0;l=n<<24|n<<16|n<<8|n}else l=0;for(const[e,o]of t.iconVertexRanges)for(let t=e;t<e+o;t+=4)r.iconOpacity[t/4]=l;if(t.selectedForRendering){const t=s.parts[1],i=t.startOpacity,r=t.targetOpacity;e.allSymbolsFadingOut=e.allSymbolsFadingOut&&0===r;const n=o?Math.floor(127*i)|r<<7:r?255:0;l=n<<24|n<<16|n<<8|n}else l=0;for(const[e,o]of t.textVertexRanges)for(let t=e;t<e+o;t+=4)r.textOpacity[t/4]=l}r.lastOpacityUpdate=s,r.opacityChanged=!0}}export{o as GridIndex,l as deserializeSymbols,s as tileCoordChange,i as writeOpacityToBuffers};