2 lines
19 KiB
JavaScript
2 lines
19 KiB
JavaScript
|
/* 2020-9-22 15:23:24 | 版权所有 军懋国兴 */
|
||
|
define(["./when-cbf8cd21","./Check-35e1a91d","./Math-69007a69","./Cartesian2-43e3a3be","./Transforms-2d1ac5ec","./RuntimeError-f4c64df1","./WebGLConstants-95ceb4e9","./ComponentDatatype-607c9a0c","./GeometryAttribute-2303bbfb","./EncodedCartesian3-29a09d7b","./IntersectionTests-459f6f08","./Plane-46b5436f","./WebMercatorProjection-3da37aae","./arrayRemoveDuplicates-d96adeb6","./ArcType-2b58731c","./EllipsoidRhumbLine-357c11e7","./EllipsoidGeodesic-007422da"],function(G,d,ze,Be,Ge,e,a,je,Ve,Ye,j,i,t,V,Y,q,M){"use strict";function r(e){e=G.defaultValue(e,G.defaultValue.EMPTY_OBJECT),this._ellipsoid=G.defaultValue(e.ellipsoid,Be.Ellipsoid.WGS84),this._rectangle=G.defaultValue(e.rectangle,Be.Rectangle.MAX_VALUE),this._projection=new Ge.GeographicProjection(this._ellipsoid),this._numberOfLevelZeroTilesX=G.defaultValue(e.numberOfLevelZeroTilesX,2),this._numberOfLevelZeroTilesY=G.defaultValue(e.numberOfLevelZeroTilesY,1)}Object.defineProperties(r.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},rectangle:{get:function(){return this._rectangle}},projection:{get:function(){return this._projection}}}),r.prototype.getNumberOfXTilesAtLevel=function(e){return this._numberOfLevelZeroTilesX<<e},r.prototype.getNumberOfYTilesAtLevel=function(e){return this._numberOfLevelZeroTilesY<<e},r.prototype.rectangleToNativeRectangle=function(e,a){d.Check.defined("rectangle",e);var t=ze.CesiumMath.toDegrees(e.west),r=ze.CesiumMath.toDegrees(e.south),n=ze.CesiumMath.toDegrees(e.east),i=ze.CesiumMath.toDegrees(e.north);return G.defined(a)?(a.west=t,a.south=r,a.east=n,a.north=i,a):new Be.Rectangle(t,r,n,i)},r.prototype.tileXYToNativeRectangle=function(e,a,t,r){var n=this.tileXYToRectangle(e,a,t,r);return n.west=ze.CesiumMath.toDegrees(n.west),n.south=ze.CesiumMath.toDegrees(n.south),n.east=ze.CesiumMath.toDegrees(n.east),n.north=ze.CesiumMath.toDegrees(n.north),n},r.prototype.tileXYToRectangle=function(e,a,t,r){var n=this._rectangle,i=this.getNumberOfXTilesAtLevel(t),s=this.getNumberOfYTilesAtLevel(t),o=n.width/i,l=e*o+n.west,u=(e+1)*o+n.west,c=n.height/s,C=n.north-a*c,p=n.north-(a+1)*c;return G.defined(r)||(r=new Be.Rectangle(l,p,u,C)),r.west=l,r.south=p,r.east=u,r.north=C,r},r.prototype.positionToTileXY=function(e,a,t){var r=this._rectangle;if(Be.Rectangle.contains(r,e)){var n=this.getNumberOfXTilesAtLevel(a),i=this.getNumberOfYTilesAtLevel(a),s=r.width/n,o=r.height/i,l=e.longitude;r.east<r.west&&(l+=ze.CesiumMath.TWO_PI);var u=(l-r.west)/s|0;n<=u&&(u=n-1);var c=(r.north-e.latitude)/o|0;return(i<=c&&(c=i-1),G.defined(t))?(t.x=u,t.y=c,t):new Be.Cartesian2(u,c)}};var u=new Be.Cartesian3,c=new Be.Cartesian3,C=new Be.Cartographic,p=new Be.Cartesian3,h=new Be.Cartesian3,o=new Ge.BoundingSphere,g=new r,f=[new Be.Cartographic,new Be.Cartographic,new Be.Cartographic,new Be.Cartographic],m=new Be.Cartesian2,qe={};function w(e){Be.Cartographic.fromRadians(e.east,e.north,0,f[0]),Be.Cartographic.fromRadians(e.west,e.north,0,f[1]),Be.Cartographic.fromRadians(e.east,e.south,0,f[2]),Be.Cartographic.fromRadians(e.west,e.south,0,f[3]);for(var a=0,t=0,r=0,n=0,i=qe._terrainHeightsMaxLevel,s=0;s<=i;++s){for(var o=!1,l=0;l<4;++l){var u=f[l];if(g.positionToTileXY(u,s,m),0===l)r=m.x,n=m.y;else if(r!==m.x||n!==m.y){o=!0;break}}if(o)break;a=r,t=n}if(0!==s)return{x:a,y:t,level:i<s?i:s-1}}qe.initialize=function(){var e=qe._initPromise;return G.defined(e)?e:(e=Ge.Resource.fetchJson(Ge.buildModuleUrl("Assets/approximateTerrainHeights.json")).then(function(e){qe._terrainHeights=e}),qe._initPromise=e)},qe.getMinimumMaximumHeights=function(e,a){if(d.Check.defined("rectangle",e),!G.defined(qe._terrainHeights))throw new d.DeveloperError("You must call ApproximateTerrainHeights.initialize and wait for the promise to resolve before using this function");a=G.defaultValue(a,Be.Ellipsoid.WGS84);var t,r,n,i,s=w(e),o=qe._defaultMinTerrainHeight,l=qe._defaultMaxTerrainHeight;return G.defined(s)&&(t=s.level+"-"+s.x+"-"+s.y,r=qe._terrainHeights[t],G.defined(r)&&(o=r[0],l=r[1]),a.cartographicToCartesian(Be.Rectangle.northeast(e,C),u),a.cartographicToCartesian(Be.Rectangle.southwe
|