c1cc48da by jikai

111111

1 parent 23da76d8
......@@ -4,20 +4,14 @@ export default class flood {
this.positions2d = [];
this.handlerPolygon = new Cesium.DrawHandler(objectManage.viewer, Cesium.DrawMode.Polygon);
this.handlerPolygon.drawEvt.addEventListener(polygon => {
var array = [].concat(polygon.object.positions), positions = [];
var array = [].concat(polygon.object.positions);
for(var i = 0, len = array.length; i < len; i++){
var cartographic = Cesium.Cartographic.fromCartesian(array[i]);
var longitude = Cesium.Math.toDegrees(cartographic.longitude);
var latitude = Cesium.Math.toDegrees(cartographic.latitude);
var h=cartographic.height;
if(positions.indexOf(longitude)===-1&&positions.indexOf(latitude)===-1){
positions.push(longitude);
positions.push(latitude);
positions.push(h);
this.positions2d.push(longitude);
this.positions2d.push(latitude);
this.positions2d.push(1000.0);
}
this.positions2d.push(longitude);
this.positions2d.push(latitude);
this.positions2d.push(cartographic.height);
}
});
}
......@@ -70,11 +64,19 @@ export default class flood {
}
});
}
floodParse(positions2d, waterHeight, targetHeight) {
var River1 = new Cesium.Primitive({
floodParse(waterHeight, targetHeight) {
!this.positions2d.length && (this.positions2d = [
116.44391163897568, 39.922128887755996, 10,
116.47222524452756, 39.921663337343915, 10,
116.47147655687662, 39.903608069115315, 10,
116.44520545789665, 39.902556426686864, 10,
116.44515353439972, 39.90683243165845, 10,
116.4437677267605, 39.9069642145195, 10
]);
this.river = new Cesium.Primitive({
geometryInstances : new Cesium.GeometryInstance({
geometry :new Cesium.PolygonGeometry({
polygonHierarchy : new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArrayHeights(positions2d)),
polygonHierarchy : new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArrayHeights(this.positions2d)),
extrudedHeight: targetHeight,
height: waterHeight,
vertexFormat : Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT
......@@ -96,6 +98,10 @@ export default class flood {
}),
show : true
});
objectManage.viewer.scene.primitives.add(River1);
objectManage.viewer.scene.primitives.add(this.river);
}
remove() {
this.positions2d = [];
objectManage.viewer.scene.primitives.remove(this.river);
}
}
\ No newline at end of file
......
import objectManage from './maputils';
export default class viewpoint {
constructor() {
console.log(Cesium.Sightline);
this.sightline = new Cesium.Sightline(objectManage.viewer.scene);
this.sightline.couldRemove = false;
this.sightline.build();
......@@ -40,4 +38,10 @@ export default class viewpoint {
objectManage.viewer.scene.viewFlag = false;
this.handlerPoint.activate();
}
remove() {
this.sightline.destroy();
this.sightline = new Cesium.Sightline(objectManage.viewer.scene);
this.sightline.couldRemove = false;
this.sightline.build();
}
}
\ No newline at end of file
......
......@@ -57,11 +57,10 @@
},
startAnalysis() {
// this.isAnalysis = true;
this.viewpoint.chooseView();
},
stopAnalysis() {
// this.isAnalysis = false;
this.viewpoint.remove();
}
}
......
......@@ -69,7 +69,7 @@
step: 0.01,
num: 1,
sdgc: '', // 水底高程
swsd: '', // 水位深度
swsd: 50, // 水位深度
ymsd: '', // 淹没速度
isXmbj: true,
// isAnalysis: true
......@@ -86,11 +86,11 @@
},
startAnalysis() {
this.flood.floodParse(this.flood.positions2d, 0, 50);
this.flood.floodParse(0, this.swsd);
this.flood.handlerPolygon.clear();
},
stopAnalysis() {
objectManage.viewer.entities.removeAll();
this.flood.remove();
},
handleIsXmbj(flag) {
this.isXmbj = flag;
......