Skip to content

Commit 54ae0ef

Browse files
committed
BGDIINF_SB-2977 : profile position tracker for Cesium
1 parent 3035098 commit 54ae0ef

File tree

3 files changed

+92
-3
lines changed

3 files changed

+92
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<template>
2+
<slot />
3+
</template>
4+
<script>
5+
import { LV95, WGS84 } from '@/utils/coordinateSystems'
6+
import { FeatureStyleColor, RED } from '@/utils/featureStyleUtils'
7+
import proj4 from 'proj4'
8+
import { CallbackProperty, Cartesian3, Color, Ellipsoid, Entity, HeightReference } from 'cesium'
9+
10+
export default {
11+
inject: ['getViewer'],
12+
props: {
13+
coordinates: {
14+
type: Array,
15+
default: null,
16+
},
17+
trackingPointColor: {
18+
type: FeatureStyleColor,
19+
default: RED,
20+
},
21+
},
22+
watch: {
23+
coordinates(newCoordinates) {
24+
if (newCoordinates) {
25+
this.updatePosition()
26+
if (!this.pointAdded) this.addTrackingPoint()
27+
} else {
28+
this.removeTrackingPoint()
29+
}
30+
},
31+
trackingPointColor(newColor) {
32+
this.pointFill = Color.fromCssColorString(newColor.fill)
33+
this.pointBorder = Color.fromCssColorString(newColor.border)
34+
this.getViewer()?.scene.requestRender()
35+
},
36+
},
37+
mounted() {
38+
this.pointAdded = false
39+
this.trackingPointPosition = new Cartesian3()
40+
this.pointFill = Color.fromCssColorString(this.trackingPointColor.fill)
41+
this.pointBorder = Color.fromCssColorString(this.trackingPointColor.border)
42+
this.trackingPoint = new Entity({
43+
position: new CallbackProperty(() => this.trackingPointPosition, false),
44+
point: {
45+
show: true,
46+
color: new CallbackProperty(() => this.pointFill, false),
47+
outlineWidth: 5,
48+
outlineColor: new CallbackProperty(() => this.pointBorder, false),
49+
pixelSize: 15,
50+
heightReference: HeightReference.CLAMP_TO_GROUND,
51+
disableDepthTestDistance: Number.POSITIVE_INFINITY,
52+
},
53+
})
54+
if (this.coordinates) {
55+
this.updatePosition()
56+
this.addTrackingPoint()
57+
}
58+
},
59+
unmounted() {
60+
this.removeTrackingPoint()
61+
},
62+
methods: {
63+
addTrackingPoint() {
64+
this.pointAdded = true
65+
this.getViewer()?.entities.add(this.trackingPoint)
66+
},
67+
removeTrackingPoint() {
68+
this.pointAdded = false
69+
this.getViewer()?.entities.remove(this.trackingPoint)
70+
},
71+
updatePosition() {
72+
const wgs84Position = proj4(LV95.epsg, WGS84.epsg, this.coordinates)
73+
Cartesian3.fromDegrees(
74+
wgs84Position[0],
75+
wgs84Position[1],
76+
0,
77+
Ellipsoid.WGS84,
78+
this.trackingPointPosition
79+
)
80+
this.getViewer()?.scene.requestRender()
81+
},
82+
},
83+
}
84+
</script>

src/modules/infobox/components/FeatureElevationProfilePlot.vue

+7-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@
5252
:tracking-point-color="trackingPointColor"
5353
:coordinates="pointBeingHovered?.coordinates"
5454
/>
55-
<!--TODO BGDIINF_SB-2977 : create a position tracker for Cesium, similar to FeatureElevationProfilePlotOpenLayersBridge-->
55+
<FeatureElevationProfilePlotCesiumBridge
56+
v-if="showIn3d"
57+
:tracking-point-color="trackingPointColor"
58+
:coordinates="pointBeingHovered?.coordinates"
59+
/>
5660
</div>
5761
</div>
5862
</template>
@@ -65,6 +69,7 @@ import { round } from '@/utils/numberUtils'
6569
import { resetZoom } from 'chartjs-plugin-zoom'
6670
import { Line as LineChart } from 'vue-chartjs'
6771
import { mapState } from 'vuex'
72+
import FeatureElevationProfilePlotCesiumBridge from '@/modules/infobox/FeatureElevationProfilePlotCesiumBridge.vue'
6873
6974
const GAP_BETWEEN_TOOLTIP_AND_PROFILE = 12 //px
7075
@@ -86,6 +91,7 @@ const GAP_BETWEEN_TOOLTIP_AND_PROFILE = 12 //px
8691
export default {
8792
components: {
8893
FeatureElevationProfilePlotOpenLayersBridge,
94+
FeatureElevationProfilePlotCesiumBridge,
8995
LineChart,
9096
},
9197
props: {

src/modules/map/components/cesium/CesiumMap.vue

+1-2
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,9 @@ import { extractOlFeatureGeodesicCoordinates } from '@/modules/drawing/lib/drawi
111111
import log from '@/utils/logging'
112112
import { LineString, Point, Polygon } from 'ol/geom'
113113
import FeatureEdit from '@/modules/infobox/components/FeatureEdit.vue'
114-
import OpenLayersPopover from '@/modules/map/components/openlayers/OpenLayersPopover.vue'
115114
116115
export default {
117-
components: { OpenLayersPopover, FeatureEdit, FeatureList, CesiumPopover, CesiumInternalLayer },
116+
components: { FeatureEdit, FeatureList, CesiumPopover, CesiumInternalLayer },
118117
provide() {
119118
return {
120119
// sharing cesium viewer object with children components

0 commit comments

Comments
 (0)