adds gpx rte tag to maps

This commit is contained in:
Christian Beutel
2024-05-05 12:31:08 +02:00
parent 844d5771e8
commit 930feda4d6
7 changed files with 15 additions and 14 deletions

View File

@@ -79,7 +79,7 @@
weight: 5, weight: 5,
}, },
gpx_options: { gpx_options: {
parseElements: ["track"] as any, parseElements: ["track", "route"] as any,
}, },
marker_options: { marker_options: {
startIcon: L.AwesomeMarkers.icon({ startIcon: L.AwesomeMarkers.icon({
@@ -93,7 +93,7 @@
shadowUrl: "", shadowUrl: "",
}, },
}) })
.on("loaded", function (e) { .on("loaded", function (e) {
map.fitBounds(e.target.getBounds()); map.fitBounds(e.target.getBounds());
}) })
.addTo(map); .addTo(map);

View File

@@ -79,7 +79,7 @@
"language": "Taal", "language": "Taal",
"latitude": "Breedtegraad", "latitude": "Breedtegraad",
"license": "Licentie", "license": "Licentie",
"list": "{n, plural, =1 {lijst} other {lijsten}}", "list": "{n, plural, =1 {Lijst} other {Lijsten}}",
"location": "Locatie", "location": "Locatie",
"login": "Inloggen", "login": "Inloggen",
"logout": "Uitloggen", "logout": "Uitloggen",
@@ -135,7 +135,7 @@
"stop-drawing": "", "stop-drawing": "",
"summit-book": "Bergtopboek", "summit-book": "Bergtopboek",
"text": "Tekst", "text": "Tekst",
"trail": "{n, plural, =1 {wandelroute} other {wandelroutes}}", "trail": "{n, plural, =1 {Wandelroute} other {Wandelroutes}}",
"trails-for-you": "Wandelroutes voor jou", "trails-for-you": "Wandelroutes voor jou",
"units": "Eenheden", "units": "Eenheden",
"upload-file": "Bestand uploaden", "upload-file": "Bestand uploaden",

View File

@@ -28,15 +28,17 @@ export async function gpx2trail(gpxString: string) {
const totals = gpx.getTotals() const totals = gpx.getTotals()
const points = gpx.trk?.at(0)?.trkseg?.at(0)?.trkpt const trackPoints = gpx.trk?.at(0)?.trkseg?.at(0)?.trkpt
const startPoint = points?.at(0); const routePoints = gpx.rte?.at(0)?.rtept;
const startPoint = trackPoints?.at(0) ?? routePoints?.at(0);
if (startPoint) { if (startPoint) {
trail.lat = startPoint.$.lat trail.lat = startPoint.$.lat
trail.lon = startPoint.$.lon trail.lon = startPoint.$.lon
} }
const startTime = points?.at(0)?.time; const startTime = trackPoints?.at(0)?.time;
const endTime = points?.at((points?.length ?? 1) - 1)?.time const endTime = trackPoints?.at((trackPoints?.length ?? 1) - 1)?.time
if (startTime && endTime && !trail.date) { if (startTime && endTime && !trail.date) {
trail.date = startTime.toISOString() trail.date = startTime.toISOString()

View File

@@ -17,7 +17,7 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
__TOGEOJSON: '/vendor/leaflet-elevation/libs/togeojson.umd.js', __TOGEOJSON: '/vendor/leaflet-elevation/libs/togeojson.umd.js',
__LGEOMUTIL: '/vendor/leaflet-elevation/libs/leaflet.geometryutil.js', __LGEOMUTIL: '/vendor/leaflet-elevation/libs/leaflet.geometryutil.js',
__LALMOSTOVER: '/vendor/leaflet-elevation/libs/leaflet.almostover.js', __LALMOSTOVER: '/vendor/leaflet-elevation/libs/leaflet.almostover.js',
__LHOTLINE: '/vendor/leaflet-elevation/libs/leaflet-hotline.min.js', __LHOTLINE: '/vendor/leaflet-elevation/libs/leaflet-hotline.js',
__LDISTANCEM: '/vendor/leaflet-elevation/libs/leaflet-distance-marker.min.js', __LDISTANCEM: '/vendor/leaflet-elevation/libs/leaflet-distance-marker.min.js',
__LEDGESCALE: '/vendor/leaflet-elevation/libs/leaflet-edgescale.min.js', __LEDGESCALE: '/vendor/leaflet-elevation/libs/leaflet-edgescale.min.js',
__LCHART: '/vendor/leaflet-elevation/src/components/chart.js', __LCHART: '/vendor/leaflet-elevation/src/components/chart.js',
@@ -452,7 +452,7 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
.then(() => { .then(() => {
layer.eachLayer((trkseg) => { layer.eachLayer((trkseg) => {
if (trkseg.feature.geometry.type != "Point") { if (trkseg.feature.geometry.type != "Point") {
let geo = L.geoJson(trkseg.toGeoJSON(), { coordsToLatLng: (coords) => L.latLng(coords[0], coords[1], coords[2] * (this.options.altitudeFactor || 1)) }); let geo = L.geoJson(trkseg.toGeoJSON(), { coordsToLatLng: (coords) => L.latLng(coords[0], coords[1], (coords[2] * (this.options.altitudeFactor || 1)) || 0) });
let line = L.hotline(geo.toGeoJSON().features[0].geometry.coordinates, { let line = L.hotline(geo.toGeoJSON().features[0].geometry.coordinates, {
renderer: L.Hotline.renderer(), renderer: L.Hotline.renderer(),
min: isFinite(this.track_info[prop + '_min']) ? this.track_info[prop + '_min'] : 0, min: isFinite(this.track_info[prop + '_min']) ? this.track_info[prop + '_min'] : 0,

View File

@@ -77,7 +77,7 @@
weight: 5, weight: 5,
}, },
gpx_options: { gpx_options: {
parseElements: ["track"], parseElements: ["track", "route"],
}, },
marker_options: { marker_options: {
startIcon: L.AwesomeMarkers.icon({ startIcon: L.AwesomeMarkers.icon({

View File

@@ -211,7 +211,7 @@
weight: 5, weight: 5,
}, },
gpx_options: { gpx_options: {
parseElements: ["track"], parseElements: ["track", "route"],
}, },
marker_options: { marker_options: {
startIcon: L.AwesomeMarkers.icon({ startIcon: L.AwesomeMarkers.icon({

View File

@@ -243,7 +243,6 @@ https://github.com/iosphere/Leaflet.hotline/
for (i = 0, dataLength = this._data.length; i < dataLength; i++) { for (i = 0, dataLength = this._data.length; i < dataLength; i++) {
path = this._data[i]; path = this._data[i];
for (j = 1, pathLength = path.length; j < pathLength; j++) { for (j = 1, pathLength = path.length; j < pathLength; j++) {
pointStart = path[j - 1]; pointStart = path[j - 1];
pointEnd = path[j]; pointEnd = path[j];