--- import Base from '../../layouts/Base.astro'; import VigilanceChip from '../../components/VigilanceChip.astro'; import VigilanceLegend from '../../components/VigilanceLegend.astro'; import { getVigilanceSnapshot, alertsForDepartement } from '../../lib/vigilance'; import { getDepartement, isDrom } from '../../lib/departements'; import { PHENOMENA, COLOR_LABEL } from '../../lib/phenomena'; import { ADVICE, EMERGENCY_NUMBERS } from '../../lib/advice'; import { getClimatoForDepartement } from '../../lib/climato'; import { computeAnomaly, normaleForDate, normalesForRange } from '../../lib/normales'; import { getHourlyForDepartement } from '../../lib/observations'; import TemperatureChartInteractive from '../../components/TemperatureChartInteractive.astro'; import AnomalyBadge from '../../components/AnomalyBadge.astro'; export const prerender = false; const { code } = Astro.params; const dept = code ? getDepartement(code.toUpperCase()) : undefined; if (!dept) { return new Response('Département introuvable', { status: 404 }); } const drom = isDrom(dept.code); let snapshot; let error: string | null = null; if (!drom) { try { snapshot = await getVigilanceSnapshot(); } catch (e) { error = (e as Error).message; } } let climato = null; let anomaly = null; let hourly = null; let normales7: Array<{ tx: number | null; tn: number | null }> = []; let normales30: Array<{ tx: number | null; tn: number | null }> = []; let normaleHourly: { tx: number | null; tn: number | null } | null = null; if (!drom) { try { climato = await getClimatoForDepartement(dept.code); if (climato?.days?.length) { anomaly = await computeAnomaly(dept.code, climato.days); } } catch (e) { console.warn('climato fetch failed for', dept.code, (e as Error).message); } try { hourly = await getHourlyForDepartement(dept.code, 24); } catch (e) { console.warn('hourly fetch failed for', dept.code, (e as Error).message); } } const last7 = climato?.days?.slice(-7) ?? []; const last30 = climato?.days?.slice(-30) ?? []; if (!drom) { const series7 = await normalesForRange(dept.code, last7.map((d) => d.date)); normales7 = series7.map((n) => ({ tx: n?.tx ?? null, tn: n?.tn ?? null })); const series30 = await normalesForRange(dept.code, last30.map((d) => d.date)); normales30 = series30.map((n) => ({ tx: n?.tx ?? null, tn: n?.tn ?? null })); // Normale "du jour courant" (pour overlay du graphe 24h, ligne horizontale) normaleHourly = await normaleForDate(dept.code, new Date()); if (normaleHourly) normaleHourly = { tx: normaleHourly.tx, tn: normaleHourly.tn }; } const stationLabel = hourly ? `${hourly.stationName} (${hourly.distKm} km)` : null; const today = snapshot ? alertsForDepartement(snapshot, dept.code, 'J') : []; const tomorrow = snapshot ? alertsForDepartement(snapshot, dept.code, 'J1') : []; const highest = today[0]; const adviceFor = highest && ADVICE[highest.phenomenonId]; ---
← Retour à la carte

{dept.name}

{dept.region} — département {dept.code}

{drom && (

Vigilance Outre-mer non couverte par cette source

Les départements et régions d'Outre-mer disposent de leur propre dispositif Vigilance, géré par les centres météorologiques locaux de Météo France. Ces données ne sont pas (encore) rediffusées en open data au même format que la métropole.

Voir la Vigilance officielle Outre-mer →

)} {!drom && error &&

Données indisponibles : {error}

} { !drom && !error && today.length === 0 && (

Aucune vigilance particulière aujourd'hui.

Le département est en niveau vert pour tous les phénomènes.

) } { !drom && !error && today.length > 0 && ( <>

Alertes en cours

) } { !drom && !error && tomorrow.length > 0 && (

Prévision pour demain

) }
{ climato && climato.days.length > 0 && (

Températures récentes

{anomaly && (
)}

Sources : Météo France — observations SYNOP horaires (onglet 24 h) et données climatologiques de base quotidiennes (7 j / 30 j), agrégées par moyenne sur les stations du département. Normales calculées sur 1991-2020 (référence WMO).

) } { adviceFor && (

Conseils — {PHENOMENA[highest!.phenomenonId].label}

{adviceFor.intro}

{adviceFor.blocks.map((block) => (

{block.title}

    {block.items.map((item) => (
  • {item}
  • ))}
))}
{adviceFor.emergency.length > 0 && (

En cas d'urgence

    {adviceFor.emergency.map((e) => (
  • {e}
  • ))}
)}

Numéros utiles

{EMERGENCY_NUMBERS.map((n) => (
{n.num} {n.label}
))}
) }