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

2 lines
5.5 KiB
JavaScript
Raw Permalink Normal View History

2024-01-02 14:12:39 +08:00
define(["./Resource-8ae1a924","./GeographicTilingScheme-86cef90e","./Cartesian2-bd414876","./defaultValue-81eec7ed","./Rectangle-cf3e0e3e","./WebMercatorProjection-44373a3d","./when-422ea0ae","./UPNG","./ElevationTool","./TerrainUpsample","./Cache","./createTaskProcessorWorker","./Check-741c5f3c","./combine-3c023bda","./Math-e73894ab","./RuntimeError-26acdd3b","./GeographicProjection-c931c7fb","./Cartesian3-e0307675","./LinkedQueue"],(function(e,t,r,n,i,o,s,l,a,c,u,h,f,g,p,d,y,_,x){"use strict";function w(e){if(e=n.defaultValue(e,n.defaultValue.EMPTY_OBJECT),this._ellipsoid=n.defaultValue(e.ellipsoid,r.Ellipsoid.WGS84),this._numberOfLevelZeroTilesX=n.defaultValue(e.numberOfLevelZeroTilesX,1),this._numberOfLevelZeroTilesY=n.defaultValue(e.numberOfLevelZeroTilesY,1),this._projection=new o.WebMercatorProjection(this._ellipsoid),n.defined(e.rectangleSouthwestInMeters)&&n.defined(e.rectangleNortheastInMeters))this._rectangleSouthwestInMeters=e.rectangleSouthwestInMeters,this._rectangleNortheastInMeters=e.rectangleNortheastInMeters;else{const e=this._ellipsoid.maximumRadius*Math.PI;this._rectangleSouthwestInMeters=new r.Cartesian2(-e,-e),this._rectangleNortheastInMeters=new r.Cartesian2(e,e)}const t=this._projection.unproject(this._rectangleSouthwestInMeters),s=this._projection.unproject(this._rectangleNortheastInMeters);this._rectangle=new i.Rectangle(t.longitude,t.latitude,s.longitude,s.latitude)}Object.defineProperties(w.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},rectangle:{get:function(){return this._rectangle}},projection:{get:function(){return this._projection}}}),w.prototype.getNumberOfXTilesAtLevel=function(e){return this._numberOfLevelZeroTilesX<<e},w.prototype.getNumberOfYTilesAtLevel=function(e){return this._numberOfLevelZeroTilesY<<e},w.prototype.rectangleToNativeRectangle=function(e,t){const r=this._projection,o=r.project(i.Rectangle.southwest(e)),s=r.project(i.Rectangle.northeast(e));return n.defined(t)?(t.west=o.x,t.south=o.y,t.east=s.x,t.north=s.y,t):new i.Rectangle(o.x,o.y,s.x,s.y)},w.prototype.tileXYToNativeRectangle=function(e,t,r,o){const s=this.getNumberOfXTilesAtLevel(r),l=this.getNumberOfYTilesAtLevel(r),a=(this._rectangleNortheastInMeters.x-this._rectangleSouthwestInMeters.x)/s,c=this._rectangleSouthwestInMeters.x+e*a,u=this._rectangleSouthwestInMeters.x+(e+1)*a,h=(this._rectangleNortheastInMeters.y-this._rectangleSouthwestInMeters.y)/l,f=this._rectangleNortheastInMeters.y-t*h,g=this._rectangleNortheastInMeters.y-(t+1)*h;return n.defined(o)?(o.west=c,o.south=g,o.east=u,o.north=f,o):new i.Rectangle(c,g,u,f)},w.prototype.tileXYToRectangle=function(e,t,n,i){const o=this.tileXYToNativeRectangle(e,t,n,i),s=this._projection,l=s.unproject(new r.Cartesian2(o.west,o.south)),a=s.unproject(new r.Cartesian2(o.east,o.north));return o.west=l.longitude,o.south=l.latitude,o.east=a.longitude,o.north=a.latitude,o},w.prototype.positionToTileXY=function(e,t,o){const s=this._rectangle;if(!i.Rectangle.contains(s,e))return;const l=this.getNumberOfXTilesAtLevel(t),a=this.getNumberOfYTilesAtLevel(t),c=(this._rectangleNortheastInMeters.x-this._rectangleSouthwestInMeters.x)/l,u=(this._rectangleNortheastInMeters.y-this._rectangleSouthwestInMeters.y)/a,h=this._projection.project(e);let f=(h.x-this._rectangleSouthwestInMeters.x)/c|0;f>=l&&(f=l-1);let g=(this._rectangleNortheastInMeters.y-h.y)/u|0;return g>=a&&(g=a-1),n.defined(o)?(o.x=f,o.y=g,o):new r.Cartesian2(f,g)};let m,M,z=65,v={},S=16,I=512,T=new u(100),b={};function N(t,r,n){var i=t.url,o=new e.Resource({url:i});o.request.throttle=!1,o.request.throttleByServer=!0,o.request.type=1;var s=o.fetchArrayBuffer();s?s.then(function(e,r){let i=l.decode(r),o=l.toRGBA8(i)[0],s=function(e,t){let r=new Int16Array(t*t);const n=t;for(let t=0;t<n;t++)for(let i=0;i<n;i++){const o=4*(t*n+i);r[t*n+i]=R(e[o],e[o+1],e[o+2])}return r}(new Uint8Array(o),i.width);t.xyz.z==S&&T.set(t.xyzStr,s);let c=j(s,i.width,n);a.updateElevation(v[m],m,t.xyzStr,s).promise.then((function(t){e.resolve(c)}),(function(t){e.resolve(c)}))}.bind(this,r)):r.reject(null)}function j(e,t,r){let n=Math.flo