Skip to content

Commit

Permalink
#24 building_structure_type to text
Browse files Browse the repository at this point in the history
  • Loading branch information
smellman committed Jul 27, 2023
1 parent c607e20 commit 267425f
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install sphinx
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Sphinx build
run: |
rm -fr _build
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This is a collection of utilities for the `Plateau <https://www.mlit.go.jp/plate
>>> parser = CityGMLParser(target_polygon)
>>> result = parser.download_and_parse("https://assets.cms.plateau.reearth.io/assets/d6/70821e-7f58-4f69-bc34-341875704e78/40203_kurume-shi_2020_citygml_3_op.zip", "/tmp")
>>> result
[{'gid': 'bldg_383f1804-aa34-4634-949f-f769e09fa92d', 'center': [130.41263587199947, 33.22489181671553], 'min_height': 3.805999994277954, 'measured_height': 9.3, 'building_structure_type': '610'}, {'gid': 'bldg_877dea60-35d0-4fd9-8b02-852e39c75d81', 'center': [130.41619367090038, 33.22492719812357], 'min_height': 4.454999923706055, 'measured_height': 3.0, 'building_structure_type': '610'},...]
[{'gid': 'bldg_383f1804-aa34-4634-949f-f769e09fa92d', 'center': [130.41263587199947, 33.22489181671553], 'min_height': 3.805999994277954, 'measured_height': 9.3, 'building_structure_type': '非木造'}, {'gid': 'bldg_877dea60-35d0-4fd9-8b02-852e39c75d81', 'center': [130.41619367090038, 33.22492719812357], 'min_height': 4.454999923706055, 'measured_height': 3.0, 'building_structure_type': '非木造'},...]
How to develop
--------------
Expand Down
2 changes: 1 addition & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Usage
>>> parser = CityGMLParser(target_polygon)
>>> result = parser.download_and_parse("https://assets.cms.plateau.reearth.io/assets/d6/70821e-7f58-4f69-bc34-341875704e78/40203_kurume-shi_2020_citygml_3_op.zip", "/tmp")
>>> result
[{'gid': 'bldg_383f1804-aa34-4634-949f-f769e09fa92d', 'center': [130.41263587199947, 33.22489181671553], 'min_height': 3.805999994277954, 'measured_height': 9.3, 'building_structure_type': '610'}, {'gid': 'bldg_877dea60-35d0-4fd9-8b02-852e39c75d81', 'center': [130.41619367090038, 33.22492719812357], 'min_height': 4.454999923706055, 'measured_height': 3.0, 'building_structure_type': '610'},...]
[{'gid': 'bldg_383f1804-aa34-4634-949f-f769e09fa92d', 'center': [130.41263587199947, 33.22489181671553], 'min_height': 3.805999994277954, 'measured_height': 9.3, 'building_structure_type': '非木造'}, {'gid': 'bldg_877dea60-35d0-4fd9-8b02-852e39c75d81', 'center': [130.41619367090038, 33.22492719812357], 'min_height': 4.454999923706055, 'measured_height': 3.0, 'building_structure_type': '非木造'},...]
.. toctree::
Expand Down
29 changes: 25 additions & 4 deletions plateauutils/parser/city_gml_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def parse(self, target_path: str = "") -> list:
tree = ET.parse(file_path)
root = tree.getroot()
# パース処理を実施する
ret = self._parse(root)
ret = self._parse(root, file_path)
# 返り値に追加
return_list.extend(ret)
# 返り値を返却
Expand Down Expand Up @@ -118,7 +118,7 @@ def _target_list(self, polygon: Polygon = None) -> list:
# 返り値を返す
return return_list

def _parse(self, root: ET.Element) -> list:
def _parse(self, root: ET.Element, file_path: str) -> list:
# 返り値を作成
return_list = []
# core:cityObjectMemberの一覧を取得
Expand Down Expand Up @@ -146,7 +146,28 @@ def _parse(self, root: ET.Element) -> list:
# uro:buildingStructureTypeを取得
building_structure_type = building_detail_attribute.find(
".//{https://www.geospatial.jp/iur/uro/2.0}buildingStructureType"
).text
)
# uro:codeSpaceを取得
code_space = building_structure_type.get("codeSpace")
# codeSpaceから値を取得
code_space_root = ET.parse(
os.path.abspath(os.path.join(file_path, "..", code_space))
)
code_space_root_root = code_space_root.getroot()
building_structure_type_text = None
for code_space_root_root_child in code_space_root_root.findall(
".//{http://www.opengis.net/gml}dictionaryEntry"
):
gml_name = code_space_root_root_child.find(
".//{http://www.opengis.net/gml}name"
)
if str(gml_name.text) == str(building_structure_type.text):
building_structure_type_text = str(
code_space_root_root_child.find(
".//{http://www.opengis.net/gml}description"
).text
)
break
# bldg:lod1Solidを取得
lod1_solid = city_object_member.find(
".//{http://www.opengis.net/citygml/building/2.0}lod1Solid"
Expand All @@ -157,7 +178,7 @@ def _parse(self, root: ET.Element) -> list:
"center": None,
"min_height": 10000,
"measured_height": measured_height,
"building_structure_type": building_structure_type,
"building_structure_type": building_structure_type_text,
}
# gml:posListを取得
pos_lists = lod1_solid.findall(".//{http://www.opengis.net/gml}posList")
Expand Down
2 changes: 1 addition & 1 deletion plateauutils/parser/tests/test_city_gml_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ def test_citygml_parser():
assert result[0]["center"] == [130.41263587199947, 33.22489181671553]
assert result[0]["min_height"] == 3.805999994277954
assert result[0]["measured_height"] == 9.3
assert result[0]["building_structure_type"] == "610"
assert result[0]["building_structure_type"] == "非木造"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Programming Language :: Python :: 3",
]
version = "0.0.2"
version = "0.0.3"
dependencies = [
"click",
"numpy",
Expand Down

0 comments on commit 267425f

Please sign in to comment.