qa-prevention-gwj-vue/static/map/cesium91/CesiumUnminified/Workers/DemData.js

2 lines
1.5 KiB
JavaScript

define((function(){"use strict";return class{constructor(t,i){if(t.height!==t.width)throw new RangeError("DEM tiles must be square");if(i&&"mapbox"!==i&&"terrarium"!==i)return console.log(`"${i}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);const s=this.dim=t.height;this.stride=this.dim+2,this.data=new Int32Array(this.stride*this.stride);const e=t.data,r="terrarium"===i?this._unpackTerrarium:this._unpackMapbox;for(let t=0;t<s;t++)for(let i=0;i<s;i++){const h=4*(t*s+i);this.set(i,t,r(e[h],e[h+1],e[h+2]))}for(let t=0;t<s;t++)this.set(-1,t,this.get(0,t)),this.set(s,t,this.get(s-1,t)),this.set(t,-1,this.get(t,0)),this.set(t,s,this.get(t,s-1));this.set(-1,-1,this.get(0,0)),this.set(s,-1,this.get(s-1,0)),this.set(-1,s,this.get(0,s-1)),this.set(s,s,this.get(s-1,s-1))}set(t,i,s){this.data[this._idx(t,i)]=s+65536}get(t,i){return this.data[this._idx(t,i)]-65536}_idx(t,i){if(t<-1||t>=this.dim+1||i<-1||i>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(i+1)*this.stride+(t+1)}_unpackMapbox(t,i,s){return(256*t*256+256*i+s)/10-1e4}_unpackTerrarium(t,i,s){return 256*t+i+s/256-32768}getPixels(){}backfillBorder(t,i,s){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let e=i*this.dim,r=i*this.dim+this.dim,h=s*this.dim,a=s*this.dim+this.dim;switch(i){case-1:e=r-1;break;case 1:r=e+1}switch(s){case-1:h=a-1;break;case 1:a=h+1}const d=-i*this.dim,n=-s*this.dim;for(let i=h;i<a;i++)for(let s=e;s<r;s++)this.set(s,i,t.get(s+d,i+n))}}}));