Skip to content

Commit

Permalink
Add altitude calculations to LunarTwoResponse.
Browse files Browse the repository at this point in the history
  • Loading branch information
mareuter committed Nov 10, 2024
1 parent ea37719 commit dfd158d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/lct_web/models/lunar_two_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from pydantic import BaseModel

from ..pkg_types import FeatureDict
from ..pkg_types import AltitudeDict, FeatureDict

__all__ = ["LunarTwoResponse"]

Expand All @@ -24,3 +24,4 @@ class LunarTwoResponse(BaseModel):

features: FeatureDict
landing_sites: FeatureDict
altitudes: AltitudeDict
3 changes: 2 additions & 1 deletion src/lct_web/pkg_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

from pylunar.pkg_types import DateTimeTuple, LunarFeatureList

__all__ = ["NextFourPhases", "RiseSetTimes"]
__all__ = ["AltitudeDict", "FeatureDict", "NextFourPhases", "RiseSetTimes"]

AltitudeDict = dict[str, float]
FeatureDict = dict[str, LunarFeatureList]
NextFourPhases = dict[str, dict[str, str | DateTimeTuple]]
RiseSetTimes = dict[str, dict[str, str | DateTimeTuple]]
7 changes: 5 additions & 2 deletions src/lct_web/routers/lunar_two.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from __future__ import annotations

from fastapi import APIRouter
from pylunar import LunarFeatureContainer, MoonInfo
from pylunar import AltitudeDict, LunarFeatureContainer, MoonInfo

from ..dependencies import DateLocDeps
from ..helpers import format_date_and_location
Expand All @@ -38,6 +38,9 @@ def lunar_two(params: DateLocDeps) -> LunarTwoResponse:
lfc = LunarFeatureContainer("LunarII")
lfc.load(moon_info)

ad = AltitudeDict()
ad.load(moon_info)

features = {}
landing_sites = {}
for i, feature in enumerate(lfc):
Expand All @@ -46,4 +49,4 @@ def lunar_two(params: DateLocDeps) -> LunarTwoResponse:
else:
features[str(i)] = feature.list_from_feature()

return LunarTwoResponse(features=features, landing_sites=landing_sites)
return LunarTwoResponse(features=features, landing_sites=landing_sites, altitudes=ad)
1 change: 1 addition & 0 deletions tests/test_lunar_two.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ def test_lunar_two() -> None:
lunar_two_info = response.json()
assert len(lunar_two_info["features"]) == 11
assert len(lunar_two_info["landing_sites"]) == 16
assert len(lunar_two_info["altitudes"]) == 4

0 comments on commit dfd158d

Please sign in to comment.