From 21d55dbcf2b6964269e706d24de33bd2c312a7cd Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Mon, 20 Apr 2026 11:35:38 +0200 Subject: [PATCH] take entrances into account for routing start and end points --- .../javascripts/index/directions-endpoint.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/index/directions-endpoint.js b/app/assets/javascripts/index/directions-endpoint.js index ffbb30322..d44158574 100644 --- a/app/assets/javascripts/index/directions-endpoint.js +++ b/app/assets/javascripts/index/directions-endpoint.js @@ -95,9 +95,20 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, marker, dragCallback, cha if (g1) endpoint.cachedReverseGeocode = g1; }; + function findPreferredEntrance(entrances, types) { + if (!entrances) return null; + + for (const t of types) { + const matchId = entrances.find(e => e.type === t); + if (matchId) return matchId; + } + + return null; + } + function getGeocode() { const viewbox = map.getBounds().toBBoxString(), // ,,, - geocodeUrl = OSM.NOMINATIM_URL + "search?" + new URLSearchParams({ q: endpoint.value, format: "json", viewbox, limit: 1 }); + geocodeUrl = OSM.NOMINATIM_URL + "search?" + new URLSearchParams({ q: endpoint.value, format: "json", viewbox, limit: 1, entrances: 1 }); endpoint.geocodeRequest = new AbortController(); fetch(geocodeUrl, { signal: endpoint.geocodeRequest.signal }) @@ -114,7 +125,7 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, marker, dragCallback, cha return; } - setLatLng(L.latLng(json[0])); + setLatLng(L.latLng(findPreferredEntrance(json[0].entrances, ["main", "yes"]) || json[0])); endpoint.value = json[0].display_name; input.val(json[0].display_name); -- 2.47.3