Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions weather-voodoo/src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,18 @@ input[type='search'] {
min-height: 280px;
border-radius: 0;
}
/* Hide controls card in fullscreen — map only */
/* Show controls card in fullscreen but compact — needed for waypoint
editing, route info, search fields */
.map-stage.fullscreen > .card:not(.map-card) {
display: none;
flex: 0 0 auto;
margin: 0;
border-radius: 0;
border-left: none;
border-right: none;
border-top: none;
padding: 0.4rem 0.6rem;
font-size: 0.9em;
overflow-x: auto;
}
.map-fs-btn {
position: absolute;
Expand Down
4 changes: 2 additions & 2 deletions weather-voodoo/src/lib/components/MapView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@
if (fitTarget.length >= 2) {
const bounds = new maplibregl.LngLatBounds();
fitTarget.forEach((p) => bounds.extend([p.lon, p.lat]));
map.fitBounds(bounds, { padding: 60, maxZoom: 11, duration: 400 });
map.fitBounds(bounds, { padding: 60, maxZoom: 16, duration: 400 });
} else if (markers.length === 1) {
map.flyTo({ center: [markers[0].lon, markers[0].lat], zoom: 11, duration: 400 });
}
Expand Down Expand Up @@ -448,7 +448,7 @@
id: 'route-line',
type: 'line',
source: 'route-src',
paint: { 'line-color': polylineColor, 'line-width': 3, 'line-opacity': 0.85 }
paint: { 'line-color': polylineColor, 'line-width': 5, 'line-opacity': 0.9 }
});
}
}
Expand Down
10 changes: 8 additions & 2 deletions weather-voodoo/src/lib/components/RouteView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
type RouteMeta =
| { kind: 'ferry'; lengthKm: number; wayCount: number; originSnapKm: number; destinationSnapKm: number }
| { kind: 'sea'; lengthKm: number; greatCircleKm: number; detourRatio: number }
| { kind: 'straight'; ferryFallback?: string; ferryDetail?: string };
| { kind: 'trail'; lengthKm: number; wayCount: number; hikeWayCount: number; bikeWayCount: number; originSnapKm: number; destinationSnapKm: number }
| { kind: 'straight'; ferryFallback?: string; ferryDetail?: string; trailFallback?: string; trailDetail?: string };
let result = $state<{
hours: FusedHour[];
timezone: string;
Expand Down Expand Up @@ -212,14 +213,19 @@
{t('route.ferryPrefix')} <strong>{result.route.lengthKm.toFixed(0)} km</strong>
<span title={t('route.waysTitle')}>{t('route.waysSuffix', { n: result.route.wayCount })}</span>
</div>
{:else if result?.route.kind === 'trail'}
<div class="muted route-meta">
{t('route.trailPrefix')} <strong>{result.route.lengthKm.toFixed(0)} km</strong>
{t('route.trailWaysSuffix', { hike: result.route.hikeWayCount, bike: result.route.bikeWayCount })}
</div>
{:else if result?.route.kind === 'sea'}
<div class="muted route-meta">
{t('route.seaPrefix')} <strong>{result.route.lengthKm.toFixed(0)} km</strong>
<span title={t('route.detourTitle')}>(×{result.route.detourRatio.toFixed(2)} {t('route.greatCircleSuffix')})</span>
</div>
{:else if view.from && view.to && result}
<div class="muted route-meta">
{t('route.straight')}{#if result.route.kind === 'straight' && result.route.ferryFallback} ({t('route.ferryLabel')}: {result.route.ferryFallback}{#if result.route.ferryDetail} · {result.route.ferryDetail}{/if}){/if} {t('route.straightHint')}
{t('route.straight')}{#if result.route.kind === 'straight' && result.route.ferryFallback} ({t('route.ferryLabel')}: {result.route.ferryFallback}{#if result.route.ferryDetail} · {result.route.ferryDetail}{/if}){/if}{#if result.route.kind === 'straight' && result.route.trailFallback} ({t('route.trailLabel')}: {result.route.trailFallback}{#if result.route.trailDetail} · {result.route.trailDetail}{/if}){/if} {t('route.straightHint')}
</div>
{/if}
</div>
Expand Down
2 changes: 2 additions & 0 deletions weather-voodoo/src/lib/components/WaypointsView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
legCount: number;
ferryLegs: number;
seaLegs: number;
trailLegs: number;
straightLegs: number;
totalKm: number;
};
Expand Down Expand Up @@ -340,6 +341,7 @@
· {t(result.route.legCount === 1 ? 'waypoints.legsOne' : 'waypoints.legsMany', { n: result.route.legCount })}
{#if result.route.ferryLegs > 0} · ⛴️ {t('waypoints.ferryLegs', { n: result.route.ferryLegs })}{/if}
{#if result.route.seaLegs > 0} · ⚓ {t('waypoints.seaLegs', { n: result.route.seaLegs })}{/if}
{#if result.route.trailLegs > 0} · 🥾 {t('waypoints.trailLegs', { n: result.route.trailLegs })}{/if}
{#if result.route.straightLegs > 0} · 📐 {t('waypoints.straightLegs', { n: result.route.straightLegs })}{/if}
</div>
{:else if editing && draft.length >= 2}
Expand Down
10 changes: 9 additions & 1 deletion weather-voodoo/src/lib/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export type Dict = {
legsMany: string;
ferryLegs: string;
seaLegs: string;
trailLegs: string;
straightLegs: string;
straightPreview: string;
editAriaLabel: string;
Expand All @@ -119,6 +120,9 @@ export type Dict = {
straight: string;
straightHint: string;
ferryLabel: string;
trailPrefix: string;
trailWaysSuffix: string;
trailLabel: string;
};
days: { today: string; tomorrow: string; d2: string };
share: {
Expand Down Expand Up @@ -431,6 +435,7 @@ export const en: Dict = {
legsMany: '{n} legs',
ferryLegs: '{n} ferry',
seaLegs: '{n} open-ocean',
trailLegs: '{n} trail',
straightLegs: '{n} straight',
straightPreview: '📐 Straight-line preview while editing — press Done to compute the real route.',
editAriaLabel: 'Edit waypoint',
Expand All @@ -451,7 +456,10 @@ export const en: Dict = {
greatCircleSuffix: 'the great-circle line',
straight: "📐 Straight-line route — couldn't snap to a sea-route network.",
straightHint: 'Sample points may cross land.',
ferryLabel: 'ferry'
ferryLabel: 'ferry',
trailPrefix: '🥾 Trail route via OpenStreetMap:',
trailWaysSuffix: '({hike} hike · {bike} bike ways)',
trailLabel: 'trail'
},
days: {
today: 'Today',
Expand Down
6 changes: 5 additions & 1 deletion weather-voodoo/src/lib/i18n/ro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export const ro: Dict = {
legsMany: '{n} segmente',
ferryLegs: '{n} feribot',
seaLegs: '{n} larg',
trailLegs: '{n} traseu',
straightLegs: '{n} drept',
straightPreview: '📐 Previzualizare în linie dreaptă în timpul editării — apasă Gata pentru a calcula ruta reală.',
editAriaLabel: 'Editează punctul de trecere',
Expand All @@ -127,7 +128,10 @@ export const ro: Dict = {
greatCircleSuffix: 'din linia great-circle',
straight: '📐 Rută în linie dreaptă — nu am putut potrivi cu o rețea de rute marine.',
straightHint: 'Punctele de eșantionare pot traversa uscatul.',
ferryLabel: 'feribot'
ferryLabel: 'feribot',
trailPrefix: '🥾 Traseu drumeție via OpenStreetMap:',
trailWaysSuffix: '({hike} drumeție · {bike} bicicletă)',
trailLabel: 'traseu'
},
days: {
today: 'Azi',
Expand Down
6 changes: 5 additions & 1 deletion weather-voodoo/src/lib/i18n/th.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export const th: Dict = {
legsMany: '{n} ช่วง',
ferryLegs: '{n} เฟอร์รี',
seaLegs: '{n} ทะเลเปิด',
trailLegs: '{n} เส้นทาง',
straightLegs: '{n} เส้นตรง',
straightPreview: '📐 เส้นตรงตัวอย่างขณะแก้ไข — กดเสร็จเพื่อคำนวณเส้นทางจริง',
editAriaLabel: 'แก้ไขจุดผ่าน',
Expand All @@ -127,7 +128,10 @@ export const th: Dict = {
greatCircleSuffix: 'ของเส้น great-circle',
straight: '📐 เส้นทางตรง — ไม่สามารถ snap เข้ากับเครือข่ายเส้นทางทะเลได้',
straightHint: 'จุดสุ่มอาจข้ามแผ่นดิน',
ferryLabel: 'เฟอร์รี'
ferryLabel: 'เฟอร์รี',
trailPrefix: '🥾 เส้นทางเดินป่าผ่าน OpenStreetMap:',
trailWaysSuffix: '({hike} เดินเท้า · {bike} จักรยาน)',
trailLabel: 'เส้นทาง'
},
days: {
today: 'วันนี้',
Expand Down
59 changes: 49 additions & 10 deletions weather-voodoo/src/lib/server/openmeteo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,25 +174,64 @@ export async function fetchMarine(lat: number, lon: number, days = 3): Promise<M
}

const GEOCODE_URL = 'https://geocoding-api.open-meteo.com/v1/search';
const NOMINATIM_URL = 'https://nominatim.openstreetmap.org/search';

export type GeocodeResult = { name: string; lat: number; lon: number; country?: string; admin1?: string };

export async function geocode(query: string, limit = 5): Promise<GeocodeResult[]> {
if (!query.trim()) return [];
const results = await geocodeOpenMeteo(query, limit);
if (results.length > 0) return results;
return geocodeNominatim(query, limit);
}

async function geocodeOpenMeteo(query: string, limit: number): Promise<GeocodeResult[]> {
const params = new URLSearchParams({
name: query,
count: limit.toString(),
language: 'en',
format: 'json'
});
const res = await fetch(`${GEOCODE_URL}?${params.toString()}`);
if (!res.ok) return [];
const data = (await res.json()) as { results?: { name: string; latitude: number; longitude: number; country?: string; admin1?: string }[] };
return (data.results ?? []).map((r) => ({
name: r.name,
lat: r.latitude,
lon: r.longitude,
country: r.country,
admin1: r.admin1
}));
try {
const res = await fetch(`${GEOCODE_URL}?${params.toString()}`);
if (!res.ok) return [];
const data = (await res.json()) as { results?: { name: string; latitude: number; longitude: number; country?: string; admin1?: string }[] };
return (data.results ?? []).map((r) => ({
name: r.name,
lat: r.latitude,
lon: r.longitude,
country: r.country,
admin1: r.admin1
}));
} catch {
return [];
}
}

async function geocodeNominatim(query: string, limit: number): Promise<GeocodeResult[]> {
const params = new URLSearchParams({
q: query,
format: 'jsonv2',
limit: limit.toString(),
addressdetails: '1'
});
try {
const res = await fetch(`${NOMINATIM_URL}?${params.toString()}`, {
headers: { 'user-agent': 'weather-voodoo (https://weather-voodoo.vercel.app)' }
});
if (!res.ok) return [];
const data = (await res.json()) as { display_name: string; lat: string; lon: string; address?: { country?: string; state?: string } }[];
return data.map((r) => {
const parts = r.display_name.split(',').map((s) => s.trim());
return {
name: parts[0] ?? r.display_name,
lat: Number(r.lat),
lon: Number(r.lon),
country: r.address?.country,
admin1: r.address?.state ?? parts[1]
};
});
} catch {
return [];
}
}
Loading