From 199e834227d7ba1e26ce80f4cf659484fd1deacb Mon Sep 17 00:00:00 2001 From: Mina Choi Date: Fri, 23 Oct 2026 09:13:12 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=8B=A8=ED=92=8D=20=EC=A7=80=EB=8F=84?= =?UTF-8?q?=20=EC=A0=9C=EB=AA=A9=EC=9D=84=20'=EC=A7=80=EA=B8=88=20?= =?UTF-8?q?=EC=A0=88=EC=A0=95:=20=EC=8B=9C=C2=B7=EB=8F=84'=EB=A1=9C,=20?= =?UTF-8?q?=EB=B3=B4=EC=97=AC=20=EC=A3=BC=EB=8A=94=20=EA=B8=B0=EA=B0=84?= =?UTF-8?q?=EC=9D=84=20=EB=AA=85=EC=86=8C=20=EC=A0=88=EC=A0=95=EC=9D=BC?= =?UTF-8?q?=EC=97=90=20=EB=A7=9E=EC=B6=B0(=EC=B2=AB=20=EB=8B=A8=ED=92=8D?= =?UTF-8?q?=20=EC=8B=9C=EC=9E=91~=EB=A7=88=EC=A7=80=EB=A7=89=20=EC=A0=88?= =?UTF-8?q?=EC=A0=95=207=EC=9D=BC=20=EB=92=A4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/b/foliageMap.tsx | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/frontend/src/b/foliageMap.tsx b/frontend/src/b/foliageMap.tsx index 28b9eba..9af1c24 100644 --- a/frontend/src/b/foliageMap.tsx +++ b/frontend/src/b/foliageMap.tsx @@ -14,8 +14,6 @@ const MAP = { lon0: 124.5, lat1: 38.75, k: 0.809017, s: 153.5327, ox: 40, oy: 62 const FIRST_DAYS = 14 const PEAK_DAYS = 3 const PEAK_AFTER = 7 -const SEASON = { from: '09-20', to: '11-25' } -const SEOUL = { lat: 37.566, lon: 126.978 } // 이름표가 피해 갈 점 반지름(px) const DOT_R = 7 @@ -47,6 +45,20 @@ function stage(m: Spot, today: string): Stage { } const md = (iso: string) => `${Number(iso.slice(5, 7))}/${Number(iso.slice(8, 10))}` +const province = (m: Spot) => m.region.split(' ')[0].split('·') + +/** 절정 명소가 많은 시·도 3곳, 절정이 없으면 가장 먼저 올 절정, 다 지났으면 지는 중 */ +function headline(spots: (Spot & { stage: Stage })[]) { + const peak = spots.filter((m) => m.stage === 'peak') + if (peak.length) { + const count = new Map() + for (const p of peak.flatMap(province)) count.set(p, (count.get(p) ?? 0) + 1) + return `지금 절정: ${[...count].sort((a, b) => b[1] - a[1]).slice(0, 3).map(([p]) => p).join('·')}` + } + if (spots.some((m) => m.stage === 'gone')) return '올해 단풍이 지고 있어요' + const first = spots.reduce((a, b) => (b.peak < a.peak ? b : a)) + return `첫 절정은 ${province(first)[0]}, ${md(first.peak)}쯤` +} type Box = { l: number; t: number; r: number; b: number } const overlaps = (a: Box, b: Box) => a.l < b.r && b.l < a.r && a.t < b.b && b.t < a.b @@ -103,19 +115,17 @@ export function FoliageCard() { return () => ro.disconnect() }, [named]) - const mmdd = today.slice(5) - if (mmdd < SEASON.from || mmdd > SEASON.to) return null + // 가장 이른 명소가 첫 단풍에 들 때부터 가장 늦은 명소의 절정이 끝날 때까지 + const peaks = spots.map((m) => m.peak).sort() + if (days(peaks[0], today) < -FIRST_DAYS || days(peaks[peaks.length - 1], today) > PEAK_AFTER) return null const peakNow = spots.filter((m) => m.stage === 'peak').map((m) => m.name) - // 발표 지도에 서울 안 산은 없어 서울 시청에서 가장 가까운 단풍 예측 산으로 - const forecast = spots.filter((m) => m.kind === 'maple' && m.basis.startsWith('산림청')) - const seoul = forecast.reduce((a, b) => (Math.hypot(b.lat - SEOUL.lat, b.lon - SEOUL.lon) < Math.hypot(a.lat - SEOUL.lat, a.lon - SEOUL.lon) ? b : a)) const sel = spots.find((m) => m.name === picked) const order = [...spots].sort((a, b) => Number(a.stage === 'peak') - Number(b.stage === 'peak')) return ( 5 ? ' 외' : ''}` : undefined}>

단풍 지도 · {md(today)}

-

서울 근교 {seoul.name} 절정 예상 {md(seoul.peak)}

+

{headline(spots)}

단풍 지도 {order.map((m) => {