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:
Sebastian Hugentobler 2023-02-03 12:41:49 +01:00
parent 553f764e69
commit 7ea79b6f44
Signed by: shu
GPG Key ID: BB32CF3CA052C2F0
3 changed files with 7 additions and 3 deletions

View File

@ -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

View File

@ -89,6 +89,7 @@ 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>`;

View File

@ -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"