feat: 구 중심 20km 안에 서쪽이 트인 노을 명소가 있으면 노을 점수 가산

This commit is contained in:
skkim committed 2026-10-12 14:41:09 +09:00
1 parent 3857ef8d14
commit cac6ea236f
6 files changed
+58 -4

No files matched your search

+27
View File
@@ -169,3 +169,30 @@ def test_nearest_slot_is_closest_three_hour_end():
from datetime import datetime, timezone
at = lambda h, m=0: datetime(2026, 10, 7, h, m, tzinfo=timezone.utc) # noqa: E731
assert [sky_service._nearest_slot(at(h, m)).hour for h, m in ((8, 0), (9, 0), (10, 29), (10, 31))] == [9, 9, 9, 12]
def test_open_west_bonus_applies_to_sunset_only_and_needs_a_spot_nearby():
from datetime import date, datetime, timezone
from types import SimpleNamespace
from common.enums import SkyType
from services.calc.sky_score import Layers
from services.calc.sun import sun_times
region = SimpleNamespace(code="R", lat=37.56, lon=126.91)
today = date(2026, 10, 7)
st = sun_times(today, region.lat, region.lon)
clouds = {
("R", kind.value, km, sky_service._nearest_hour(at), 3): Layers(0, 20, 0)
for kind, at in ((SkyType.SUNSET, st.sunset_at), (SkyType.SUNRISE, st.sunrise_at)) for km in (20, 100)
}
now = datetime(2026, 10, 7, 3, tzinfo=timezone.utc)
by = lambda rows: {(r["sky_type"], r["score_date"]): r["score"] for r in rows} # noqa: E731
plain = by(sky_service._score_rows(region, today, clouds, now))
west = by(sky_service._score_rows(region, today, clouds, now, open_west=True))
assert west[(SkyType.SUNSET.value, today)] == min(100, round(plain[(SkyType.SUNSET.value, today)] * 1.1))
assert west[(SkyType.SUNRISE.value, today)] == plain[(SkyType.SUNRISE.value, today)]
near = SimpleNamespace(lat=37.5555, lon=126.895) # 망원한강공원, 약 1.5km
far = SimpleNamespace(lat=37.0, lon=126.0)
assert sky_service._open_west(region, [near]) and not sky_service._open_west(region, [far]) and not sky_service._open_west(region, [])