| | |
| | | movement.endPosition, |
| | | ellipsoid |
| | | ); |
| | | |
| | | |
| | | if (cartesian) { |
| | | //将笛卡尔三维坐标转为地图坐标(弧度) |
| | | var cartographic = |
| | |
| | | geodesic.setEndPoints(leftCartographic, rightCartographic, ellipsoid); |
| | | // rate.value = geodesic.surfaceDistance.toFixed(2); //分辨率 |
| | | }); |
| | | Viewer.camera.moveEnd.addEventListener(() => { |
| | | const height = Viewer.camera.positionCartographic.height; |
| | | const zoom = getZoomLevel(height) |
| | | rate.value = zoom; |
| | | // console.log('缩放层级是--', zoom) |
| | | }) |
| | | const getZoomLevel = (height) => { |
| | | const A = 40487.57; |
| | | const B = 0.00007096758; |
| | | const C = 91610.74; |
| | | const D = -40467.74; |
| | | var obj= Math.round(D + (A - D) / (1 + Math.pow(height / C, B))); |
| | | var fgis = [0.703125, 0.3515625, 0.17578125, 0.087890625, 0.0439453125, 0.02197265625, 0.010986328125, 0.0054931640625, 0.00274658203125, 0.001373291015625, 0.0006866455078125, 0.00034332275390625, 0.00017166137695312, 0.000085830688476562, 0.000042915344238281, 0.000021457672119141, 0.00001072883605957, 0.0000053644180297852, 0.0000026822090148926, 0.0000013411045074463, 0.00000067055225372314, 0.00000033527612686157] |
| | | |
| | | return( fgis[obj]*30318.4).toFixed(2); |
| | | } |
| | | |
| | | |
| | | |
| | | Viewer.scene.postRender.addEventListener(() => { |
| | |
| | | if (!SmartEarth.Cesium.defined(leftPosition) || !SmartEarth.Cesium.defined(rightPosition)) { |
| | | return; |
| | | } |
| | | const dpi = getDPI(); |
| | | const ellipsoid = SmartEarth.Cesium.Ellipsoid.MOON2000 |
| | | var leftCartographic = ellipsoid.cartesianToCartographic(leftPosition); |
| | | var rightCartographic = ellipsoid.cartesianToCartographic(rightPosition); |
| | | var geodesic = new SmartEarth.Cesium.EllipsoidGeodesic(leftCartographic, rightCartographic, ellipsoid); |
| | | var distance = geodesic.surfaceDistance;// 分辨率 |
| | | rate.value = distance.toFixed(2); //分辨率 |
| | | var distance = geodesic.surfaceDistance * dpi;// 分辨率 |
| | | // rate.value = distance.toFixed(2); //分辨率 |
| | | }) |
| | | }; |
| | | const getDPI = () => { |
| | | |
| | | var arrDPI = new Array(); |
| | | if (window.screen.deviceXDPI != undefined) { |
| | | arrDPI[0] = window.screen.deviceXDPI; |
| | | arrDPI[1] = window.screen.deviceYDPI; |
| | | } |
| | | else { |
| | | var tmpNode = document.createElement("DIV"); |
| | | tmpNode.style.cssText = "width:1in;height:1in;position:absolute;left:0px;top:0px;z-index:99;visibility:hidden"; |
| | | document.body.appendChild(tmpNode); |
| | | arrDPI[0] = parseInt(tmpNode.offsetWidth); |
| | | arrDPI[1] = parseInt(tmpNode.offsetHeight); |
| | | |
| | | } |
| | | return arrDPI[0] |
| | | |
| | | } |
| | | const gridSwitch = () => { |
| | | server.showlonlatLine(); |
| | | }; |