mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Load BuildingMeasurements from SiteNotes JSON 🟩
This commit is contained in:
parent
2ed741df5c
commit
770bf1293d
1 changed files with 57 additions and 1 deletions
|
|
@ -5,9 +5,12 @@ from datatypes.epc.surveys.pashub_rdsap_site_notes import (
|
|||
BuildingConstruction,
|
||||
BuildingMeasurements,
|
||||
ExtensionConstruction,
|
||||
ExtensionMeasurements,
|
||||
FloorConstruction,
|
||||
FloorMeasurement,
|
||||
General,
|
||||
MainBuildingConstruction,
|
||||
MainBuildingMeasurements,
|
||||
PasHubRdSapSiteNotes,
|
||||
)
|
||||
|
||||
|
|
@ -185,7 +188,60 @@ class PasHubRdSapSiteNotesExtractor:
|
|||
)
|
||||
|
||||
def extract_building_measurements(self) -> BuildingMeasurements:
|
||||
raise NotImplementedError
|
||||
bm_section = self._section("Building Measurements", "Roof Space")
|
||||
|
||||
extension_markers = []
|
||||
i = 1
|
||||
while f"Extension {i}" in bm_section:
|
||||
extension_markers.append(f"Extension {i}")
|
||||
i += 1
|
||||
|
||||
main_start = bm_section.index("Main Building")
|
||||
main_end = (
|
||||
bm_section.index(extension_markers[0])
|
||||
if extension_markers
|
||||
else len(bm_section)
|
||||
)
|
||||
main_floors = self._parse_floor_measurements(bm_section[main_start:main_end])
|
||||
|
||||
extensions = []
|
||||
for n, marker in enumerate(extension_markers):
|
||||
ext_start = bm_section.index(marker)
|
||||
ext_end = (
|
||||
bm_section.index(extension_markers[n + 1])
|
||||
if n + 1 < len(extension_markers)
|
||||
else len(bm_section)
|
||||
)
|
||||
extensions.append(
|
||||
ExtensionMeasurements(
|
||||
id=n + 1,
|
||||
floors=self._parse_floor_measurements(bm_section[ext_start:ext_end]),
|
||||
)
|
||||
)
|
||||
|
||||
return BuildingMeasurements(
|
||||
main_building=MainBuildingMeasurements(floors=main_floors),
|
||||
extensions=extensions if extensions else None,
|
||||
)
|
||||
|
||||
def _parse_floor_measurements(self, data: List[str]) -> List[FloorMeasurement]:
|
||||
floors = []
|
||||
i = 0
|
||||
while i < len(data):
|
||||
if data[i].startswith("Floor") and i + 4 < len(data):
|
||||
floors.append(
|
||||
FloorMeasurement(
|
||||
name=data[i],
|
||||
area_m2=float(data[i + 1]),
|
||||
height_m=float(data[i + 2]),
|
||||
heat_loss_perimeter_m=float(data[i + 3]),
|
||||
pwl_m=float(data[i + 4]),
|
||||
)
|
||||
)
|
||||
i += 5
|
||||
else:
|
||||
i += 1
|
||||
return floors
|
||||
|
||||
def _parse_floor_construction(self, data: List[str]) -> FloorConstruction:
|
||||
return FloorConstruction(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue