/** * * SmartEarthSDK 基于Cesium的三维web开发 * author: 张丹钊、金磊、薛鹏、张恒 * */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SmartEarth={})}(this,function(o){"use strict";function f(e,t,i,o){var r=Math.PI;function n(e){return e*r/180}var a=n((e+i)/2),e=n((e-i)/2),i=n((t-o)/2),t=Math.sin(e),o=Math.sin(i),e=Math.sin(a),i=(t*=t)*(1-(o*=o))+(1-(e*=e))*o,a=(1-t)*(1-o)+e*o;return 2*(o=Math.atan(Math.sqrt(i/a)))*6378137*(1+1/298.257*((3*(o=Math.sqrt(i*a)/o)-1)/2/a*e*(1-t)-(3*o+1)/2/i*(1-e)*t))}function m(e,t){this._viewer=e,this._cesium=t}function y(e,t){this._viewer=e,this._cesium=t}function v(e,t){var i=Math.PI/180,o=180/Math.PI,r=e.y*i,n=e.x*i,e=t.y*i,i=t.x*i,i=-Math.atan2(Math.sin(n-i)*Math.cos(e),Math.cos(r)*Math.sin(e)-Math.sin(r)*Math.cos(e)*Math.cos(n-i));return i<0&&(i+=2*Math.PI),i*=o}function C(e,t,i){i=v(t,e)-v(t,i);return i<0&&(i+=360),i}function w(e){if(!e||e.length<3)return 0;for(var t=Math.PI/180,i=0,o=0;oCesium.Math.toRadians(80))return!1;e=t.cartesianToCanvasCoordinates(e);return e?[e.x-this._mapOffset[0],e.y-this._mapOffset[1]]:[]}return[]}},{key:"pointToData",value:function(e){var t=this._mapOffset,i=u.scene.globe.ellipsoid,t=new Cesium.cartesian3(e[1]+t,e[2]+t[2],0),t=i.cartesianToCartographic(t);return[t.lng,t.lat]}},{key:"getViewRect",value:function(){var e=this._api;return new echarts.graphic.BoundingRect(0,0,e.getWidth(),e.getHeight())}},{key:"getRoamTransform",value:function(){return echarts.matrix.create()}}]),o(r,n),s);function s(e,t){!function(e){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}(this),this._viewer=e,this.dimensions=["lng","lat"],this._mapOffset=[0,0],this._api=t}function l(){echarts.registerCoordinateSystem("GLMap",a),echarts.registerAction({type:"GLMapRoam",event:"GLMapRoam",update:"updateLayout"},function(e,t){})}echarts.extendComponentModel({type:"GLMap",getViewer:function(){return u},defaultOption:{roam:!1}}),echarts.extendComponentView({type:"GLMap",init:function(e,t){this.api=t,this.dispose(),u.scene.postRender.addEventListener(this.moveHandler,this)},moveHandler:function(e,t){this.api.dispatchAction({type:"GLMapRoam"})},render:function(e,t,i){},dispose:function(e){u.scene.postRender.removeEventListener(this.moveHandler,this)}}),i.d(t,"load",function(){return l})}],o={},r.m=i,r.c=o,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(i,o,function(e){return t[e]}.bind(null,o));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)},I.prototype.getSceneList=function(t){$.ajax({url:this.serverUrl+"/scene/sceneList",type:"get",success:function(e){t&&"function"==typeof t&&e&&t(JSON.parse(e))}})},I.prototype.query=function(e,t){var i=e.database,e={type:P(e.type,"building"),id:e.id,returnGeometry:P(e.returnGeometry,!0),returnChildren:P(e.returnChildren,!0)};$.ajax({url:this.serverUrl+"/"+i+"/query?version=v2.1",type:"post",async:!0,data:e,success:function(e){t&&"function"==typeof t&&e&&t(JSON.parse(e))},error:function(e,t,i){alert("error:"+e.status)}})},L.prototype.startRecord=function(){navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0}).then(e=>{this.createRecorder(e)}).catch(e=>{this.getUserMediaError(e)})},L.prototype.getUserMediaError=function(e){console.log("mediaError",e)},L.prototype.createRecorder=function(e){console.log("start record");var t={videoBitsPerSecond:this.videoBPS};this.recorder=new MediaRecorder(e,t),this.recorder.start();var i=[];this.recorder.onstop=e=>{var t=new Blob(i,{type:"video/mp4"});this.saveMedia(t)},this.recorder.ondataavailable=e=>{i.push(e.data)}},L.prototype.saveMedia=function(e){var t=window.URL.createObjectURL(e),e=document.createElement("a");e.innerHTML="test",e.download=this.mediaOutputPath,e.href=t,e.click()},L.prototype.stopRecord=function(){this.recorder.stop()};const M=52.35987755982988,A=3.141592653589793,R=6378245,O=.006693421622965943,H={BD09ToGCJ02(e,t){var i=+e-.0065,e=+t-.006,t=Math.sqrt(i*i+e*e)-2e-5*Math.sin(e*M),i=Math.atan2(e,i)-3e-6*Math.cos(i*M);return[t*Math.cos(i),t*Math.sin(i)]},GCJ02ToBD09(e,t){t=+t,e=+e;var i=Math.sqrt(e*e+t*t)+2e-5*Math.sin(t*M),e=Math.atan2(t,e)+3e-6*Math.cos(e*M);return[i*Math.cos(e)+.0065,i*Math.sin(e)+.006]},WGS84ToGCJ02(e,t){if(this.out_of_china(e=+e,t=+t))return[e,t];var i=this.delta(e,t);return[e+i[0],t+i[1]]},GCJ02ToWGS84(e,t){if(this.out_of_china(e=+e,t=+t))return[e,t];var i=this.delta(e,t);return[2*e-(e+i[0]),2*t-(t+i[1])]},delta(e,t){var i=this.transformLng(e-105,t-35),o=this.transformLat(e-105,t-35),r=t/180*A,e=Math.sin(r),e=1-O*e*e,t=Math.sqrt(e);return[i=180*i/(R/t*Math.cos(r)*A),o=180*o/(R*(1-O)/(e*t)*A)]},transformLng(e,t){t=300+(e=+e)+2*(t=+t)+.1*e*e+.1*e*t+.1*Math.sqrt(Math.abs(e));return t+=2*(20*Math.sin(6*e*A)+20*Math.sin(2*e*A))/3,t+=2*(20*Math.sin(e*A)+40*Math.sin(e/3*A))/3,t+=2*(150*Math.sin(e/12*A)+300*Math.sin(e/30*A))/3},transformLat(e,t){var i=2*(e=+e)-100+3*(t=+t)+.2*t*t+.1*e*t+.2*Math.sqrt(Math.abs(e));return i+=2*(20*Math.sin(6*e*A)+20*Math.sin(2*e*A))/3,i+=2*(20*Math.sin(t*A)+40*Math.sin(t/3*A))/3,i+=2*(160*Math.sin(t/12*A)+320*Math.sin(t*A/30))/3},out_of_china(e,t){return t=+t,!(73.66<(e=+e)&&e<135.05&&3.86