mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Map window custom_displayable_fields to WindowVentilation 🟩
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
10bbf0bb60
commit
9a3987b4f1
1 changed files with 39 additions and 1 deletions
|
|
@ -2,7 +2,15 @@ from typing import Optional
|
|||
|
||||
import datatypes.magicplan.api.response as api
|
||||
from datatypes.magicplan.api.response import MagicPlanPlan
|
||||
from datatypes.magicplan.domain.models import Plan, Floor, Room, Window, Door
|
||||
from datatypes.magicplan.domain.models import (
|
||||
Door,
|
||||
DoorVentilation,
|
||||
Floor,
|
||||
Plan,
|
||||
Room,
|
||||
Window,
|
||||
WindowVentilation,
|
||||
)
|
||||
|
||||
|
||||
def map_plan(mp: MagicPlanPlan) -> Plan:
|
||||
|
|
@ -60,6 +68,36 @@ def _map_window(wi: api.WallItem) -> Window:
|
|||
height_m=round(wi.size.z, 2),
|
||||
area_m2=round(wi.size.x * wi.size.z, 2),
|
||||
opening_type=wi.symbol.id.removeprefix("window"),
|
||||
ventilation=_map_window_ventilation(wi.custom_displayable_fields),
|
||||
)
|
||||
|
||||
|
||||
def _map_window_ventilation(
|
||||
fields: list[api.SurveyField],
|
||||
) -> Optional[WindowVentilation]:
|
||||
if not fields:
|
||||
return None
|
||||
by_label = {f.label: f for f in fields}
|
||||
|
||||
def _str(label: str) -> Optional[str]:
|
||||
f = by_label.get(label)
|
||||
if f is None or not f.value.has_value:
|
||||
return None
|
||||
v = f.value.value
|
||||
return v[0] if isinstance(v, list) else v
|
||||
|
||||
def _int(label: str) -> Optional[int]:
|
||||
raw = _str(label)
|
||||
return int(raw) if raw is not None else None
|
||||
|
||||
return WindowVentilation(
|
||||
opening_type=_str("Opening Type"),
|
||||
num_openings=_int("Number of Openings (In Same Window)"),
|
||||
pct_openable=_int("% of Window Openable"),
|
||||
trickle_vent_area_mm2=_int(
|
||||
"Trickle Vent Effective Area (mm2) (No Code Then Width x Height)"
|
||||
),
|
||||
num_trickle_vents=_int("No. of Trickle Vents"),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue