111111
Showing
4 changed files
with
31 additions
and
25 deletions
| 1 | import objectManage from './maputils'; | ||
| 1 | export default class flood { | 2 | export default class flood { |
| 2 | constructor(viewer) { | 3 | constructor() { |
| 3 | this.positions2d = []; | 4 | this.positions2d = []; |
| 4 | this.handlerPolygon = new Cesium.DrawHandler(viewer, Cesium.DrawMode.Polygon); | 5 | this.handlerPolygon = new Cesium.DrawHandler(objectManage.viewer, Cesium.DrawMode.Polygon); |
| 5 | this.handlerPolygon.drawEvt.addEventListener(polygon => { | 6 | this.handlerPolygon.drawEvt.addEventListener(polygon => { |
| 6 | var array = [].concat(polygon.object.positions), positions = []; | 7 | var array = [].concat(polygon.object.positions), positions = []; |
| 7 | for(var i = 0, len = array.length; i < len; i++){ | 8 | for(var i = 0, len = array.length; i < len; i++){ | ... | ... |
| 1 | import objectManage from './maputils'; | 1 | import objectManage from './maputils'; |
| 2 | export default class shadow { | 2 | export default class shadow { |
| 3 | constructor() { | 3 | constructor() { |
| 4 | this.points = []; | ||
| 4 | this.shadowQuery = new Cesium.ShadowQueryPoints(objectManage.viewer.scene); | 5 | this.shadowQuery = new Cesium.ShadowQueryPoints(objectManage.viewer.scene); |
| 6 | this.shadowQuery.build(); | ||
| 5 | this.setCurrentTime(); | 7 | this.setCurrentTime(); |
| 6 | this.init(); | 8 | this.init(); |
| 7 | } | 9 | } |
| 8 | setCurrentTime() { | 10 | setCurrentTime() { |
| 9 | objectManage.viewer.clock.currentTime = Cesium.JulianDate.fromDate(new Date()); | 11 | let d = new Date(); |
| 12 | d.setHours(20) | ||
| 13 | objectManage.viewer.clock.currentTime = Cesium.JulianDate.fromDate(d); | ||
| 10 | objectManage.viewer.clock.multiplier = 1; | 14 | objectManage.viewer.clock.multiplier = 1; |
| 11 | objectManage.viewer.clock.shouldAnimate = true; | 15 | objectManage.viewer.clock.shouldAnimate = true; |
| 12 | } | 16 | } |
| 13 | init() { | 17 | init() { |
| 14 | this.handlerPolygon = new Cesium.DrawHandler(objectManage.viewer, Cesium.DrawMode.Polygon, 0); | ||
| 15 | this.tooltip = this.createTooltip(document.body); | 18 | this.tooltip = this.createTooltip(document.body); |
| 16 | this.points = []; | 19 | this.handlerPolygon = new Cesium.DrawHandler(objectManage.viewer, Cesium.DrawMode.Polygon, 0); |
| 17 | this.handlerPolygon.activeEvt.addEventListener(a => { | 20 | this.handlerPolygon.activeEvt.addEventListener(a => { |
| 18 | let body = $('body').removeClass('measureCur'); | 21 | let body = $('body').removeClass('measureCur'); |
| 19 | a && body.addClass('measureCur'); | 22 | a && body.addClass('measureCur'); | ... | ... |
| 1 | |||
| 2 | import objectManage from './maputils'; | ||
| 1 | export default class viewpoint { | 3 | export default class viewpoint { |
| 2 | constructor(viewer) { | 4 | constructor() { |
| 3 | this.viewer = viewer; | 5 | this.sightline = new Cesium.Sightline(objectManage.viewer.scene); |
| 4 | this.sightline = new Cesium.Sightline(viewer.scene); | ||
| 5 | this.sightline.couldRemove = false; | 6 | this.sightline.couldRemove = false; |
| 6 | this.sightline.build(); | 7 | this.sightline.build(); |
| 7 | this.handlerPoint = new Cesium.DrawHandler(viewer, Cesium.DrawMode.Point); | 8 | this.handlerPoint = new Cesium.DrawHandler(objectManage.viewer, Cesium.DrawMode.Point); |
| 8 | this.handlerPoint.drawEvt.addEventListener(result => { | 9 | this.handlerPoint.drawEvt.addEventListener(result => { |
| 9 | var point = result.object; | 10 | var point = result.object; |
| 10 | point.show = false; | 11 | point.show = false; |
| ... | @@ -14,9 +15,9 @@ export default class viewpoint { | ... | @@ -14,9 +15,9 @@ export default class viewpoint { |
| 14 | var longitude = Cesium.Math.toDegrees(cartographic.longitude); | 15 | var longitude = Cesium.Math.toDegrees(cartographic.longitude); |
| 15 | var latitude = Cesium.Math.toDegrees(cartographic.latitude); | 16 | var latitude = Cesium.Math.toDegrees(cartographic.latitude); |
| 16 | var height = cartographic.height; | 17 | var height = cartographic.height; |
| 17 | if(viewer.scene.viewFlag) { | 18 | if(objectManage.viewer.scene.viewFlag) { |
| 18 | this.sightline.viewPosition = [longitude, latitude, height]; | 19 | this.sightline.viewPosition = [longitude, latitude, height]; |
| 19 | viewer.scene.viewFlag = false; | 20 | objectManage.viewer.scene.viewFlag = false; |
| 20 | this.addPoint(); | 21 | this.addPoint(); |
| 21 | }else { | 22 | }else { |
| 22 | this.sightline.addTargetPoint({ | 23 | this.sightline.addTargetPoint({ |
| ... | @@ -29,13 +30,13 @@ export default class viewpoint { | ... | @@ -29,13 +30,13 @@ export default class viewpoint { |
| 29 | } | 30 | } |
| 30 | chooseView() { | 31 | chooseView() { |
| 31 | if(this.handlerPoint.active) return; | 32 | if(this.handlerPoint.active) return; |
| 32 | this.viewer.scene.viewFlag = true; | 33 | objectManage.viewer.scene.viewFlag = true; |
| 33 | this.viewer.entities.removeAll(); | 34 | objectManage.viewer.entities.removeAll(); |
| 34 | this.sightline.removeAllTargetPoint(); | 35 | this.sightline.removeAllTargetPoint(); |
| 35 | this.handlerPoint.activate(); | 36 | this.handlerPoint.activate(); |
| 36 | } | 37 | } |
| 37 | addPoint() { | 38 | addPoint() { |
| 38 | this.viewer.scene.viewFlag = false; | 39 | objectManage.viewer.scene.viewFlag = false; |
| 39 | this.handlerPoint.activate(); | 40 | this.handlerPoint.activate(); |
| 40 | } | 41 | } |
| 41 | } | 42 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | import objectManage from './maputils'; | ||
| 1 | export default class visual { | 2 | export default class visual { |
| 2 | constructor(viewer) { | 3 | constructor() { |
| 3 | this.viewer = viewer; | 4 | objectManage.viewer.scene.viewFlag = true; |
| 4 | viewer.scene.viewFlag = true; | 5 | this.pointHandler = new Cesium.DrawHandler(objectManage.viewer, Cesium.DrawMode.Point); |
| 5 | this.pointHandler = new Cesium.DrawHandler(viewer, Cesium.DrawMode.Point); | 6 | this.viewshed3D = new Cesium.ViewShed3D(objectManage.viewer.scene); |
| 6 | this.viewshed3D = new Cesium.ViewShed3D(viewer.scene); | ||
| 7 | this.viewPosition; | 7 | this.viewPosition; |
| 8 | this.viewModel = { | 8 | this.viewModel = { |
| 9 | direction: 1.0, | 9 | direction: 1.0, |
| ... | @@ -15,7 +15,7 @@ export default class visual { | ... | @@ -15,7 +15,7 @@ export default class visual { |
| 15 | invisibleAreaColor: '#ffffffff' | 15 | invisibleAreaColor: '#ffffffff' |
| 16 | }; | 16 | }; |
| 17 | Cesium.knockout.track(this.viewModel); | 17 | Cesium.knockout.track(this.viewModel); |
| 18 | this.init(viewer.scene); | 18 | this.init(objectManage.viewer.scene); |
| 19 | } | 19 | } |
| 20 | init(scene) { | 20 | init(scene) { |
| 21 | this.handler = new Cesium.ScreenSpaceEventHandler(scene.canvas); | 21 | this.handler = new Cesium.ScreenSpaceEventHandler(scene.canvas); |
| ... | @@ -49,28 +49,29 @@ export default class visual { | ... | @@ -49,28 +49,29 @@ export default class visual { |
| 49 | this.pointHandler.drawEvt.addEventListener(result => { | 49 | this.pointHandler.drawEvt.addEventListener(result => { |
| 50 | var point = result.object; | 50 | var point = result.object; |
| 51 | var position = point.position; | 51 | var position = point.position; |
| 52 | viewPosition = position; | 52 | this.viewPosition = position; |
| 53 | // 将获取的点的位置转化成经纬度 | 53 | // 将获取的点的位置转化成经纬度 |
| 54 | var cartographic = Cesium.Cartographic.fromCartesian(position); | 54 | var cartographic = Cesium.Cartographic.fromCartesian(position); |
| 55 | var longitude = Cesium.Math.toDegrees(cartographic.longitude); | 55 | var longitude = Cesium.Math.toDegrees(cartographic.longitude); |
| 56 | var latitude = Cesium.Math.toDegrees(cartographic.latitude); | 56 | var latitude = Cesium.Math.toDegrees(cartographic.latitude); |
| 57 | var height = cartographic.height + 1.8; | 57 | var height = cartographic.height + 1.8; |
| 58 | point.position = Cesium.Cartesian3.fromDegrees(longitude, latitude, height); | 58 | point.position = Cesium.Cartesian3.fromDegrees(longitude, latitude, height); |
| 59 | if (this.viewer.scene.viewFlag) { | 59 | if (objectManage.viewer.scene.viewFlag) { |
| 60 | // 设置视口位置 | 60 | // 设置视口位置 |
| 61 | this.viewshed3D.viewPosition = [longitude, latitude, height]; | 61 | this.viewshed3D.viewPosition = [longitude, latitude, height]; |
| 62 | this.viewshed3D.build(); | 62 | this.viewshed3D.build(); |
| 63 | // 将标记置为false以激活鼠标移动回调里面的设置可视域操作 | 63 | // 将标记置为false以激活鼠标移动回调里面的设置可视域操作 |
| 64 | this.viewer.scene.viewFlag = false; | 64 | objectManage.viewer.scene.viewFlag = false; |
| 65 | } | 65 | } |
| 66 | }); | 66 | }); |
| 67 | this.chooseView(); | ||
| 67 | } | 68 | } |
| 68 | chooseView() { | 69 | chooseView() { |
| 69 | if (this.pointHandler.active) return; | 70 | if (this.pointHandler.active) return; |
| 70 | //先清除之前的可视域分析 | 71 | //先清除之前的可视域分析 |
| 71 | this.viewer.entities.removeAll(); | 72 | objectManage.viewer.entities.removeAll(); |
| 72 | this.viewshed3D.distance = 0.1; | 73 | this.viewshed3D.distance = 0.1; |
| 73 | this.viewer.scene.viewFlag = true; | 74 | objectManage.viewer.scene.viewFlag = true; |
| 74 | //激活绘制点类 | 75 | //激活绘制点类 |
| 75 | this.pointHandler.activate(); | 76 | this.pointHandler.activate(); |
| 76 | } | 77 | } | ... | ... |
-
Please register or sign in to post a comment