Don't crash if segments.geom is null.
Somtimes (for example https://www.sac-cas.ch/it/capanne-e-escursioni/portale-escursionistico-del-cas/albristhubel-6246/escursioni-con-le-racchette/von-matten-simmental-2785/) segments.geom is null and the creation of the gpx xml subsequently fails. If that is the case just ignore it and do not try to turn it into a track segment. Thanks to wizche for the report and fix!
This commit is contained in:
parent
553f764e69
commit
7ea79b6f44
@ -18,3 +18,6 @@ Heed their warning and do not blindly follow the gps track! Use your brain and
|
||||
plan your route beforehand to be aware of dangerous parts and alternatives.
|
||||
|
||||
Take a look at their [safety instructions](https://www.sac-cas.ch/en/training-and-safety/safety/).
|
||||
|
||||
## Contributors
|
||||
- wizche
|
||||
|
@ -89,9 +89,10 @@ function trackTitle(geoJson) {
|
||||
*/
|
||||
function toGpx(geoJson) {
|
||||
let trackSegments = geoJson.segments.map((segment) => {
|
||||
if (segment.geom == null) return "";
|
||||
return `<trkseg>
|
||||
${segment.geom.coordinates.map(toTrackPoint).join("")}
|
||||
</trkseg>`;
|
||||
${segment.geom.coordinates.map(toTrackPoint).join("")}
|
||||
</trkseg>`;
|
||||
}).join("");
|
||||
|
||||
let endPoint = geoJson.end_point ? toWayPoint(geoJson.end_point) : "";
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
"manifest_version": 2,
|
||||
"name": "SAC Route Portal GPX Downloader",
|
||||
"version": "0.6",
|
||||
"version": "0.7",
|
||||
"developer": {
|
||||
"name": "Sebastian Hugentobler",
|
||||
"url": "https://code.vanwa.ch/sebastian/sac-route-portal-gpx-fx"
|
||||
|
Loading…
Reference in New Issue
Block a user