mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-06 18:54:17 +00:00
feat(roadtrip): give the corridor hits their own icons, and say when a stretch went unsearched
A petrol station and a campsite both came back as the same nameless grey dot, because the road categories only existed on the server: the map falls back to grey for a category it does not know. They now sit in the client's category table too — with the pump, the bolt, the parking sign and the tent, in their own colours — which both map renderers and the popup read from the same place. They stay out of the explore pill's own list on purpose: that pill offers what a city visit needs, and while road trip mode is on it is not on screen anyway. The search also stayed quiet when only some boxes failed, which reads as "no fuel on this stretch" when the truth is that nobody looked. A partial failure now says how many stretches went unanswered.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Utensils, Coffee, Wine, BedDouble, Camera, Landmark, Trees, Ticket, type LucideIcon } from 'lucide-react'
|
||||
import { Utensils, Coffee, Wine, BedDouble, Camera, Landmark, Trees, Ticket, Fuel, Zap, ParkingSquare, Tent, type LucideIcon } from 'lucide-react'
|
||||
|
||||
// The POI categories shown in the map "explore" pill. The `key` is the contract
|
||||
// with the server (CATEGORY_OSM_FILTERS in mapsService.ts) — the OSM tag mapping
|
||||
@@ -22,8 +22,21 @@ export const POI_CATEGORIES: PoiCategory[] = [
|
||||
{ key: 'activity', labelKey: 'poi.cat.activities', Icon: Ticket, color: '#F59E0B' },
|
||||
]
|
||||
|
||||
/**
|
||||
* What a drive needs. Kept out of POI_CATEGORIES on purpose: these are not offered by
|
||||
* the explore pill, they are what the road trip corridor searches for. They are in the
|
||||
* lookup below all the same, so a hit drawn on the map gets its own icon and colour
|
||||
* instead of the nameless grey dot an unknown category falls back to.
|
||||
*/
|
||||
export const ROADTRIP_POI_CATEGORIES: PoiCategory[] = [
|
||||
{ key: 'fuel', labelKey: 'roadtrip.poi.fuel', Icon: Fuel, color: '#0EA5E9' },
|
||||
{ key: 'charging', labelKey: 'roadtrip.poi.charging', Icon: Zap, color: '#10B981' },
|
||||
{ key: 'rest_area', labelKey: 'roadtrip.poi.rest', Icon: ParkingSquare, color: '#64748B' },
|
||||
{ key: 'campsite', labelKey: 'roadtrip.poi.campsite', Icon: Tent, color: '#65A30D' },
|
||||
]
|
||||
|
||||
export const POI_CATEGORY_BY_KEY: Record<string, PoiCategory> = Object.fromEntries(
|
||||
POI_CATEGORIES.map(c => [c.key, c]),
|
||||
[...POI_CATEGORIES, ...ROADTRIP_POI_CATEGORIES].map(c => [c.key, c]),
|
||||
)
|
||||
|
||||
// One POI result from /api/maps/pois (mirror of the server's OverpassPoi).
|
||||
|
||||
@@ -214,6 +214,13 @@ export default function RoadtripCorridorPanel({ corridor, routes, onAddPoi }: Ro
|
||||
<AlertTriangle size={12} className="mt-0.5 shrink-0" aria-hidden />
|
||||
{t('roadtrip.poi.failed')}
|
||||
</p>
|
||||
) : search.failedAreas > 0 ? (
|
||||
// Some boxes answered and some did not. Saying so is the difference between
|
||||
// "there is no fuel on this stretch" and "nobody looked at this stretch".
|
||||
<p className="flex items-start gap-1.5 text-caption text-warning">
|
||||
<AlertTriangle size={12} className="mt-0.5 shrink-0" aria-hidden />
|
||||
{t('roadtrip.poi.partial', { count: search.failedAreas })}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ export interface CorridorSearch {
|
||||
loading: boolean
|
||||
/** True when the route was longer than the request budget and the tail was left out. */
|
||||
capped: boolean
|
||||
/** Boxes the place search could not answer — a partial result is still shown. */
|
||||
failedAreas: number
|
||||
error: boolean
|
||||
search: () => void
|
||||
clear: () => void
|
||||
@@ -58,6 +60,7 @@ export function useCorridorPois(line: LatLng[], categories: string[], widthKm: n
|
||||
const [progress, setProgress] = useState({ done: 0, total: 0 })
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [capped, setCapped] = useState(false)
|
||||
const [failedAreas, setFailedAreas] = useState(0)
|
||||
const [error, setError] = useState(false)
|
||||
const abortRef = useRef<AbortController | null>(null)
|
||||
const runIdRef = useRef(0)
|
||||
@@ -68,6 +71,7 @@ export function useCorridorPois(line: LatLng[], categories: string[], widthKm: n
|
||||
setProgress({ done: 0, total: 0 })
|
||||
setLoading(false)
|
||||
setCapped(false)
|
||||
setFailedAreas(0)
|
||||
setError(false)
|
||||
}, [])
|
||||
|
||||
@@ -90,6 +94,7 @@ export function useCorridorPois(line: LatLng[], categories: string[], widthKm: n
|
||||
const tiles = allTiles.slice(0, MAX_TILES)
|
||||
|
||||
setCapped(allTiles.length > tiles.length)
|
||||
setFailedAreas(0)
|
||||
setError(false)
|
||||
setResults([])
|
||||
setLoading(true)
|
||||
@@ -124,6 +129,7 @@ export function useCorridorPois(line: LatLng[], categories: string[], widthKm: n
|
||||
// One dead mirror or one clamped box must not empty the whole search; the run
|
||||
// is only called a failure if every request failed.
|
||||
failures++
|
||||
setFailedAreas(failures)
|
||||
}
|
||||
done++
|
||||
if (controller.signal.aborted || runId !== runIdRef.current) return
|
||||
@@ -142,5 +148,5 @@ export function useCorridorPois(line: LatLng[], categories: string[], widthKm: n
|
||||
|
||||
useEffect(() => () => abortRef.current?.abort(), [])
|
||||
|
||||
return { results, progress, loading, capped, error, search, clear }
|
||||
return { results, progress, loading, capped, failedAreas, error, search, clear }
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': 'ابحث على طول المسار',
|
||||
'roadtrip.poi.searching': 'جارٍ البحث {done} من {total}',
|
||||
'roadtrip.poi.capped': 'المسار طويل — تم البحث في الجزء الأول فقط.',
|
||||
'roadtrip.poi.partial': 'تعذّر البحث في {count} من المقاطع — لم يستجب البحث عن الأماكن.',
|
||||
'roadtrip.poi.failed': 'البحث عن الأماكن لا يستجيب حاليًا.',
|
||||
'roadtrip.poi.empty': 'اختر ما تحتاجه ثم ابحث.',
|
||||
'roadtrip.poi.add': 'إضافة',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': 'Buscar ao longo da rota',
|
||||
'roadtrip.poi.searching': 'Buscando {done} de {total}',
|
||||
'roadtrip.poi.capped': 'A rota é longa — apenas o primeiro trecho foi pesquisado.',
|
||||
'roadtrip.poi.partial': 'Não foi possível pesquisar {count} trechos — a busca de locais não respondeu.',
|
||||
'roadtrip.poi.failed': 'A busca de locais não está respondendo agora.',
|
||||
'roadtrip.poi.empty': 'Escolha o que precisa e pesquise.',
|
||||
'roadtrip.poi.add': 'Adicionar',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': 'Cerca al llarg de la ruta',
|
||||
'roadtrip.poi.searching': 'Cercant {done} de {total}',
|
||||
'roadtrip.poi.capped': 'La ruta és llarga: només s’ha cercat el primer tram.',
|
||||
'roadtrip.poi.partial': 'No s’han pogut cercar {count} trams: la cerca de llocs no ha respost.',
|
||||
'roadtrip.poi.failed': 'La cerca de llocs no respon ara mateix.',
|
||||
'roadtrip.poi.empty': 'Tria què necessites i cerca.',
|
||||
'roadtrip.poi.add': 'Afegeix',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': 'Hledat podél trasy',
|
||||
'roadtrip.poi.searching': 'Hledání {done} z {total}',
|
||||
'roadtrip.poi.capped': 'Trasa je dlouhá — prohledán byl jen první úsek.',
|
||||
'roadtrip.poi.partial': '{count} úseků se nepodařilo prohledat — vyhledávání míst neodpovědělo.',
|
||||
'roadtrip.poi.failed': 'Vyhledávání míst právě neodpovídá.',
|
||||
'roadtrip.poi.empty': 'Vyberte, co potřebujete, a hledejte.',
|
||||
'roadtrip.poi.add': 'Přidat',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': 'Entlang der Route suchen',
|
||||
'roadtrip.poi.searching': 'Suche {done} von {total}',
|
||||
'roadtrip.poi.capped': 'Die Route ist lang — nur der erste Abschnitt wurde durchsucht.',
|
||||
'roadtrip.poi.partial': '{count} Abschnitte konnten nicht durchsucht werden — die Ortssuche hat nicht geantwortet.',
|
||||
'roadtrip.poi.failed': 'Die Ortssuche antwortet gerade nicht.',
|
||||
'roadtrip.poi.empty': 'Wähle aus, was du brauchst, und suche.',
|
||||
'roadtrip.poi.add': 'Übernehmen',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': 'Search along the route',
|
||||
'roadtrip.poi.searching': 'Searching {done} of {total}',
|
||||
'roadtrip.poi.capped': 'The route is long — only the first stretch was searched.',
|
||||
'roadtrip.poi.partial': '{count} stretches could not be searched — the place search did not answer.',
|
||||
'roadtrip.poi.failed': 'The place search is not answering right now.',
|
||||
'roadtrip.poi.empty': 'Pick what you need and search.',
|
||||
'roadtrip.poi.add': 'Add',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': 'Buscar a lo largo de la ruta',
|
||||
'roadtrip.poi.searching': 'Buscando {done} de {total}',
|
||||
'roadtrip.poi.capped': 'La ruta es larga: solo se buscó en el primer tramo.',
|
||||
'roadtrip.poi.partial': 'No se pudieron buscar {count} tramos: la búsqueda de lugares no respondió.',
|
||||
'roadtrip.poi.failed': 'La búsqueda de lugares no responde ahora mismo.',
|
||||
'roadtrip.poi.empty': 'Elige lo que necesitas y busca.',
|
||||
'roadtrip.poi.add': 'Añadir',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': 'Chercher le long du trajet',
|
||||
'roadtrip.poi.searching': 'Recherche {done} sur {total}',
|
||||
'roadtrip.poi.capped': 'L’itinéraire est long : seule la première portion a été parcourue.',
|
||||
'roadtrip.poi.partial': '{count} tronçons n’ont pas pu être parcourus : la recherche de lieux n’a pas répondu.',
|
||||
'roadtrip.poi.failed': 'La recherche de lieux ne répond pas pour le moment.',
|
||||
'roadtrip.poi.empty': 'Choisissez ce qu’il vous faut, puis lancez la recherche.',
|
||||
'roadtrip.poi.add': 'Ajouter',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': 'Αναζήτηση κατά μήκος της διαδρομής',
|
||||
'roadtrip.poi.searching': 'Αναζήτηση {done} από {total}',
|
||||
'roadtrip.poi.capped': 'Η διαδρομή είναι μεγάλη — αναζητήθηκε μόνο το πρώτο τμήμα.',
|
||||
'roadtrip.poi.partial': 'Δεν ήταν δυνατή η αναζήτηση σε {count} τμήματα — η αναζήτηση τοποθεσιών δεν απάντησε.',
|
||||
'roadtrip.poi.failed': 'Η αναζήτηση τοποθεσιών δεν απαντά αυτή τη στιγμή.',
|
||||
'roadtrip.poi.empty': 'Διαλέξτε τι χρειάζεστε και αναζητήστε.',
|
||||
'roadtrip.poi.add': 'Προσθήκη',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': 'Keresés az útvonal mentén',
|
||||
'roadtrip.poi.searching': 'Keresés {done}/{total}',
|
||||
'roadtrip.poi.capped': 'Az útvonal hosszú – csak az első szakaszon kerestünk.',
|
||||
'roadtrip.poi.partial': '{count} szakaszon nem sikerült keresni – a helykeresés nem válaszolt.',
|
||||
'roadtrip.poi.failed': 'A helykeresés most nem válaszol.',
|
||||
'roadtrip.poi.empty': 'Válaszd ki, mire van szükséged, és keress.',
|
||||
'roadtrip.poi.add': 'Hozzáadás',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': 'Cari di sepanjang rute',
|
||||
'roadtrip.poi.searching': 'Mencari {done} dari {total}',
|
||||
'roadtrip.poi.capped': 'Rute panjang — hanya bagian pertama yang dicari.',
|
||||
'roadtrip.poi.partial': '{count} ruas tidak dapat dicari — pencarian tempat tidak merespons.',
|
||||
'roadtrip.poi.failed': 'Pencarian tempat sedang tidak merespons.',
|
||||
'roadtrip.poi.empty': 'Pilih yang Anda butuhkan lalu cari.',
|
||||
'roadtrip.poi.add': 'Tambah',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': 'Cerca lungo il percorso',
|
||||
'roadtrip.poi.searching': 'Ricerca {done} di {total}',
|
||||
'roadtrip.poi.capped': 'Il percorso è lungo: è stato cercato solo il primo tratto.',
|
||||
'roadtrip.poi.partial': 'Non è stato possibile cercare in {count} tratti: la ricerca dei luoghi non ha risposto.',
|
||||
'roadtrip.poi.failed': 'La ricerca dei luoghi non risponde al momento.',
|
||||
'roadtrip.poi.empty': 'Scegli cosa ti serve e cerca.',
|
||||
'roadtrip.poi.add': 'Aggiungi',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': 'ルート沿いを検索',
|
||||
'roadtrip.poi.searching': '検索中 {done}/{total}',
|
||||
'roadtrip.poi.capped': 'ルートが長いため、最初の区間のみ検索しました。',
|
||||
'roadtrip.poi.partial': '{count} 区間を検索できませんでした。場所の検索が応答しませんでした。',
|
||||
'roadtrip.poi.failed': '場所の検索が現在応答していません。',
|
||||
'roadtrip.poi.empty': '必要なものを選んで検索してください。',
|
||||
'roadtrip.poi.add': '追加',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': '경로 주변 검색',
|
||||
'roadtrip.poi.searching': '검색 중 {done}/{total}',
|
||||
'roadtrip.poi.capped': '경로가 길어 앞부분만 검색했습니다.',
|
||||
'roadtrip.poi.partial': '{count}개 구간을 검색하지 못했습니다. 장소 검색이 응답하지 않았습니다.',
|
||||
'roadtrip.poi.failed': '장소 검색이 지금 응답하지 않습니다.',
|
||||
'roadtrip.poi.empty': '필요한 항목을 고르고 검색하세요.',
|
||||
'roadtrip.poi.add': '추가',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': 'Langs de route zoeken',
|
||||
'roadtrip.poi.searching': 'Zoeken {done} van {total}',
|
||||
'roadtrip.poi.capped': 'De route is lang — alleen het eerste deel is doorzocht.',
|
||||
'roadtrip.poi.partial': '{count} stukken konden niet worden doorzocht — de plaatszoekfunctie antwoordde niet.',
|
||||
'roadtrip.poi.failed': 'De plaatszoekfunctie reageert nu niet.',
|
||||
'roadtrip.poi.empty': 'Kies wat je nodig hebt en zoek.',
|
||||
'roadtrip.poi.add': 'Toevoegen',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': 'Szukaj wzdłuż trasy',
|
||||
'roadtrip.poi.searching': 'Szukanie {done} z {total}',
|
||||
'roadtrip.poi.capped': 'Trasa jest długa — przeszukano tylko pierwszy odcinek.',
|
||||
'roadtrip.poi.partial': 'Nie udało się przeszukać {count} odcinków — wyszukiwanie miejsc nie odpowiedziało.',
|
||||
'roadtrip.poi.failed': 'Wyszukiwanie miejsc chwilowo nie odpowiada.',
|
||||
'roadtrip.poi.empty': 'Wybierz, czego potrzebujesz, i szukaj.',
|
||||
'roadtrip.poi.add': 'Dodaj',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': 'Искать вдоль маршрута',
|
||||
'roadtrip.poi.searching': 'Поиск {done} из {total}',
|
||||
'roadtrip.poi.capped': 'Маршрут длинный — просмотрен только первый участок.',
|
||||
'roadtrip.poi.partial': 'Не удалось просмотреть участков: {count} — поиск мест не ответил.',
|
||||
'roadtrip.poi.failed': 'Поиск мест сейчас не отвечает.',
|
||||
'roadtrip.poi.empty': 'Выберите нужное и запустите поиск.',
|
||||
'roadtrip.poi.add': 'Добавить',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': 'Sök längs rutten',
|
||||
'roadtrip.poi.searching': 'Söker {done} av {total}',
|
||||
'roadtrip.poi.capped': 'Rutten är lång – bara första sträckan genomsöktes.',
|
||||
'roadtrip.poi.partial': '{count} sträckor kunde inte genomsökas – platssökningen svarade inte.',
|
||||
'roadtrip.poi.failed': 'Platssökningen svarar inte just nu.',
|
||||
'roadtrip.poi.empty': 'Välj vad du behöver och sök.',
|
||||
'roadtrip.poi.add': 'Lägg till',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': 'Rota boyunca ara',
|
||||
'roadtrip.poi.searching': 'Aranıyor {done}/{total}',
|
||||
'roadtrip.poi.capped': 'Rota uzun — yalnızca ilk bölüm arandı.',
|
||||
'roadtrip.poi.partial': '{count} bölüm aranamadı — yer araması yanıt vermedi.',
|
||||
'roadtrip.poi.failed': 'Yer araması şu anda yanıt vermiyor.',
|
||||
'roadtrip.poi.empty': 'Neye ihtiyacın olduğunu seç ve ara.',
|
||||
'roadtrip.poi.add': 'Ekle',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': 'Шукати вздовж маршруту',
|
||||
'roadtrip.poi.searching': 'Пошук {done} з {total}',
|
||||
'roadtrip.poi.capped': 'Маршрут довгий — переглянуто лише перший відрізок.',
|
||||
'roadtrip.poi.partial': 'Не вдалося переглянути відрізків: {count} — пошук місць не відповів.',
|
||||
'roadtrip.poi.failed': 'Пошук місць зараз не відповідає.',
|
||||
'roadtrip.poi.empty': 'Оберіть потрібне й почніть пошук.',
|
||||
'roadtrip.poi.add': 'Додати',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': 'Tìm dọc lộ trình',
|
||||
'roadtrip.poi.searching': 'Đang tìm {done}/{total}',
|
||||
'roadtrip.poi.capped': 'Lộ trình dài — chỉ đoạn đầu được tìm kiếm.',
|
||||
'roadtrip.poi.partial': 'Không tìm được {count} đoạn — tìm kiếm địa điểm không phản hồi.',
|
||||
'roadtrip.poi.failed': 'Tìm kiếm địa điểm hiện không phản hồi.',
|
||||
'roadtrip.poi.empty': 'Chọn thứ bạn cần rồi tìm.',
|
||||
'roadtrip.poi.add': 'Thêm',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': '沿路線搜尋',
|
||||
'roadtrip.poi.searching': '搜尋中 {done}/{total}',
|
||||
'roadtrip.poi.capped': '路線較長,僅搜尋了前段。',
|
||||
'roadtrip.poi.partial': '有 {count} 段無法搜尋 — 地點搜尋沒有回應。',
|
||||
'roadtrip.poi.failed': '地點搜尋暫時沒有回應。',
|
||||
'roadtrip.poi.empty': '選擇你需要的,然後搜尋。',
|
||||
'roadtrip.poi.add': '新增',
|
||||
|
||||
@@ -25,6 +25,7 @@ const roadtrip: TranslationStrings = {
|
||||
'roadtrip.poi.search': '沿路线搜索',
|
||||
'roadtrip.poi.searching': '搜索中 {done}/{total}',
|
||||
'roadtrip.poi.capped': '路线较长,仅搜索了前段。',
|
||||
'roadtrip.poi.partial': '有 {count} 段无法搜索 — 地点搜索没有响应。',
|
||||
'roadtrip.poi.failed': '地点搜索暂时没有响应。',
|
||||
'roadtrip.poi.empty': '选择你需要的,然后搜索。',
|
||||
'roadtrip.poi.add': '添加',
|
||||
|
||||
Reference in New Issue
Block a user