111111
Showing
4 changed files
with
28 additions
and
19 deletions
| ... | @@ -4,20 +4,14 @@ export default class flood { | ... | @@ -4,20 +4,14 @@ export default class flood { |
| 4 | this.positions2d = []; | 4 | this.positions2d = []; |
| 5 | this.handlerPolygon = new Cesium.DrawHandler(objectManage.viewer, Cesium.DrawMode.Polygon); | 5 | this.handlerPolygon = new Cesium.DrawHandler(objectManage.viewer, Cesium.DrawMode.Polygon); |
| 6 | this.handlerPolygon.drawEvt.addEventListener(polygon => { | 6 | this.handlerPolygon.drawEvt.addEventListener(polygon => { |
| 7 | var array = [].concat(polygon.object.positions), positions = []; | 7 | var array = [].concat(polygon.object.positions); |
| 8 | for(var i = 0, len = array.length; i < len; i++){ | 8 | for(var i = 0, len = array.length; i < len; i++){ |
| 9 | var cartographic = Cesium.Cartographic.fromCartesian(array[i]); | 9 | var cartographic = Cesium.Cartographic.fromCartesian(array[i]); |
| 10 | var longitude = Cesium.Math.toDegrees(cartographic.longitude); | 10 | var longitude = Cesium.Math.toDegrees(cartographic.longitude); |
| 11 | var latitude = Cesium.Math.toDegrees(cartographic.latitude); | 11 | var latitude = Cesium.Math.toDegrees(cartographic.latitude); |
| 12 | var h=cartographic.height; | ||
| 13 | if(positions.indexOf(longitude)===-1&&positions.indexOf(latitude)===-1){ | ||
| 14 | positions.push(longitude); | ||
| 15 | positions.push(latitude); | ||
| 16 | positions.push(h); | ||
| 17 | this.positions2d.push(longitude); | 12 | this.positions2d.push(longitude); |
| 18 | this.positions2d.push(latitude); | 13 | this.positions2d.push(latitude); |
| 19 | this.positions2d.push(1000.0); | 14 | this.positions2d.push(cartographic.height); |
| 20 | } | ||
| 21 | } | 15 | } |
| 22 | }); | 16 | }); |
| 23 | } | 17 | } |
| ... | @@ -70,11 +64,19 @@ export default class flood { | ... | @@ -70,11 +64,19 @@ export default class flood { |
| 70 | } | 64 | } |
| 71 | }); | 65 | }); |
| 72 | } | 66 | } |
| 73 | floodParse(positions2d, waterHeight, targetHeight) { | 67 | floodParse(waterHeight, targetHeight) { |
| 74 | var River1 = new Cesium.Primitive({ | 68 | !this.positions2d.length && (this.positions2d = [ |
| 69 | 116.44391163897568, 39.922128887755996, 10, | ||
| 70 | 116.47222524452756, 39.921663337343915, 10, | ||
| 71 | 116.47147655687662, 39.903608069115315, 10, | ||
| 72 | 116.44520545789665, 39.902556426686864, 10, | ||
| 73 | 116.44515353439972, 39.90683243165845, 10, | ||
| 74 | 116.4437677267605, 39.9069642145195, 10 | ||
| 75 | ]); | ||
| 76 | this.river = new Cesium.Primitive({ | ||
| 75 | geometryInstances : new Cesium.GeometryInstance({ | 77 | geometryInstances : new Cesium.GeometryInstance({ |
| 76 | geometry :new Cesium.PolygonGeometry({ | 78 | geometry :new Cesium.PolygonGeometry({ |
| 77 | polygonHierarchy : new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArrayHeights(positions2d)), | 79 | polygonHierarchy : new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArrayHeights(this.positions2d)), |
| 78 | extrudedHeight: targetHeight, | 80 | extrudedHeight: targetHeight, |
| 79 | height: waterHeight, | 81 | height: waterHeight, |
| 80 | vertexFormat : Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT | 82 | vertexFormat : Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT |
| ... | @@ -96,6 +98,10 @@ export default class flood { | ... | @@ -96,6 +98,10 @@ export default class flood { |
| 96 | }), | 98 | }), |
| 97 | show : true | 99 | show : true |
| 98 | }); | 100 | }); |
| 99 | objectManage.viewer.scene.primitives.add(River1); | 101 | objectManage.viewer.scene.primitives.add(this.river); |
| 102 | } | ||
| 103 | remove() { | ||
| 104 | this.positions2d = []; | ||
| 105 | objectManage.viewer.scene.primitives.remove(this.river); | ||
| 100 | } | 106 | } |
| 101 | } | 107 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | |||
| 2 | import objectManage from './maputils'; | 1 | import objectManage from './maputils'; |
| 3 | export default class viewpoint { | 2 | export default class viewpoint { |
| 4 | constructor() { | 3 | constructor() { |
| 5 | console.log(Cesium.Sightline); | ||
| 6 | this.sightline = new Cesium.Sightline(objectManage.viewer.scene); | 4 | this.sightline = new Cesium.Sightline(objectManage.viewer.scene); |
| 7 | this.sightline.couldRemove = false; | 5 | this.sightline.couldRemove = false; |
| 8 | this.sightline.build(); | 6 | this.sightline.build(); |
| ... | @@ -40,4 +38,10 @@ export default class viewpoint { | ... | @@ -40,4 +38,10 @@ export default class viewpoint { |
| 40 | objectManage.viewer.scene.viewFlag = false; | 38 | objectManage.viewer.scene.viewFlag = false; |
| 41 | this.handlerPoint.activate(); | 39 | this.handlerPoint.activate(); |
| 42 | } | 40 | } |
| 41 | remove() { | ||
| 42 | this.sightline.destroy(); | ||
| 43 | this.sightline = new Cesium.Sightline(objectManage.viewer.scene); | ||
| 44 | this.sightline.couldRemove = false; | ||
| 45 | this.sightline.build(); | ||
| 46 | } | ||
| 43 | } | 47 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -57,11 +57,10 @@ | ... | @@ -57,11 +57,10 @@ |
| 57 | 57 | ||
| 58 | }, | 58 | }, |
| 59 | startAnalysis() { | 59 | startAnalysis() { |
| 60 | // this.isAnalysis = true; | ||
| 61 | this.viewpoint.chooseView(); | 60 | this.viewpoint.chooseView(); |
| 62 | }, | 61 | }, |
| 63 | stopAnalysis() { | 62 | stopAnalysis() { |
| 64 | // this.isAnalysis = false; | 63 | this.viewpoint.remove(); |
| 65 | } | 64 | } |
| 66 | 65 | ||
| 67 | } | 66 | } | ... | ... |
| ... | @@ -69,7 +69,7 @@ | ... | @@ -69,7 +69,7 @@ |
| 69 | step: 0.01, | 69 | step: 0.01, |
| 70 | num: 1, | 70 | num: 1, |
| 71 | sdgc: '', // 水底高程 | 71 | sdgc: '', // 水底高程 |
| 72 | swsd: '', // 水位深度 | 72 | swsd: 50, // 水位深度 |
| 73 | ymsd: '', // 淹没速度 | 73 | ymsd: '', // 淹没速度 |
| 74 | isXmbj: true, | 74 | isXmbj: true, |
| 75 | // isAnalysis: true | 75 | // isAnalysis: true |
| ... | @@ -86,11 +86,11 @@ | ... | @@ -86,11 +86,11 @@ |
| 86 | 86 | ||
| 87 | }, | 87 | }, |
| 88 | startAnalysis() { | 88 | startAnalysis() { |
| 89 | this.flood.floodParse(this.flood.positions2d, 0, 50); | 89 | this.flood.floodParse(0, this.swsd); |
| 90 | this.flood.handlerPolygon.clear(); | 90 | this.flood.handlerPolygon.clear(); |
| 91 | }, | 91 | }, |
| 92 | stopAnalysis() { | 92 | stopAnalysis() { |
| 93 | objectManage.viewer.entities.removeAll(); | 93 | this.flood.remove(); |
| 94 | }, | 94 | }, |
| 95 | handleIsXmbj(flag) { | 95 | handleIsXmbj(flag) { |
| 96 | this.isXmbj = flag; | 96 | this.isXmbj = flag; | ... | ... |
-
Please register or sign in to post a comment