From b2ddc0ef449ccbe7f0d33e539ccdfc1baef04e2c Mon Sep 17 00:00:00 2001
From: Ariel Costas Guerrero <ariel@costas.dev>
Date: Sun, 28 Dec 2025 18:21:17 +0100
Subject: Get favourite stops from OTP instead of pre-generated file

---
 src/frontend/app/routes/map.tsx | 44 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

(limited to 'src/frontend/app/routes/map.tsx')

diff --git a/src/frontend/app/routes/map.tsx b/src/frontend/app/routes/map.tsx
index b02c494..b8f179c 100644
--- a/src/frontend/app/routes/map.tsx
+++ b/src/frontend/app/routes/map.tsx
@@ -40,6 +40,13 @@ export default function StopMap() {
 
   const { searchRoute } = usePlanner({ autoLoad: false });
 
+  const favouriteIds = useMemo(() => StopDataProvider.getFavouriteIds(), []);
+
+  const favouriteFilter = useMemo(() => {
+    if (favouriteIds.length === 0) return ["boolean", false];
+    return ["match", ["get", "id"], favouriteIds, true, false];
+  }, [favouriteIds]);
+
   // Handle click events on clusters and individual stops
   const onMapClick = (e: MapLayerMouseEvent) => {
     const features = e.features;
@@ -139,6 +146,32 @@ export default function StopMap() {
           maxzoom={20}
         />
 
+        <Layer
+          id="stops-favourite-highlight"
+          type="circle"
+          minzoom={11}
+          source="stops-source"
+          source-layer="stops"
+          filter={["all", stopLayerFilter, favouriteFilter]}
+          paint={{
+            "circle-color": "#FFD700",
+            "circle-radius": [
+              "interpolate",
+              ["linear"],
+              ["zoom"],
+              13,
+              10,
+              16,
+              12,
+              18,
+              16,
+            ],
+            "circle-opacity": 0.4,
+            "circle-stroke-color": "#FFD700",
+            "circle-stroke-width": 2,
+          }}
+        />
+
         <Layer
           id="stops"
           type="symbol"
@@ -161,6 +194,17 @@ export default function StopMap() {
             ],
             "icon-allow-overlap": true,
             "icon-ignore-placement": true,
+            "symbol-sort-key": [
+              "match",
+              ["get", "transitKind"],
+              "bus",
+              3,
+              "coach",
+              2,
+              "train",
+              1,
+              0,
+            ],
           }}
         />
 
-- 
cgit v1.3

