import { time } from 'echarts';
|
import mapServer from './mapServe';
|
|
const menuManager = {
|
pid: null,
|
pointFly: null,
|
particle: null,
|
AnalysisFlood: null,
|
modelLayer: null,
|
regionWeather: null,
|
regionWeather: null,
|
colorAll: {
|
point: SmartEarth.Cesium.Color.fromCssColorString('#ff0000'),
|
polyline: SmartEarth.Cesium.Color.fromCssColorString('#ffff0050'),
|
polygon: SmartEarth.Cesium.Color.fromCssColorString('#ffff0050'),
|
},
|
init(res) {
|
switch (res.pid) {
|
case 's1': //配网巡检
|
return this.setMenuS1(res);
|
break;
|
case 's2': //配网运检
|
return this.setMenuS2(res);
|
break;
|
case 's3': //配网灾害管理
|
return this.setMenuS3(res);
|
break;
|
case 's4': //图层管理
|
return this.setMenuS4(res);
|
break;
|
case 's5': //漫游
|
return this.setMenuS5(res);
|
break;
|
case 's6': //定位
|
return this.setMenuS6(res);
|
break;
|
case 's7': //标绘
|
return this.setMenuS7(res);
|
break;
|
case 's8': //测量
|
return this.setMenuS8(res);
|
break;
|
case 's9': //特效
|
return this.setMenuS9(res);
|
break;
|
}
|
},
|
//配网巡检
|
setMenuS1(res) {
|
switch (res.id) {
|
case 'a1':
|
return res.name;
|
break;
|
default:
|
return null;
|
break;
|
}
|
},
|
// 配网运检
|
setMenuS2(res) {
|
switch (res.id) {
|
case 'a1':
|
case 'a2':
|
return res.name;
|
break;
|
default:
|
return null;
|
break;
|
}
|
},
|
handlerClick(res) {
|
var that = this;
|
var handler = new Cesium.ScreenSpaceEventHandler(Viewer.scene.canvas);
|
handler.setInputAction((event) => {
|
let cartesian = Viewer.camera.pickEllipsoid(event.position);
|
let cartographic = Cesium.Cartographic.fromCartesian(cartesian);
|
|
if (cartesian) {
|
let lng = parseFloat(Cesium.Math.toDegrees(cartographic.longitude)).toFixed(6); // 经度
|
let lat = parseFloat(Cesium.Math.toDegrees(cartographic.latitude)).toFixed(6); // 纬度
|
var alt = Viewer.camera.positionCartographic.height.toFixed(0);
|
if (res == 'a2') {
|
that.setCreateFireAnalysis(lng, lat, alt);
|
} else if (res == 'a4') {
|
that.setCreateRainAnalysis(lng, lat, alt);
|
} else if (res == 'a5') {
|
that.setCreateSnowAnalysis(lng, lat, alt);
|
}
|
}
|
handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
},
|
getModelLayer() {
|
const obj = mapServer.layerList.filter((item) => {
|
if (item.id == 'baseModel') {
|
return time;
|
}
|
});
|
if (obj.length <= 0) return;
|
this.modelLayer = obj[0].layer;
|
},
|
setCreateRainAnalysis(lng, lat, alt) {
|
this.regionWeather = earthCtrl.factory.createRegionWeather({
|
primitive: this.modelLayer.item,
|
position: new SmartEarth.Cesium.Cartesian3.fromDegrees(lng, lat, 1000),
|
radius: 1000,
|
});
|
this.regionWeather.enableWeatherType = SmartEarth.Cesium.RegionWeather.TYPE_RAIN;
|
this.regionWeather.regionAlpha = 0.6;
|
this.regionWeather.regionGradientDistance = 300;
|
},
|
setCreateSnowAnalysis(lng, lat, alt) {
|
this.regionWeather = earthCtrl.factory.createRegionWeather({
|
primitive: this.modelLayer.item,
|
position: new SmartEarth.Cesium.Cartesian3.fromDegrees(lng, lat, 1000),
|
radius: 1000,
|
});
|
this.regionWeather.enableWeatherType = SmartEarth.Cesium.RegionWeather.TYPE_SNOW;
|
this.regionWeather.regionAlpha = 0.8;
|
this.regionWeather.regionGradientDistance = 300;
|
},
|
setClearMenuS3() {
|
if (this.particle) {
|
this.particle.remove();
|
this.particle = null;
|
}
|
if (this.AnalysisFlood) {
|
this.AnalysisFlood.endWater();
|
this.AnalysisFlood = undefined;
|
}
|
if (this.regionWeather) {
|
this.regionWeather.enableWeatherType = SmartEarth.Cesium.RegionWeather.TYPE_NONE;
|
}
|
},
|
// 灾害管理
|
setMenuS3(res) {
|
switch (res.id) {
|
case 'a1':
|
return res.name;
|
break;
|
case 'a2':
|
if (this.particle) {
|
this.particle.remove();
|
this.particle = null;
|
return;
|
}
|
this.handlerClick(res.id);
|
|
break;
|
case 'a3':
|
if (this.AnalysisFlood) {
|
this.AnalysisFlood.endWater();
|
this.AnalysisFlood = undefined;
|
return;
|
}
|
var url = SmartEarthRootUrl + 'Workers/image/33.gif';
|
const method = {
|
pointSelect: true, // rectangle: 'rectangle',
|
spood: 20,
|
GroupID: 0,
|
url: url,
|
};
|
this.AnalysisFlood = earthCtrl.analysis.createSubmergence(method, (value) => {});
|
break;
|
case 'a4':
|
if (!this.modelLayer) {
|
this.getModelLayer();
|
}
|
this.handlerClick(res.id);
|
break;
|
|
case 'a5':
|
if (!this.modelLayer) {
|
this.getModelLayer();
|
}
|
this.handlerClick(res.id);
|
break;
|
case 'a6':
|
this.setClearMenuS3();
|
break;
|
default:
|
return null;
|
break;
|
}
|
},
|
setCreateFireAnalysis(lon, lat, alt) {
|
this.particle = earthCtrl.factory.createParticleEffect(
|
'flame',
|
{
|
x: lon,
|
y: lat,
|
z: 0,
|
},
|
{
|
translation: SmartEarth.Cesium.Cartesian3.fromElements(0, 0, 0), //平移
|
},
|
(data) => {}
|
);
|
},
|
//图层管理
|
setMenuS4(res) {
|
switch (res.id) {
|
case 'a1':
|
return res.name;
|
break;
|
default:
|
return null;
|
break;
|
}
|
},
|
// 漫游
|
setMenuS5(res) {
|
switch (res.id) {
|
case 'a1':
|
if (this.pointFly) {
|
this.pointFly.removeFromMap();
|
} else {
|
earthCtrl.factory.createSimpleGraphic('billboard', {}, (entity) => {
|
const position = entity.position.getValue();
|
const coordinate = earthCtrl.core.toDegrees(position);
|
this.pointFly = earthCtrl.camera.rotateCamera({
|
lon: coordinate.lon,
|
lat: coordinate.lat,
|
distance: 1000,
|
pitch: -30,
|
});
|
});
|
}
|
return null;
|
break;
|
case 'a2':
|
return res.name;
|
break;
|
case 'a3':
|
earthCtrl.analysis.createIndoormode({ showHelp: true });
|
return null;
|
break;
|
|
default:
|
return null;
|
break;
|
}
|
},
|
// 定位
|
setMenuS6(res) {
|
switch (res.id) {
|
case 'a1':
|
return res.name;
|
break;
|
default:
|
return null;
|
break;
|
}
|
},
|
// 标绘
|
setMenuS7(res) {
|
switch (res.id) {
|
case 'a1':
|
earthCtrl.factory.createSimpleGraphic('point', {}, (entity) => {});
|
break;
|
case 'a2':
|
earthCtrl.factory.createSimpleGraphic('label', {}, (entity) => {});
|
break;
|
case 'a3':
|
earthCtrl.factory.createSimpleGraphic('polyline', { showSize: false }, (entity) => {
|
const obj = this.getWKtCoord(entity.polyline.positions.getValue());
|
console.log('polyline Wkt:' + obj);
|
});
|
break;
|
case 'a4':
|
earthCtrl.factory.createSimpleGraphic('rectangle', { showSize: false }, (entity) => {});
|
break;
|
case 'a5':
|
earthCtrl.factory.createSimpleGraphic('polygon', { showSize: false }, (entity) => {
|
const obj = this.getWKtCoord(entity.polygon.hierarchy.getValue().positions);
|
console.log('polygon Wkt:' + obj);
|
});
|
break;
|
case 'a6':
|
earthCtrl.factory.SimpleGraphic.clear();
|
break;
|
default:
|
break;
|
}
|
return null;
|
},
|
getWKtCoord(obj) {
|
var ellipsoid = Viewer.scene.globe.ellipsoid;
|
var std = [];
|
for (var i in obj) {
|
// 将世界坐标转换为地理坐标(Cartographic)
|
var cartographic = ellipsoid.cartesianToCartographic(obj[i]);
|
// 获取经纬度
|
var longitude = Cesium.Math.toDegrees(cartographic.longitude);
|
var latitude = Cesium.Math.toDegrees(cartographic.latitude);
|
var height = 0;
|
std.push([longitude, latitude, height]);
|
}
|
return std;
|
},
|
// 测量
|
setMenuS8(res) {
|
const colorAll = this.colorAll;
|
switch (res.id) {
|
case 'a1':
|
earthCtrl.measure.clampLineDistance(colorAll, (e) => {});
|
break;
|
case 'a2':
|
earthCtrl.measure.altitude(colorAll, (e) => {});
|
break;
|
case 'a3':
|
earthCtrl.measure.surfaceArea(
|
{
|
...colorAll,
|
tin: true, // 是否显示tin三角网
|
onlyTerrain: false, // 是否只测量精细地形
|
},
|
(e) => {}
|
);
|
break;
|
case 'a4':
|
earthCtrl.measure.planeArea(colorAll, (e) => {});
|
break;
|
case 'a5':
|
earthCtrl.measure.horizontalDistance(colorAll, (e) => {});
|
break;
|
case 'a6':
|
earthCtrl.measure.clearResult();
|
break;
|
}
|
},
|
// 特效
|
setMenuS9(res) {
|
switch (res.id) {
|
case 'a1':
|
return res.name;
|
break;
|
case 'a2':
|
earthCtrl.factory.createScreenshot();
|
break;
|
default:
|
return null;
|
break;
|
}
|
},
|
};
|
export default menuManager;
|