Skip to content

Commit 9e3fdcf

Browse files
Show takeoff/landing pads on map
1 parent 75bb0b8 commit 9e3fdcf

File tree

4 files changed

+209
-16
lines changed

4 files changed

+209
-16
lines changed

app/img/LandingLocation.svg

Lines changed: 64 additions & 0 deletions
Loading

app/img/TakeoffLocation.svg

Lines changed: 64 additions & 0 deletions
Loading

app/js/Drone.js

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ class Drone {
22

33
#demoIndex = 0;
44

5+
#droneImageSource = './img/drone.svg';
6+
#droneImageScale = 1;
7+
#takeoffLocationImageSource = './img/TakeoffLocation.svg';
8+
#takeoffLocationImageScale = 2;
9+
#landingLocationImageSource = './img/LandingLocation.svg';
10+
#landingLocationImageScale = 2;
11+
512
#drone_id;
613

714
#gpsSignalLevel;
@@ -200,6 +207,25 @@ class Drone {
200207
}
201208

202209

210+
getDroneImageSource() {
211+
return this.#droneImageSource;
212+
}
213+
getDroneImageScale() {
214+
return this.#droneImageScale;
215+
}
216+
getTakeoffLocationImageSource() {
217+
return this.#takeoffLocationImageSource;
218+
}
219+
getTakeoffLocationImageScale() {
220+
return this.#takeoffLocationImageScale;
221+
}
222+
getLandingLocationImageSource() {
223+
return this.#landingLocationImageSource;
224+
}
225+
getLandingLocationImageScale() {
226+
return this.#landingLocationImageScale;
227+
}
228+
203229
getDroneId() {
204230
return this.#drone_id;
205231
}
@@ -217,12 +243,12 @@ class Drone {
217243
setGpsValid(gpsValid) {
218244
this.#gpsValid = gpsValid;
219245
}
220-
getGpsLat() { // TODO: incorrect order!
221-
return this.#gpsLon;
222-
}
223-
getGpsLon() { // TODO: incorrect order!
246+
getGpsLat() {
224247
return this.#gpsLat;
225248
}
249+
getGpsLon() {
250+
return this.#gpsLon;
251+
}
226252

227253
getAltitude() {
228254
return this.#altitude;
@@ -263,4 +289,35 @@ class Drone {
263289
return this.#remainingFlightRadius;
264290
}
265291

292+
293+
getTakeoffTime() {
294+
return this.#takeoffTime;
295+
}
296+
getTakeoffGpsValid() {
297+
return this.#takeoffGpsValid;
298+
}
299+
getTakeoffGpsLat() {
300+
return this.#takeoffGpsLat;
301+
}
302+
getTakeoffGpsLon() {
303+
return this.#takeoffGpsLon;
304+
}
305+
306+
getLandingTime() {
307+
return this.#landingTime;
308+
}
309+
getLandingGpsValid() {
310+
return this.#landingGpsValid;
311+
}
312+
getLandingGpsLat() {
313+
return this.#landingGpsLat;
314+
}
315+
getLandingGpsLon() {
316+
return this.#landingGpsLon;
317+
}
318+
319+
getOperationModes() {
320+
return this.#operationModes;
321+
}
322+
266323
}

app/js/MapApplet.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ class MapApplet {
44

55
#map;
66
#droneVectors;
7+
#takeoffLocationVectors = [];
8+
#landingLocationVectors = [];
79

810
#preferredZoomLevel = 18;
911

@@ -87,8 +89,11 @@ class MapApplet {
8789
let droneId = Object.keys(drones)[i];
8890
let drone = drones[droneId];
8991

92+
this.#updateVectorPointCoordinates(this.#landingLocationVectors[i], drone.getLandingGpsLat(), drone.getLandingGpsLon());
93+
this.#updateVectorPointCoordinates(this.#takeoffLocationVectors[i], drone.getTakeoffGpsLat(), drone.getTakeoffGpsLon());
94+
9095
this.#updateVectorPointCoordinates(this.#droneVectors[i], drone.getGpsLat(), drone.getGpsLon());
91-
this.#updateVectorPointRotation(this.#droneVectors[i], drone.getYaw());
96+
this.#updateVectorPointRotation(this.#droneVectors[i], drone.getYaw(), drone.getDroneImageSource(), drone.getDroneImageScale());
9297
}
9398
} else {
9499
// Different drones
@@ -99,7 +104,11 @@ class MapApplet {
99104
for (drone_id in drones) {
100105
const drone = drones[drone_id];
101106

102-
this.#droneVectors.push(this.#createAndAddVectorPoint(this.#map, drone.getGpsLat(), drone.getGpsLon()));
107+
this.#landingLocationVectors.push(this.#createAndAddVectorPoint(this.#map, drone.getLandingGpsLat(), drone.getLandingGpsLon(), drone.getLandingLocationImageSource(), drone.getLandingLocationImageScale()));
108+
this.#takeoffLocationVectors.push(this.#createAndAddVectorPoint(this.#map, drone.getTakeoffGpsLat(), drone.getTakeoffGpsLon(), drone.getTakeoffLocationImageSource(), drone.getTakeoffLocationImageScale()));
109+
110+
this.#droneVectors.push(this.#createAndAddVectorPoint(this.#map, drone.getGpsLat(), drone.getGpsLon(), this.#drones[drone_id].getDroneImageSource()));
111+
// TODO: rotate drone
103112
}
104113
}
105114

@@ -108,7 +117,7 @@ class MapApplet {
108117
}
109118

110119

111-
#createVectorPoint(lat, lon) {
120+
#createVectorPoint(lat, lon, imageSource, imageScale) {
112121
return new ol.layer.Vector({
113122
source: new ol.source.Vector({
114123
features: [
@@ -119,16 +128,15 @@ class MapApplet {
119128
}),
120129
style: new ol.style.Style({
121130
image: new ol.style.Icon({
122-
src: './img/drone.svg',
123-
rotation: 30,
124-
scale: 1.5
131+
src: imageSource,
132+
scale: imageScale
125133
}),
126134
})
127135
});
128136
}
129137

130-
#createAndAddVectorPoint(map, lat, lon) {
131-
let vector = this.#createVectorPoint(lat, lon);
138+
#createAndAddVectorPoint(map, lat, lon, imageSource, imageScale) {
139+
let vector = this.#createVectorPoint(lat, lon, imageSource, imageScale);
132140
this.#map.addLayer(vector);
133141
return vector;
134142
}
@@ -147,12 +155,12 @@ class MapApplet {
147155
}
148156

149157

150-
#updateVectorPointRotation(vector, rotation) {
158+
#updateVectorPointRotation(vector, rotation, imageSource, imageScale) {
151159
let newStyle = new ol.style.Style({
152160
image: new ol.style.Icon({
153-
src: './img/drone.svg',
154-
rotation: rotation * (3.1415 / 180),
155-
scale: 1.5
161+
src: imageSource,
162+
scale: imageScale,
163+
rotation: rotation * (3.1415 / 180)
156164
}),
157165
})
158166

0 commit comments

Comments
 (0)