2 lines
18 KiB
JavaScript
2 lines
18 KiB
JavaScript
|
define(["./Transforms-98ffa11d","./Matrix2-e3fb4559","./Cartesian3-7e9cc2ff","./Check-741c5f3c","./defaultValue-81eec7ed","./Math-5f585871","./ArcType-fc72c06c","./arrayRemoveDuplicates-85770175","./ComponentDatatype-aaeec80f","./EllipsoidGeodesic-6de45192","./EllipsoidRhumbLine-9c6b32ea","./EncodedCartesian3-aac44514","./GeometryAttribute-b025f9a8","./IntersectionTests-73b87d72","./Matrix4-d34187af","./Plane-4f75b3df","./WebMercatorProjection-f5706bbf","./_commonjsHelpers-3aae1032-26891ab7","./combine-3c023bda","./RuntimeError-26acdd3b","./WebGLConstants-508b9636"],(function(e,t,a,n,i,r,s,o,l,c,u,C,p,d,h,g,f,m,w,y,M){"use strict";function T(a){a=i.defaultValue(a,i.defaultValue.EMPTY_OBJECT),this._ellipsoid=i.defaultValue(a.ellipsoid,t.Ellipsoid.WGS84),this._rectangle=i.defaultValue(a.rectangle,t.Rectangle.MAX_VALUE),this._projection=new e.GeographicProjection(this._ellipsoid),this._numberOfLevelZeroTilesX=i.defaultValue(a.numberOfLevelZeroTilesX,2),this._numberOfLevelZeroTilesY=i.defaultValue(a.numberOfLevelZeroTilesY,1)}Object.defineProperties(T.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},rectangle:{get:function(){return this._rectangle}},projection:{get:function(){return this._projection}}}),T.prototype.getNumberOfXTilesAtLevel=function(e){return this._numberOfLevelZeroTilesX<<e},T.prototype.getNumberOfYTilesAtLevel=function(e){return this._numberOfLevelZeroTilesY<<e},T.prototype.rectangleToNativeRectangle=function(e,a){const n=r.CesiumMath.toDegrees(e.west),s=r.CesiumMath.toDegrees(e.south),o=r.CesiumMath.toDegrees(e.east),l=r.CesiumMath.toDegrees(e.north);return i.defined(a)?(a.west=n,a.south=s,a.east=o,a.north=l,a):new t.Rectangle(n,s,o,l)},T.prototype.tileXYToNativeRectangle=function(e,t,a,n){const i=this.tileXYToRectangle(e,t,a,n);return i.west=r.CesiumMath.toDegrees(i.west),i.south=r.CesiumMath.toDegrees(i.south),i.east=r.CesiumMath.toDegrees(i.east),i.north=r.CesiumMath.toDegrees(i.north),i},T.prototype.tileXYToRectangle=function(e,a,n,r){const s=this._rectangle,o=this.getNumberOfXTilesAtLevel(n),l=this.getNumberOfYTilesAtLevel(n),c=s.width/o,u=e*c+s.west,C=(e+1)*c+s.west,p=s.height/l,d=s.north-a*p,h=s.north-(a+1)*p;return i.defined(r)||(r=new t.Rectangle(u,h,C,d)),r.west=u,r.south=h,r.east=C,r.north=d,r},T.prototype.positionToTileXY=function(e,a,n){const s=this._rectangle;if(!t.Rectangle.contains(s,e))return;const o=this.getNumberOfXTilesAtLevel(a),l=this.getNumberOfYTilesAtLevel(a),c=s.width/o,u=s.height/l;let C=e.longitude;s.east<s.west&&(C+=r.CesiumMath.TWO_PI);let p=(C-s.west)/c|0;p>=o&&(p=o-1);let d=(s.north-e.latitude)/u|0;return d>=l&&(d=l-1),i.defined(n)?(n.x=p,n.y=d,n):new t.Cartesian2(p,d)};const E=new a.Cartesian3,_=new a.Cartesian3,O=new t.Cartographic,b=new a.Cartesian3,P=new a.Cartesian3,k=new e.BoundingSphere,A=new T,L=[new t.Cartographic,new t.Cartographic,new t.Cartographic,new t.Cartographic],S=new t.Cartesian2,x={};function I(e){t.Cartographic.fromRadians(e.east,e.north,0,L[0]),t.Cartographic.fromRadians(e.west,e.north,0,L[1]),t.Cartographic.fromRadians(e.east,e.south,0,L[2]),t.Cartographic.fromRadians(e.west,e.south,0,L[3]);let a=0,n=0,i=0,r=0;const s=x._terrainHeightsMaxLevel;let o;for(o=0;o<=s;++o){let e=!1;for(let t=0;t<4;++t){const a=L[t];if(A.positionToTileXY(a,o,S),0===t)i=S.x,r=S.y;else if(i!==S.x||r!==S.y){e=!0;break}}if(e)break;a=i,n=r}if(0!==o)return{x:a,y:n,level:o>s?s:o-1}}x.initialize=function(){let t=x._initPromise;return i.defined(t)||(t=e.Resource.fetchJson(e.buildModuleUrl("Assets/approximateTerrainHeights.json")).then((function(e){x._terrainHeights=e})),x._initPromise=t),t},x.getMinimumMaximumHeights=function(e,n){n=i.defaultValue(n,t.Ellipsoid.WGS84);const r=I(e);let s=x._defaultMinTerrainHeight,o=x._defaultMaxTerrainHeight;if(i.defined(r)){const l=`${r.level}-${r.x}-${r.y}`,c=x._terrainHeights[l];i.defined(c)&&(s=c[0],o=c[1]),n.cartographicToCartesian(t.Rectangle.northeast(e,O),E),n.cartographicToCartesian(t.Rectangle.southwest(e,O),_),a.Cartesian3.midpoint(_,E,b);const u=n.scaleToGeodeticSurface(b,P);if(i.defined(u)){const e=a.Cartesian3.distance(b,u)
|