bimland/dist/Cesium/Workers/MVTWorkTile.js

2 lines
256 KiB
JavaScript
Raw Permalink Normal View History

2023-07-26 17:04:38 +08:00
define(["./createTaskProcessorWorker","./when-b60132fc","./pbf-2b242707","./earcut-2.2.1-20c8012f"],(function(t,e,r,n){"use strict";function i(t){this._stringToNumber={},this._numberToString=[];for(var e=0;e<t.length;e++){var r=t[e];this._stringToNumber[r]=e,this._numberToString[e]=r}}i.prototype.encode=function(t){return this._stringToNumber[t]},i.prototype.decode=function(t){return this._numberToString[t]};var a={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};function o(t,e){void 0===e&&(e=1);var r=0,n=0;return{members:t.map((function(t){var i=s(t.type),a=r=u(r,Math.max(e,i)),o=t.components||1;return n=Math.max(n,i),r+=i*o,{name:t.name,type:t.type,components:o,offset:a}})),size:u(r,Math.max(n,e)),alignment:e}}function s(t){return a[t].BYTES_PER_ELEMENT}function u(t,e){return Math.ceil(t/e)*e}var l=1,p=function(t,e){var r=e.pixelRatio,n=e.version,i=e.stretchX,a=e.stretchY,o=e.content;this.paddedRect=t,this.pixelRatio=r,this.stretchX=i,this.stretchY=a,this.content=o,this.version=n},c={tl:{configurable:!0},br:{configurable:!0},tlbr:{configurable:!0},displaySize:{configurable:!0}};c.tl.get=function(){return[this.paddedRect.x+l,this.paddedRect.y+l]},c.br.get=function(){return[this.paddedRect.x+this.paddedRect.w-l,this.paddedRect.y+this.paddedRect.h-l]},c.tlbr.get=function(){return this.tl.concat(this.br)},c.displaySize.get=function(){return[(this.paddedRect.w-2*l)/this.pixelRatio,(this.paddedRect.h-2*l)/this.pixelRatio]},Object.defineProperties(p.prototype,c);var f=function(t,e){h(this,t,4,e)};function h(t,e,r,n){var i=e.width,a=e.height;if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==i*a*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(i*a*r);return t.width=i,t.height=a,t.data=n,t}function d(t,e,r){var n=e.width,i=e.height;if(n!==t.width||i!==t.height){var a=h({},{width:n,height:i},r);y(t,a,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,n),height:Math.min(t.height,i)},r),t.width=n,t.height=i,t.data=a.data}}function y(t,e,r,n,i,a){if(0===i.width||0===i.height)return e;if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");for(var o=t.data,s=e.data,u=0;u<i.height;u++)for(var l=((r.y+u)*t.width+r.x)*a,p=((n.y+u)*e.width+n.x)*a,c=0;c<i.width*a;c++)s[p+c]=o[l+c];return e}function m(t){for(var e=0,r=0,n=0,i=t;n<i.length;n+=1){var a=i[n];e+=a.w*a.h,r=Math.max(r,a.w)}t.sort((function(t,e){return e.h-t.h}));for(var o=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}],s=0,u=0,l=0,p=t;l<p.length;l+=1)for(var c=p[l],f=o.length-1;f>=0;f--){var h=o[f];if(!(c.w>h.w||c.h>h.h)){if(c.x=h.x,c.y=h.y,u=Math.max(u,c.y+c.h),s=Math.max(s,c.x+c.w),c.w===h.w&&c.h===h.h){var d=o.pop();f<o.length&&(o[f]=d)}else c.h===h.h?(h.x+=c.w,h.w-=c.w):c.w===h.w?(h.y+=c.h,h.h-=c.h):(o.push({x:h.x+c.w,y:h.y,w:h.w-c.w,h:c.h}),h.y+=c.h,h.h-=c.h);break}}return{w:s,h:u,fill:e/(s*u)||0}}f.prototype.resize=function(t){d(this,t,4)},f.prototype.replace=function(t,e){e?this.data.set(t):t instanceof Uint8ClampedArray?this.data=new Uint8Array(t.buffer):this.data=t},f.prototype.clone=function(){return new f({width:this.width,height:this.height},new Uint8Array(this.data))},f.copy=function(t,e,r,n,i){y(t,e,r,n,i,4)};var v=1,g=function(t,e){var r={},n={};this.haveRenderCallbacks=[];var i=[];this.addImages(t,r,i),this.addImages(e,n,i);var a=m(i),o=a.w,s=a.h,u=new f({width:o||1,height:s||1});for(var l in t){var p=t[l],c=r[l].paddedRect;f.copy(p.data,u,{x:0,y:0},{x:c.x+v,y:c.y+v},p.data)}for(var h in e){var d=e[h],y=n[h].paddedRect,g=y.x+v,x=y.y+v,b=d.data.width,_=d.data.height;f.copy(d.data,u,{x:0,y:0},{x:g,y:x},d.data),f.copy(d.data,u,{x:0,y:_-1},{x:g,y:x-1},{width:b,height:1}),f.copy(d.data,u,{x:0,y:0},{x:g,y:x+_},{width:b,height:1}),f.copy(d.data,u,{x:b-1,y:0},{x:g-1,y:x},{width:1,he