Skip to content

Commit

Permalink
update(readers.citygml.extractors): add get_district_plan and get_dis…
Browse files Browse the repository at this point in the history
…tricts_and_zones_type
  • Loading branch information
ozekik committed Aug 22, 2024
1 parent 7962ce6 commit d097437
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
26 changes: 26 additions & 0 deletions plateaukit/readers/citygml/extractors/city_object_extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ def get_usage(xml: CityObjectXML) -> str | None:
return value


def get_district_plan(xml: CityObjectXML) -> str | None:
value = _get_string_attribute(xml, name="地区計画")
return value


def get_building_id(xml: CityObjectXML) -> str | None:
try:
path = "./uro:buildingIDAttribute/uro:BuildingIDAttribute/uro:buildingID"
Expand Down Expand Up @@ -119,6 +124,27 @@ def get_river_flooding_duration(xml: CityObjectXML) -> float | None:
return value


def get_districts_and_zones_type(xml: CityObjectXML) -> str | None:
el = xml.find(
"./uro:buildingDetailAttribute",
xml.nsmap,
)

if el is None:
return None

# TODO:
# ".//uro:urbanPlanType", # "都市計画区域" など
# ".//uro:areaClassificationType", # "市街化区域" など

# 都市計画法第8条第3項第1号に定める地域地区(及び用途地域)の区分
result = xml._get_codespace_attribute(
"./uro:BuildingDetailAttribute/uro:districtsAndZonesType", parent=el
)

return result


def get_address(xml: CityObjectXML) -> dict | None:
el = xml.find("./bldg:address", xml.nsmap)

Expand Down
6 changes: 6 additions & 0 deletions plateaukit/readers/citygml/parsers/city_object_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ def _parse_attributes(self, el: CityObjectXML) -> dict:
"storeys_below_ground": extractors.get_storeys_below_ground(el),
"name": extractors.get_name(el),
"usage": extractors.get_usage(el),
"district_plan": extractors.get_district_plan(el),
}

# river_flooding_risks = extractors.get_river_flooding_risks(el)
Expand All @@ -249,6 +250,11 @@ def _parse_attributes(self, el: CityObjectXML) -> dict:
river_flooding_risks = extractors.get_river_flooding_risks(el)
optional_attributes.update({"river_flooding_risk": river_flooding_risks})

districts_and_zones_type = extractors.get_districts_and_zones_type(el)
optional_attributes.update(
{"districts_and_zones_type": districts_and_zones_type}
)

optional_attributes = {
k: v for k, v in optional_attributes.items() if v is not None
}
Expand Down

0 comments on commit d097437

Please sign in to comment.