|
|
/** * Mars3D平台插件,结合mapv可视化功能插件 mars3d-mapv * * 版本信息:v3.7.23 * 编译日期:2024-07-22 00:04:50 * 版权所有:Copyright by 火星科技 http://mars3d.cn
* 使用单位:免费公开版 ,2024-01-15 */
(function (global, factory) { if (typeof exports === 'object' && typeof module !== 'undefined') { factory(exports, window.mapv || require('mapv'), window.mars3d || require('mars3d')); } else if (typeof define === 'function' && define.amd) { define(['exports', 'mapv', 'mars3d'], factory); } else { global = typeof globalThis !== 'undefined' ? globalThis : global || self; factory(global["mars3d-mapv"] = {}, global.mapv, global.mars3d); }})(this, function (exports, mapv, mars3d) { 'use strict';
function _interopNamespace(_0x573ae7) { if (_0x573ae7 && _0x573ae7.__esModule) { return _0x573ae7; } var _0x5455e0 = Object.create(null); if (_0x573ae7) { Object.keys(_0x573ae7).forEach(function (_0x153706) { if (_0x153706 !== 'default') { var _0x19ee1b = Object.getOwnPropertyDescriptor(_0x573ae7, _0x153706); Object.defineProperty(_0x5455e0, _0x153706, _0x19ee1b.get ? _0x19ee1b : { 'enumerable': true, 'get': function () { return _0x573ae7[_0x153706]; } }); } }); } _0x5455e0['default'] = _0x573ae7; return _0x5455e0; } var mapv__namespace = _interopNamespace(mapv); var mars3d__namespace = _interopNamespace(mars3d); const Cesium$1 = mars3d__namespace.Cesium; const baiduMapLayer = mapv__namespace ? mapv__namespace.baiduMapLayer : null; const BaseLayer$1 = baiduMapLayer ? baiduMapLayer.__proto__ : Function; class MapVRenderer extends BaseLayer$1 { constructor(_0x18d85c, _0x42db71, _0x576641, _0x34a4eb) { super(_0x18d85c, _0x42db71, _0x576641); if (!BaseLayer$1) { return; } this.map = _0x18d85c; this.scene = _0x18d85c.scene; this.dataSet = _0x42db71; _0x576641 = _0x576641 || {}; this.init(_0x576641); this.argCheck(_0x576641); this.initDevicePixelRatio(); this.canvasLayer = _0x34a4eb; this.stopAniamation = false; this.animation = _0x576641.animation; } ['initDevicePixelRatio']() { this.devicePixelRatio = 0x1 || 0x1; } ['addAnimatorEvent']() {} ['animatorMovestartEvent']() { const _0x314d7a = this.options.animation; if (this.isEnabledTime() && this.animator) { this.steps.step = _0x314d7a.stepsRange.start; } } ["animatorMoveendEvent"]() { if (this.isEnabledTime()) { this.animator; } } ['getContext']() { return this.canvasLayer.canvas.getContext(this.context); } ['init'](_0x51f4aa) { this.options = _0x51f4aa; this.initDataRange(_0x51f4aa); this.context = this.options.context || '2d'; if (Cesium$1.defined(this.options.zIndex) && this.canvasLayer && this.canvasLayer.setZIndex) { this.canvasLayer.setZIndex(this.options.zIndex); } // alert(1)
this.initAnimator(); } ["_canvasUpdate"](_0x20338a) { if (!this.canvasLayer || this.stopAniamation) { return; } const _0x416071 = this.scene; const _0x2399bf = this.options.animation; const _0x39a81a = this.getContext(); if (this.isEnabledTime()) { if (undefined === _0x20338a) { return void this.clear(_0x39a81a); } if (this.context === '2d') { _0x39a81a.save(); _0x39a81a.globalCompositeOperation = 'destination-out'; _0x39a81a.fillStyle = "rgba(0, 0, 0, .1)"; _0x39a81a.fillRect(0x0, 0x0, _0x39a81a.canvas.width, _0x39a81a.canvas.height); _0x39a81a.restore(); } } else { this.clear(_0x39a81a); } if (this.context === '2d') { for (const _0x378c53 in this.options) { _0x39a81a[_0x378c53] = this.options[_0x378c53]; } } else { _0x39a81a.clear(_0x39a81a.COLOR_BUFFER_BIT); } const _0x381465 = { 'transferCoordinate': function (_0x2707ae) { let _0x439b1f = _0x416071.mapvFixedHeight; if (_0x416071.mapvAutoHeight) { _0x439b1f = _0x416071.globe.getHeight(Cesium$1.Cartographic.fromDegrees(_0x2707ae[0x0], _0x2707ae[0x1])); } const _0x36ea67 = Cesium$1.Cartesian3.fromDegrees(_0x2707ae[0x0], _0x2707ae[0x1], _0x439b1f); if (!_0x36ea67) { return null; } const _0x5ce1af = _0x416071.cartesianToCanvasCoordinates(_0x36ea67); //const _0x5ce1af = Cesium.SceneTransforms.wgs84ToWindowCoordinates(_0x416071,_0x36ea67)
// const _0x5ce1af = _0x416071.wgs84ToWindowCoordinates(_0x36ea67);
if (!_0x5ce1af) { return null; } if (_0x416071.mapvDepthTest && _0x416071.mode === Cesium$1.SceneMode.SCENE3D) { const _0x5cf40c = new Cesium$1.EllipsoidalOccluder(_0x416071.globe.ellipsoid, _0x416071.camera.positionWC); const _0xccc6c5 = _0x5cf40c.isPointVisible(_0x36ea67); if (!_0xccc6c5) { return null; } } return [_0x5ce1af.x, _0x5ce1af.y]; } }; if (undefined !== _0x20338a) { _0x381465.filter = function (_0x501bbe) { const _0x3c6991 = _0x2399bf.trails || 0xa; return !!(_0x20338a && _0x501bbe.time > _0x20338a - _0x3c6991 && _0x501bbe.time < _0x20338a); }; } let _0x1b9b76; if (this.options.draw === "cluster" && (!this.options.maxClusterZoom || this.options.maxClusterZoom >= this.getZoom())) { this.map.getExtent(); const _0x440029 = this.getZoom(); const _0x1cb057 = this.supercluster.getClusters([-0xb4, -0x5a, 0xb4, 0x5a], _0x440029); this.pointCountMax = this.supercluster.trees[_0x440029].max; this.pointCountMin = this.supercluster.trees[_0x440029].min; let _0x5bc48e = {}; let _0x349eb2 = null; let _0xe32a87 = null; if (this.pointCountMax === this.pointCountMin) { _0x349eb2 = this.options.fillStyle; _0xe32a87 = this.options.minSize || 0x8; } else { const _0x1a5a3f = { min: this.pointCountMin, max: this.pointCountMax, minSize: this.options.minSize || 0x8, maxSize: this.options.maxSize || 0x1e, gradient: this.options.gradient }; _0x5bc48e = new mapv__namespace.utilDataRangeIntensity(_0x1a5a3f); } for (let _0x4be964 = 0x0; _0x4be964 < _0x1cb057.length; _0x4be964++) { const _0x52b538 = _0x1cb057[_0x4be964]; if (_0x52b538.properties && _0x52b538.properties.cluster_id) { _0x1cb057[_0x4be964].size = _0xe32a87 || _0x5bc48e.getSize(_0x52b538.properties.point_count); _0x1cb057[_0x4be964].fillStyle = _0x349eb2 || _0x5bc48e.getColor(_0x52b538.properties.point_count); } else { _0x1cb057[_0x4be964].size = this.options.size; } } this.clusterDataSet.set(_0x1cb057); _0x1b9b76 = this.clusterDataSet.get(_0x381465); } else { _0x1b9b76 = this.dataSet.get(_0x381465); } this.processData(_0x1b9b76); if (this.options.unit === 'm' && this.options.size) { this.options._size = this.options.size; } const _0x3ef808 = _0x416071.cartesianToCanvasCoordinates(Cesium$1.Cartesian3.fromDegrees(0x0, 0x0)); if (!_0x3ef808) { return; } // alert("1+1");
// console.log("new mapv__namespace.DataSet(_0x1b9b76)",new mapv__namespace.DataSet(_0x1b9b76))
this.drawContext(_0x39a81a, new mapv__namespace.DataSet(_0x1b9b76), this.options, _0x3ef808); if (this.options.updateCallback) { this.options.updateCallback(_0x20338a); } } ['updateData'](_0x260212, _0x5b851c) { let _0x189e00 = _0x260212; if (_0x189e00 && _0x189e00.get) { _0x189e00 = _0x189e00.get(); } if (undefined !== _0x189e00) { this.dataSet.set(_0x189e00); } const _0x465b76 = { 'options': _0x5b851c }; super.update(_0x465b76); } ['addData'](_0x28f22, _0x564ee7) { let _0x41f1d8 = _0x28f22; const _0x27f2bd = { 'options': _0x564ee7 }; if (_0x28f22 && _0x28f22.get) { _0x41f1d8 = _0x28f22.get(); } this.dataSet.add(_0x41f1d8); this.update(_0x27f2bd); } ['getData']() { return this.dataSet; } ['removeData'](_0x464f7d) { if (this.dataSet) { const _0x12718a = this.dataSet.get({ 'filter': function (_0xe00322) { return _0x464f7d == null || typeof _0x464f7d !== "function" || !_0x464f7d(_0xe00322); } }); this.dataSet.set(_0x12718a); const _0x1157d6 = { options: null }; this.update(_0x1157d6); } } ['clearData']() { if (this.dataSet) { this.dataSet.clear(); } const _0x1dd969 = { options: null }; this.update(_0x1dd969); } ['draw']() { this.canvasLayer.draw(); } ["clear"](_0x4b8669) { if (_0x4b8669 && _0x4b8669.clearRect) { _0x4b8669.clearRect(0x0, 0x0, _0x4b8669.canvas.width, _0x4b8669.canvas.height); } } ['getZoom']() { return this.map.level; } ['destroy']() { this.clear(this.getContext()); this.clearData(); if (this.animator) { this.animator.stop(); } this.animator = null; this.canvasLayer = null; } } if (mapv__namespace !== null && mapv__namespace !== undefined && mapv__namespace.DataSet) { mapv__namespace.DataSet.prototype.transferCoordinate = function (_0x4f82a4, _0xdf712b, _0x5dc743, _0x400bac) { _0x400bac = _0x400bac || "_coordinates"; _0x5dc743 = _0x5dc743 || 'coordinates'; for (let _0x54053f = 0x0; _0x54053f < _0x4f82a4.length; _0x54053f++) { const _0x3a6e1b = _0x4f82a4[_0x54053f].geometry; const _0x476e96 = _0x3a6e1b[_0x5dc743]; switch (_0x3a6e1b.type) { case "Point": { const _0x137d16 = _0xdf712b(_0x476e96); if (_0x137d16) { _0x3a6e1b[_0x400bac] = _0x137d16; } else { _0x3a6e1b[_0x400bac] = [-0x3e7, -0x3e7]; } } break; case "LineString": { const _0x1cc238 = []; for (let _0x3e1833 = 0x0; _0x3e1833 < _0x476e96.length; _0x3e1833++) { const _0x512dbe = _0xdf712b(_0x476e96[_0x3e1833]); if (_0x512dbe) { _0x1cc238.push(_0x512dbe); } } _0x3a6e1b[_0x400bac] = _0x1cc238; } break; case 'MultiLineString': case "Polygon": { const _0x247cdf = _0x178cd7(_0x476e96); _0x3a6e1b[_0x400bac] = _0x247cdf; } break; case 'MultiPolygon': { const _0x23f598 = []; for (let _0x20a32b = 0x0; _0x20a32b < _0x476e96.length; _0x20a32b++) { const _0x5bbaf6 = _0x178cd7(_0x476e96[_0x20a32b]); if (_0x5bbaf6.length > 0x0) { _0x23f598.push(_0x5bbaf6); } } _0x3a6e1b[_0x400bac] = _0x23f598; } break; } } function _0x178cd7(_0x4713d8) { const _0x5027d2 = []; for (let _0x45afa1 = 0x0; _0x45afa1 < _0x4713d8.length; _0x45afa1++) { const _0x54a18b = _0x4713d8[_0x45afa1]; const _0x5f842c = []; for (let _0x281016 = 0x0; _0x281016 < _0x54a18b.length; _0x281016++) { const _0x4f4c1b = _0xdf712b(_0x54a18b[_0x281016]); if (_0x4f4c1b) { _0x5f842c.push(_0x4f4c1b); } } if (_0x5f842c.length > 0x0) { _0x5027d2.push(_0x5f842c); } } return _0x5027d2; } return _0x4f82a4; }; } else { throw new Error("请引入 mapv 库 "); } const Cesium = mars3d__namespace.Cesium; const BaseLayer = mars3d__namespace.layer.BaseLayer; class MapVLayer extends BaseLayer { constructor(_0x56419, _0x16a668) { super(_0x56419); this._pointerEvents = this.options.pointerEvents; this.dataSet = _0x16a668 || new mapv__namespace.DataSet(_0x56419.data); this.canvas = null; } get ['pointerEvents']() { return this._pointerEvents; } set ["pointerEvents"](_0x58af16) { this._pointerEvents = _0x58af16; if (this.canvas) { if (_0x58af16) { this.canvas.style.pointerEvents = 'all'; } else { this.canvas.style.pointerEvents = "none"; } } } ['_showHook'](_0x10638f) { if (_0x10638f) { this.canvas.style.display = 'block'; } else { this.canvas.style.display = "none"; } } ['_mountedHook']() { this._map.scene.mapvDepthTest = this.options.depthTest ?? true; this._map.scene.mapvAutoHeight = this.options.clampToGround ?? false; this._map.scene.mapvFixedHeight = this.options.fixedHeight ?? 0x0; } ['_addedHook']() { if (this.dataSet && (!this.dataSet._data || this.dataSet._data.length === 0x0)) { this.dataSet._data = [].concat(this.dataSet._dataCache); } this._mapVRenderer = new MapVRenderer(this._map, this.dataSet, this.options, this); this.initDevicePixelRatio(); this.canvas = this._createCanvas(); this.render = this.render.bind(this); this.bindEvent(); this._reset(); } ['_removedHook']() { this.unbindEvent(); if (this._mapVRenderer) { this._mapVRenderer.destroy(); this._mapVRenderer = null; } this.canvas.parentElement.removeChild(this.canvas); } ['initDevicePixelRatio']() { this.devicePixelRatio = 0x1 || 0x1; } ['bindEvent']() { var _0x3ce2ad; var _0x498282; this._map.on(mars3d__namespace.EventType.mouseDown, this._onMoveStartEvent, this); this._map.on(mars3d__namespace.EventType.cameraMoveStart, this._onMoveStartEvent, this); this._map.on(mars3d__namespace.EventType.cameraMoveEnd, this._onMoveEndEvent, this); if ((_0x3ce2ad = this.options) !== null && _0x3ce2ad !== undefined && (_0x3ce2ad = _0x3ce2ad.methods) !== null && _0x3ce2ad !== undefined && _0x3ce2ad.click) { this._map.on(mars3d__namespace.EventType.click, this._onMapClick, this); } if ((_0x498282 = this.options) !== null && _0x498282 !== undefined && (_0x498282 = _0x498282.methods) !== null && _0x498282 !== undefined && _0x498282.mousemove) { this._map.on(mars3d__namespace.EventType.mouseMove, this._onMapMouseMove, this); } } ['unbindEvent']() { var _0x44d725; var _0xec0e4a; this._map.off(mars3d__namespace.EventType.mouseDown, this._onMoveStartEvent, this); this._map.off(mars3d__namespace.EventType.cameraMoveStart, this._onMoveStartEvent, this); this._map.off(mars3d__namespace.EventType.cameraMoveEnd, this._onMoveEndEvent, this); this._map.off(mars3d__namespace.EventType.postRender, this._reset, this); if ((_0x44d725 = this.options) !== null && _0x44d725 !== undefined && (_0x44d725 = _0x44d725.methods) !== null && _0x44d725 !== undefined && _0x44d725.click) { this._map.off(mars3d__namespace.EventType.click, this._onMapClick, this); } if ((_0xec0e4a = this.options) !== null && _0xec0e4a !== undefined && (_0xec0e4a = _0xec0e4a.methods) !== null && _0xec0e4a !== undefined && _0xec0e4a.mousemove) { this._map.off(mars3d__namespace.EventType.mouseMove, this._onMapMouseMove, this); } } ["_onMoveStartEvent"]() { if (this._mapVRenderer) { this._mapVRenderer.animatorMovestartEvent(); this._map.off(mars3d__namespace.EventType.postRender, this._reset, this); this._map.on(mars3d__namespace.EventType.postRender, this._reset, this); } } ["_onMoveEndEvent"]() { if (this._mapVRenderer) { this._map.off(mars3d__namespace.EventType.postRender, this._reset, this); this._mapVRenderer.animatorMoveendEvent(); this._reset(); } } ['_setOptionsHook'](_0x4678bc, _0x3e2c62) { this._removedHook(); this._addedHook(); } ['addData'](_0x2384db) { if (this._mapVRenderer) { this._mapVRenderer.addData(_0x2384db, this.options); } } ["updateData"](_0x4baab4) { if (this._mapVRenderer) { this._mapVRenderer.updateData(_0x4baab4, this.options); } } ["getData"]() { if (this._mapVRenderer) { this.dataSet = this._mapVRenderer.getData(); } return this.dataSet; } ['removeData'](_0x14bf91) { if (this._mapVRenderer) { this._mapVRenderer.removeData(_0x14bf91); } } ['removeAllData']() { if (this._mapVRenderer) { this._mapVRenderer.clearData(); } } ['_createCanvas']() { const _0xabae54 = mars3d__namespace.DomUtil.create('canvas', 'mars3d-mapv', this._map.container); _0xabae54.id = this.id; _0xabae54.style.position = 'absolute'; _0xabae54.style.top = '0px'; _0xabae54.style.left = "0px"; _0xabae54.width = parseInt(this._map.canvas.width); _0xabae54.height = parseInt(this._map.canvas.height); _0xabae54.style.width = this._map.canvas.style.width; _0xabae54.style.height = this._map.canvas.style.height; _0xabae54.style.pointerEvents = this._pointerEvents ? "auto" : 'none'; _0xabae54.style.zIndex = this.options.zIndex ?? 0x9; if (this.options.context === '2d') { const _0x3a854b = this.devicePixelRatio; _0xabae54.getContext(this.options.context).scale(_0x3a854b, _0x3a854b); } return _0xabae54; } ["_reset"]() { this.resize(); this.render(); } ["draw"]() { this._reset(); } ['remove']() { if (this._mapVRenderer) { this._mapVRenderer.destroy(); this._mapVRenderer = null; } this.canvas.parentElement.removeChild(this.canvas); } ['render']() { this._mapVRenderer._canvasUpdate(); } ["resize"]() { if (this.canvas) { const _0x48d6 = this.canvas; _0x48d6.style.position = 'absolute'; _0x48d6.style.top = "0px"; _0x48d6.style.left = '0px'; _0x48d6.width = parseInt(this._map.canvas.width); _0x48d6.height = parseInt(this._map.canvas.height); _0x48d6.style.width = this._map.canvas.style.width; _0x48d6.style.height = this._map.canvas.style.height; } } ["getRectangle"](_0x2b1698) { if (!this.dataSet || !this.dataSet._data) { return; } const _0x114d2e = { type: 'FeatureCollection', features: this.dataSet._data }; const _0x4569b7 = mars3d__namespace.Util.getExtentByGeoJSON(_0x114d2e); if (!_0x4569b7) { return; } return _0x2b1698 !== null && _0x2b1698 !== undefined && _0x2b1698.isFormat ? _0x4569b7 : Cesium.Rectangle.fromDegrees(_0x4569b7.xmin, _0x4569b7.ymin, _0x4569b7.xmax, _0x4569b7.ymax); } ['_onMapClick'](_0x44e19c) { this._cache_event = _0x44e19c; // alert(1);
if (this._mapVRenderer) { this._mapVRenderer.clickEvent(_0x44e19c.windowPosition, _0x44e19c); } } ['_onMapMouseMove'](_0x59a0cf) { this._cache_event = _0x59a0cf; if (this._mapVRenderer) { this._mapVRenderer.mousemoveEvent(_0x59a0cf.windowPosition, _0x59a0cf); } } ['on'](_0x3a2096, _0x494636, _0x2f773d) { this.options.methods = this.options.methods || {}; if (_0x3a2096 === mars3d__namespace.EventType.click) { this.options.methods.click = _0x2d7a56 => { if (_0x2d7a56) { const _0xf52206 = { ...this._cache_event }; _0xf52206.layer = this; _0xf52206.data = _0x2d7a56; _0x494636.bind(_0x2f773d)(_0xf52206); } }; this._map.on(mars3d__namespace.EventType.click, this._onMapClick, this); } else if (_0x3a2096 === mars3d__namespace.EventType.mouseMove) { this.options.methods.mousemove = _0x46d7eb => { if (_0x46d7eb) { const _0x51132e = { ...this._cache_event }; _0x51132e.layer = this; _0x51132e.data = _0x46d7eb; _0x494636.bind(_0x2f773d)(_0x51132e); } }; this._map.on(mars3d__namespace.EventType.mouseMove, this._onMapMouseMove, this); } return this; } ['off'](_0x210b79, _0x6aa22a) { if (_0x210b79 === "click") { var _0x5b11c7; this._map.off(_0x210b79, this._onMapClick, this); if ((_0x5b11c7 = this.options.methods) !== null && _0x5b11c7 !== undefined && _0x5b11c7.mousemove) { delete this.options.methods.click; } } else { if (_0x210b79 === 'mouseMove') { var _0x4bcab2; this._map.off(_0x210b79, this._onMapMouseMove, this); if ((_0x4bcab2 = this.options.methods) !== null && _0x4bcab2 !== undefined && _0x4bcab2.mousemove) { delete this.options.methods.mousemove; } } } return this; } } mars3d__namespace.LayerUtil.register("mapv", MapVLayer); mars3d__namespace.layer.MapVLayer = MapVLayer; mars3d__namespace.mapv = mapv__namespace; exports.MapVLayer = MapVLayer; Object.keys(mapv).forEach(function (_0x122543) { if (_0x122543 !== "default" && !exports.hasOwnProperty(_0x122543)) { Object.defineProperty(exports, _0x122543, { 'enumerable': true, 'get': function () { return mapv[_0x122543]; } }); } }); const _0x3b352c = { value: true }; Object.defineProperty(exports, '__esModule', _0x3b352c);});
|