import request from '@/api/request'
|
import bus from './bus'
|
import { intensity, getbounds, createPic, picurl } from "@/api/http";
|
import { Message, Loading } from 'element-ui';
|
import data from "../utils/data.json"
|
import Vue from 'vue';
|
import poiLayer from '@/components/common/test'
|
|
|
//白膜
|
export function loadBaimo(num) {
|
//上海小面积白膜
|
let url1 = "http://183.162.245.49:8099/SHdata/SH_CLIP_BM/tileset.json"
|
let url12 = "http://183.162.245.49:8099/SHdata/LJZ_JM_BM1/tileset.json"
|
|
//广州精模 2 3 4
|
let url2 = "http://183.162.245.49:82/SG/b3dm/part1.412787/tileset.json"
|
let url3 = "http://183.162.245.49:82/SG/b3dm/_3.412788/tileset.json"
|
let url4 = "http://183.162.245.49:82/SG/b3dm/_2.413191/tileset.json"
|
|
let url6 = "http://183.162.245.49:8099/SHdata/GZ_BM_3DTILE1/tileset.json"//广州白膜
|
|
|
let url7 = "http://183.162.245.49:8099/SHdata/LJZJM3DTILES/tileset.json"//上海手工精模
|
|
|
let url8 = "http://183.162.245.49:8099/SHdata/SHQX_3dtiles/3dtiles/tileset.json"//飞飞上海倾斜
|
|
|
let url9 = "http://183.162.245.49:8099/SHdata/GZ_TH_3DTILE/tileset.json"//广州精模(天河)
|
let url10 = "http://183.162.245.49:8099/SHdata/GZ_fujia_2/tileset.json"//广州精模(天河)
|
let url11 = "http://183.162.245.49:8099/SHdata/GZ_fujia_3/tileset.json"//广州精模(天河)
|
|
switch (num) {
|
case 1:
|
window.model1 = sgworld.Creator.create3DTilesets("", url1, {}, {
|
}, "0", true, (data) => {
|
});
|
window.model12 = sgworld.Creator.create3DTilesets("", url12, {}, {
|
|
}, "0", true, (data) => {
|
});
|
break;
|
case 2:
|
window.model8 = sgworld.Creator.create3DTilesets("", url8, {}, {
|
}, "0", true, (data) => {
|
});
|
break;
|
case 3:
|
window.model7 = sgworld.Creator.create3DTilesets("", url7, {}, {
|
}, "0", true, (data) => {
|
});
|
break;
|
case 4:
|
window.model9 = sgworld.Creator.create3DTilesets("", url9, {}, {
|
}, "0", true, (data) => {
|
});
|
window.model10 = sgworld.Creator.create3DTilesets("", url10, {}, {
|
}, "0", true, (data) => {
|
});
|
window.model11 = sgworld.Creator.create3DTilesets("", url11, {}, {
|
}, "0", true, (data) => {
|
});
|
break;
|
case 5:
|
window.model2 = sgworld.Creator.create3DTilesets("", url2, {}, {
|
}, "0", true, (data) => {
|
});
|
window.model3 = sgworld.Creator.create3DTilesets("", url3, {}, {
|
}, "0", true, (data) => {
|
});
|
window.model4 = sgworld.Creator.create3DTilesets("", url4, {}, {
|
}, "0", true, (data) => {
|
});
|
break;
|
case 6:
|
window.model6 = sgworld.Creator.create3DTilesets("", url6, {}, {
|
|
}, "0", true, (data) => {
|
});
|
break;
|
// case 7:
|
// window.model13= sgworld.Creator.create3DTilesets("", url13, {}, {
|
|
// }, "0", true, (data) => {
|
// });
|
// window.model14= sgworld.Creator.create3DTilesets("", url14, {}, {
|
|
// }, "0", true, (data) => {
|
// });
|
// window.model15= sgworld.Creator.create3DTilesets("", url15, {}, {
|
|
// }, "0", true, (data) => {
|
// });
|
// break;
|
default:
|
break;
|
}
|
//初始添加注记
|
|
}
|
//水系
|
//点
|
window.deleteObj = []
|
export function loaddian(urls, name, height) {
|
var data = {
|
font_family: "微软雅黑",
|
font_size: 16,
|
pointHeight: height,
|
showBackground: true,
|
text: name,
|
fillColor: "#00ffff",
|
outlineColor: "#000000",
|
outlineWidth: 2,
|
disableDepthTestDistance: Infinity,
|
near: 0,
|
far: 2000,
|
};
|
let dx = sgworld.Creator.createLabelPointGeoJsonFeatureLayer("", urls, data, "0", true)
|
//
|
window.deleteObj.push(dx)
|
|
}
|
//路网
|
export function loadLW() {
|
var urls = "http://183.162.245.49:8099/gisserver/tmsserver/SH_peitu"
|
var layer = sgworld.Creator.createUrlTemplateImageryProvider('tms服务', {
|
url: Cesium.buildModuleUrl(urls + "/{z}/{x}/{reverseY}.png"),
|
Level: 15
|
}, '0', undefined, true, "");
|
var urls1 = "http://183.162.245.49:8099//gisserver/tmsserver/SH_sj"
|
var layer1 = sgworld.Creator.createUrlTemplateImageryProvider('tms服务', {
|
url: Cesium.buildModuleUrl(urls1 + "/{z}/{x}/{reverseY}.png"),
|
Level: 6
|
}, '0', undefined, true, "");
|
}
|
//聚合效果
|
export function juhe(params, name) {
|
var url;
|
var billboardImage;
|
var jhtype;
|
var dataSource;
|
if (name === "监测站") {
|
url = "http://221.224.53.36:9080/gis/monitor/stations";
|
billboardImage = "./static/img/jcz.png";
|
jhtype = 'GET';
|
dataSource = new Cesium.CustomDataSource("jcz");
|
} else if (name === "系统台站") {
|
url = "http://221.224.53.36:9080/map/searchRsbtStn";
|
billboardImage = "./static/img/blue.png";
|
jhtype = 'POST';
|
dataSource = new Cesium.CustomDataSource("xttz");
|
} else if (name === "测试台站") {
|
|
}
|
if (!params) {
|
if (name === "系统台站") {
|
var ds = viewer.dataSources.getByName("xttz");
|
if (ds.length > 0) {
|
for (var i = 0; i < ds.length; i++) {
|
viewer.dataSources.remove(ds[i]);
|
|
}
|
}
|
} else if (name === "监测站") {
|
var jcz = viewer.dataSources.getByName("jcz");
|
if (jcz.length > 0) {
|
for (var i = 0; i < jcz.length; i++) {
|
viewer.dataSources.remove(jcz[i]);
|
|
}
|
}
|
if (window.modelList.length > 0) {
|
for (var j = 0; j < window.modelList.length; j++) {
|
window.modelList[j].deleteObject();
|
}
|
}
|
}
|
|
} else {
|
|
var dataSourcePromise = viewer.dataSources.add(dataSource);
|
$.ajax({
|
|
url: url,
|
contentType: 'application/json;charset=UTF-8',
|
type: jhtype,
|
dataType: 'json',
|
data: JSON.stringify({ "freqRfb": 87, "freqRfe": 108 }),
|
success: function (data) {
|
if (data.message == "Success") {
|
data.rows.forEach((item) => {
|
if (item.statName) {
|
item.dataType = "XXTZ";
|
var pixelO = (item.statName.length / 2 * 20)
|
dataSource.entities.add(new Cesium.Entity({
|
position: Cesium.Cartesian3.fromDegrees(item.statLg, item.statLa, 500),
|
label: {
|
showBackground: true,
|
backgroundColor: new Cesium.Color.fromCssColorString("#000").withAlpha(0.3),
|
text: item.statName,
|
font: "15px Helvetica",
|
fillColor: Cesium.Color.fromCssColorString("#FCFF00"), pixelOffset: new Cesium.Cartesian2(pixelO, 0),
|
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
distanceDisplayCondition: new Cesium.DistanceDisplayCondition(10, 1000000)
|
},
|
billboard: {
|
image: billboardImage,
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
width: 30, // default: undefined
|
height: 30,
|
distanceDisplayCondition: new Cesium.DistanceDisplayCondition(10, 1000000)
|
|
},
|
properties: item,
|
}));
|
} else if (item.monstationName) {
|
item.dataType = "JCZ";
|
var gltfurl = "./static/gltf/JCZ.glb";
|
let x = item.monstationLg, y = item.monstationLa
|
let z = 25
|
var position = new Cesium.Cartesian3.fromDegrees(x, y, 0);
|
if (item.monstationName == "云海") {
|
x = 121.444697
|
y = 31.213850
|
gltfurl = "./static/gltf/gdjcz.glb";
|
position = new Cesium.Cartesian3.fromDegrees(121.444697, 31.213850, 88.5);
|
z = 110
|
}
|
loadGLTF(gltfurl, position)
|
var pixelO = (item.monstationName.length / 2 * 20) + 35
|
dataSource.entities.add(new Cesium.Entity({
|
position: Cesium.Cartesian3.fromDegrees(x, y, z),
|
label: {
|
showBackground: true,
|
backgroundColor: new Cesium.Color.fromCssColorString("#000").withAlpha(0.3),
|
text: item.monstationName,
|
font: "15px Helvetica",
|
fillColor: Cesium.Color.fromCssColorString("#00FFEA"),
|
pixelOffset: new Cesium.Cartesian2(pixelO, 0),
|
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
distanceDisplayCondition: new Cesium.DistanceDisplayCondition(10, 1000000)
|
},
|
billboard: {
|
image: billboardImage,
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
width: 40, // default: undefined
|
height: 40,
|
distanceDisplayCondition: new Cesium.DistanceDisplayCondition(10, 1000000)
|
|
},
|
properties: item,
|
}));
|
}
|
|
|
})
|
}
|
}
|
})
|
dataSourcePromise.then(function (dataSource) {
|
const pixelRange = 25;
|
const minimumClusterSize = 3;
|
const enabled = true;
|
dataSource.clustering.enabled = enabled;
|
dataSource.clustering.pixelRange = pixelRange;
|
dataSource.clustering.minimumClusterSize = minimumClusterSize;
|
let removeListener;
|
const gradient = {
|
0.0001: Cesium.Color.DEEPSKYBLUE,
|
0.001: Cesium.Color.WHITE,
|
0.01: Cesium.Color.ORANGE,
|
0.1: Cesium.Color.RED
|
};
|
function customStyle() {
|
if (Cesium.defined(removeListener)) {
|
removeListener();
|
removeListener = undefined;
|
} else {
|
removeListener = dataSource.clustering.clusterEvent.addEventListener(
|
function (clusteredEntities, cluster) {
|
cluster.billboard.show = true;
|
// cluster.billboard.disableDepthTestDistance = Number.POSITIVE_INFINITY;
|
// cluster.label.font = `bold 12px sans-serif`;
|
cluster.label.font = `12px sans-serif`;
|
cluster.label.fillColor = new Cesium.Color.fromCssColorString("#fff");
|
cluster.label.disableDepthTestDistance = Number.POSITIVE_INFINITY;
|
let allCount = dataSource.entities.values.length || 0
|
for (let key in gradient) {
|
if (clusteredEntities.length >= allCount * key) {
|
let numLength = String(clusteredEntities.length).length
|
cluster.billboard.image = _drawCircle(
|
gradient[key],
|
numLength
|
)
|
cluster.label.show = true
|
if (numLength === 1) {
|
cluster.label.pixelOffset = new Cesium.Cartesian2(-2, 3)
|
} else {
|
cluster.label.pixelOffset = new Cesium.Cartesian2(
|
-5 * (numLength - 1),
|
5
|
)
|
}
|
} else if (clusteredEntities.length <= 1) {
|
cluster.label.show = false
|
}
|
}
|
}
|
);
|
}
|
// force a re-cluster with the new styling
|
const pixelRange = dataSource.clustering.pixelRange;
|
dataSource.clustering.pixelRange = 0;
|
dataSource.clustering.pixelRange = pixelRange;
|
}
|
var _cache = {};
|
function _drawCircle(color, numLength) {
|
let size = 18 * (numLength + 1)
|
let key = color.toCssColorString() + '-' + size
|
if (!_cache[key]) {
|
let canvas = document.createElement('canvas')
|
canvas.width = size
|
canvas.height = size
|
let context2D = canvas.getContext('2d')
|
context2D.save()
|
context2D.scale(size / 24, size / 24) //Added to auto-generated code to scale up to desired size.
|
context2D.fillStyle = color.withAlpha(0.2).toCssColorString() //Modified from auto-generated code.
|
context2D.beginPath()
|
context2D.arc(12, 12, 9, 0, 2 * Math.PI)
|
context2D.closePath()
|
context2D.fill()
|
context2D.beginPath()
|
context2D.arc(12, 12, 6, 0, 2 * Math.PI)
|
context2D.fillStyle = color.toCssColorString()
|
context2D.fill()
|
context2D.closePath()
|
context2D.restore()
|
_cache[key] = canvas.toDataURL()
|
}
|
return _cache[key]
|
}
|
// start with custom style
|
customStyle();
|
});
|
|
}
|
|
|
}
|
//创建glb模型
|
window.modelList = [];
|
export function loadGLTF(url, position) {
|
var model = sgworld.Creator.addSimpleGraphic('model', {
|
url: url,
|
position: position,
|
removeEdit: true // 屏蔽全局标绘编辑功能
|
});
|
window.modelList.push(model)
|
//viewer.trackedEntity = model;
|
}
|
window.showtable = false;
|
let timeoutID
|
let handlerMes
|
export function addMouseEvent() {
|
//点击获取信息
|
handlerMes ? handlerMes.destroy() : ""
|
handlerMes = new Cesium.ScreenSpaceEventHandler(
|
window.Viewer.scene.canvas
|
);
|
handlerMes.setInputAction(function (movement) {
|
if (window.JCZlist.length > 0) {
|
for (var j = 0; j < window.JCZlist.length; j++) {
|
viewer.entities.removeById(window.JCZlist[j].id);
|
}
|
|
}
|
var pick = window.Viewer.scene.pick(movement.position);
|
clearTimeout(timeoutID);
|
timeoutID = window.setTimeout(function () {
|
if (!window.showtable) {
|
} else {
|
bus.$emit("isFX", true)
|
if (Cesium.defined(pick) && pick.id && pick.id.properties) {
|
window.objform.monstationGuid = pick.id.properties._monstationGuid._value;
|
let data = [
|
window.objform
|
]
|
showdataJCZ(data)
|
}
|
}
|
}, 200);
|
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
var divPoint3;
|
handlerMes.setInputAction(function (movement) {
|
clearTimeout(timeoutID);
|
if (divPoint3) {
|
divPoint3.deleteObject();
|
}
|
|
var pick = window.Viewer.scene.pick(movement.position);
|
if (Cesium.defined(pick) && pick.id && pick.id.properties) {
|
var prophtml = setEpidemicLayerInfoDomtj(pick.id.properties);
|
setInterval(function () {
|
$("body .closeclick").on("click", () => {
|
debugger
|
document.getElementsByClassName("tableContain")[0].style.display =
|
"none";
|
});
|
}, 1000);
|
if (pick.id.properties.statLg && pick.id.properties.statLa) {
|
var lng = pick.id.properties.statLg._value;
|
var lat = pick.id.properties.statLa._value;
|
} else if (pick.id.properties.monstationLg && pick.id.properties.monstationLa) {
|
var lng = pick.id.properties.monstationLg._value;
|
var lat = pick.id.properties.monstationLa._value;
|
}
|
if (pick.id.properties && pick.id.properties._monstationName && pick.id.properties._monstationName._value == "云海") {
|
lng = 121.444697
|
lat = 31.213850
|
}
|
if (movement.position)
|
divPoint3 = sgworld.Creator.createDivPoint('', { lon: lng, lat: lat, height: 105 }, {
|
type: "custom",
|
offset: ["c", 20],
|
description: prophtml,
|
near: 0,
|
far: 100000
|
});
|
}
|
|
}, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)
|
|
}
|
|
//抽离监测站图例创建事件
|
export function showdataJCZ(data) {
|
const loading = Loading.service({
|
lock: true,
|
text: "计算中",
|
spinner: "el-icon-loading",
|
background: "rgba(0, 0, 0, 0.7)",
|
});
|
MonitoringStation(data).then((res) => {
|
if (res.message === "Success") {
|
var positions = res.data.countorResVOList[0].points;
|
var value = res.data.countorResVOList[0].areaResult
|
var positionsList = [];
|
for (var i = 0; i < positions.length; i++) {
|
positionsList.push(positions[i].lon, positions[i].lat);
|
}
|
let obj = {
|
name: window.analysisType,
|
value: value
|
}
|
bus.$emit("newData", obj)
|
createPloygon(positionsList);
|
loading.close();
|
}
|
}).catch((error) => {
|
loading.close();
|
});
|
}
|
//开启平行光
|
export function light() {
|
Viewer.scene.light = new Cesium.DirectionalLight({
|
direction: new Cesium.Cartesian3(0, 0, -1),
|
});
|
}
|
//右击事件
|
export function addRightMouseEvent() {
|
//点击获取信息
|
let handler = new Cesium.ScreenSpaceEventHandler(
|
window.Viewer.scene.canvas
|
);
|
//获取html文件
|
let PoiLayerConstructor = Vue.extend(poiLayer);
|
let instance = new PoiLayerConstructor({
|
data: {
|
btnlist: [
|
{
|
name: "场强范围",
|
value: false,
|
},
|
{
|
name: "黑广播",
|
value: false,
|
},
|
{
|
name: "伪基站覆盖范围",
|
value: false,
|
},
|
],
|
}
|
});
|
instance.$mount();
|
let prophtml = instance.$el
|
|
|
|
|
handler.setInputAction(function (movement) {
|
if (window.divPoint4) {
|
window.divPoint4.deleteObject();
|
}
|
//清除之前监测站事件
|
if (window.JCZlist.length > 0) {
|
for (var j = 0; j < window.JCZlist.length; j++) {
|
viewer.entities.removeById(window.JCZlist[j].id);
|
}
|
|
}
|
//重置或者得到pick中的值
|
window.pick = window.Viewer.scene.pick(movement.position);
|
if (Cesium.defined(pick) && pick.id && pick.id.properties) {
|
window.showtable = true
|
let position = pick.id.position.getValue()
|
let degrees = sgworld.Core.toDegrees(position)
|
if (pick.id.properties.dataType._value == "JCZ") {
|
// let prophtml = createHtmlRight("黑广播")
|
window.divPoint4 = sgworld.Creator.createDivPoint('', { lon: degrees.lon, lat: degrees.lat, height: degrees.height }, {
|
type: "custom",
|
offset: ["c", 20],
|
description: prophtml,
|
near: 0,
|
far: 50000,
|
});
|
}
|
} else {
|
try {
|
window.divPoint4.deleteObject();
|
window.showtable = false
|
} catch (e) { }
|
}
|
}, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
|
}
|
// 监测站覆盖评估
|
export function MonitoringStation(data) {
|
return request({
|
url: 'calc/stationCover',
|
method: 'POST',
|
data: data
|
})
|
}
|
window.JCZlist = [];
|
export function createPloygon(pos) {
|
viewer.scene.globe.depthTestAgainstTerrain = false;
|
var poly = viewer.entities.add({
|
name: "JCZ",
|
polygon: {
|
hierarchy: Cesium.Cartesian3.fromDegreesArray(pos),
|
extrudedHeight: 1,
|
material: Cesium.Color.DARKSALMON.withAlpha(0.3),
|
outline: false,
|
outlineColor: Cesium.Color.RED,
|
arcType: Cesium.ArcType.RHUMB,
|
},
|
polyline: {
|
positions: Cesium.Cartesian3.fromDegreesArray(pos),
|
width: 2,
|
material: Cesium.Color.RED
|
}
|
});
|
window.JCZlist.push(poly);
|
|
}
|
//右击按钮
|
export function createHtmlRight(data) {
|
var html = ``;
|
html += `<div class="showRightClickBtn">`
|
html += `<button type="button">${data}</button>`
|
html += `</div>`
|
return html;
|
}
|
//监测站弹框
|
export function setEpidemicLayerInfoDomtj(marker) {
|
let tablename, tablevalue
|
if (marker.dataType._value == "XXTZ") {
|
tablename = ["台站名称", "台站位置", "天线高度(m)", "经度[°]", "维度[°]", "接收起始频率[MHz]", "接受结束频率[MHz]", "发射起始频率[MHz]", "发射结束频率[MHz]", "功率[dBm]"]
|
tablevalue = ["statName", "statAddr", "antHight", "statLg", "statLa", "freqUc", "freqEfb", "freqEfe", "freqEfe", "equPow"]
|
}
|
if (marker.dataType._value == "JCZ") {
|
tablename = ["监测设施", "监测设备", "覆盖半径(km)", "设备型号", "设备名称", "经度[°]", "维度[°]", "监测站位置",]
|
tablevalue = ["monstationName", "monstationEquName", "monstationLa", "monstationType", "monstationEquName", "monstationLg", "monstationLa", "monstationName"]
|
}
|
var html = ``;
|
html += `<div class="tableContain">`
|
html += `<div class="closeclick" >X</div>`
|
html += `<div class="tableinner">`
|
html += `<table id="mytable" cellspacing="0">
|
<caption> </caption> `;
|
if (marker.propertyNames) {
|
for (var i = 0; i < tablename.length; i++) {
|
html += `<tr>
|
<td class="row">`+ tablename[i] + `</td>
|
<td class="row">`+ marker[tablevalue[i]]._value + `</td>
|
</tr>`
|
|
}
|
} else {
|
for (var item in marker) {
|
html += `<tr>
|
<td class="row">`+ item + `</td>
|
<td class="row">`+ marker[item] + `</td>
|
</tr>`
|
}
|
}
|
html += `</table>`;
|
html += `</div>`
|
html += `</div>`
|
|
|
return html;
|
|
}
|
// mpt地形
|
let mptYx
|
export function addMpt(bollean) {
|
if (bollean) {
|
mptYx ? mptYx.deleteObject() : "";
|
mptYx = null
|
var option = {
|
url: "http://183.162.245.49:82/SG/Elevation",
|
layerName: "gz0920.414509",
|
requestVertexNormals: true,
|
};
|
mptYx = sgworld.Creator.sfsterrainprovider("", option, "", true, "");
|
} else {
|
mptYx ? mptYx.deleteObject() : "";
|
mptYx = null
|
return
|
}
|
}
|
|
//监听按钮事件
|
let status
|
export function SPPM() {
|
tedp.trame.subStyle = {
|
left: "1446px",
|
top: "2100px"
|
}
|
window.addEventListener("keydown",
|
(event) => {
|
if (event.keyCode === 122) {
|
event.preventDefault();
|
var el = document.documentElement;
|
var rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen;//定义不同浏览器的全屏API
|
//执行全屏
|
if (typeof rfs != "undefined" && rfs) {
|
rfs.call(el);
|
} else if (typeof window.ActiveXObject != "undefined") {
|
var wscript = new ActiveXObject("WScript.Shell");
|
if (wscript != null) {
|
wscript.SendKeys("{F11}");
|
}
|
}
|
|
//监听不同浏览器的全屏事件,并件执行相应的代码
|
document.addEventListener("webkitfullscreenchange", function () {//
|
if (document.webkitIsFullScreen) {
|
//全屏后要执行的代码
|
tedp.trame.subStyle = {
|
left: "1446px",
|
top: "2420px"
|
}
|
document.getElementsByClassName("container")[0].style.height = "2200px"
|
document.getElementsByClassName("containerBtn")[0].style.top = "2300px"
|
status = false
|
} else {
|
tedp.trame.subStyle = {
|
left: "1446px",
|
top: "2120px"
|
}
|
//退出全屏后执行的代码
|
document.getElementsByClassName("container")[0].style.height = "1900px"
|
document.getElementsByClassName("containerBtn")[0].style.top = "1980px"
|
}
|
}, false);
|
}
|
}, true)
|
}
|