Skip to content

Commit 01a77ec

Browse files
authored
fixed NaN validation, add no-gps-data class to map (#618)
1 parent bbf2bca commit 01a77ec

File tree

2 files changed

+45
-10
lines changed

2 files changed

+45
-10
lines changed

css/main.css

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,32 @@ html.has-sticks #stickCanvas {
507507
display:block;
508508
}
509509

510+
#mapContainer.no-gps-data:before {
511+
position: absolute;
512+
display: block;
513+
top: 0;
514+
right: 0;
515+
bottom: 0;
516+
left: 0;
517+
z-index: 9999;
518+
content: "";
519+
background-color: gray;
520+
opacity: .5;
521+
}
522+
523+
#mapContainer.no-gps-data:after {
524+
position: absolute;
525+
display: block;
526+
top: calc(30%);
527+
right: 0;
528+
bottom: 0;
529+
left: 0;
530+
z-index: 10001;
531+
content: "No GPS Data";
532+
text-align: center;
533+
font-size: 3vw;
534+
}
535+
510536
html.has-analyser-fullscreen.has-analyser .analyser input:not(.onlyFullScreenException) {
511537
display:block;
512538
}

js/graph_map.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,22 +121,27 @@ function MapGrapher() {
121121
}
122122

123123
this.setFlightLogIndexs();
124-
125124
let { latlngs, maxAlt, minAlt } = this.getPolylinesData();
126125

127-
const polyline = L.polyline(latlngs, polylineOptions);
126+
const hasGpsData = latlngs.length > 0;
128127

129-
const polylineC = this.createAltitudeColoredPolyline(
130-
latlngs,
131-
maxAlt,
132-
minAlt
133-
);
128+
if (hasGpsData) {
129+
const polyline = L.polyline(latlngs, polylineOptions);
130+
131+
const polylineC = this.createAltitudeColoredPolyline(
132+
latlngs,
133+
maxAlt,
134+
minAlt
135+
);
134136

135-
trailLayers.set(logIndex, { polyline, polylineC });
137+
trailLayers.set(logIndex, { polyline, polylineC });
136138

137-
if (latlngs.length > 0) {
138139
homePosition = this.getHomeCoordinatesFromFlightLog(flightLog);
140+
} else {
141+
console.debug("FlightLog has no gps data.");
139142
}
143+
144+
$("#mapContainer").toggleClass("no-gps-data", !hasGpsData);
140145
};
141146

142147
this.setFlightLogIndexs = function () {
@@ -382,7 +387,7 @@ function MapGrapher() {
382387
const lng = frame[lngIndex];
383388
const alt = frame[altitudeIndex];
384389

385-
return typeof lat == "number" || typeof lng == "number"
390+
return this.isNumber(lat) && this.isNumber(lng)
386391
? L.latLng(
387392
lat / coordinateDivider,
388393
lng / coordinateDivider,
@@ -391,6 +396,10 @@ function MapGrapher() {
391396
: null;
392397
};
393398

399+
this.isNumber = function (n) {
400+
return typeof n === "number" && !isNaN(n);
401+
};
402+
394403
this.getGroundCourseFromFrame = function (frame, groundCourseIndex) {
395404
const gc = frame[groundCourseIndex];
396405
return typeof gc == "number" ? gc / grounCourseDivider : 0;

0 commit comments

Comments
 (0)