Skip to content

Commit

Permalink
Merge pull request #43 from eukarya-inc/feature/dev-v3
Browse files Browse the repository at this point in the history
catch error if uro:buildingStructureType is NoneType
  • Loading branch information
smellman authored Sep 6, 2023
2 parents de966ce + 9a766a0 commit 4ffa81a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
38 changes: 22 additions & 16 deletions plateauutils/parser/city_gml_parser.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import glob
import numpy as np
import os
from plateauutils.abc.plateau_parser import PlateauParser
from plateauutils.mesh_geocorder.polygon_to_meshcode_list import PolygonToMeshCodeList
from shapely.geometry import Polygon
import shutil
import xml.etree.ElementTree as ET
import zipfile

Expand Down Expand Up @@ -202,20 +200,28 @@ def _parse(
".//uro:buildingStructureType", ns
)
# uro:codeSpaceを取得
code_space = building_structure_type.get("codeSpace")
# codeSpaceから値を取得
code_space_path = os.path.normpath(os.path.join(target, "..", code_space))
code_space_root = ET.fromstring(zip_file.read(code_space_path))
building_structure_type_text = None
for code_space_root_root_child in code_space_root.findall(
".//gml:dictionaryEntry", ns
):
gml_name = code_space_root_root_child.find(".//gml:name", ns)
if str(gml_name.text) == str(building_structure_type.text):
building_structure_type_text = str(
code_space_root_root_child.find(".//gml:description", ns).text
)
break
try:
code_space = building_structure_type.get("codeSpace")
# codeSpaceから値を取得
code_space_path = os.path.normpath(
os.path.join(target, "..", code_space)
)
code_space_root = ET.fromstring(zip_file.read(code_space_path))
building_structure_type_text = None
for code_space_root_root_child in code_space_root.findall(
".//gml:dictionaryEntry", ns
):
gml_name = code_space_root_root_child.find(".//gml:name", ns)
if str(gml_name.text) == str(building_structure_type.text):
building_structure_type_text = str(
code_space_root_root_child.find(
".//gml:description", ns
).text
)
break
except AttributeError:
print("uro:buildingStructureType is NoneType in", gid, "in", target)
building_structure_type_text = "不明"
# bldg:lod1Solidを取得
lod1_solid = city_object_member.find(".//bldg:lod1Solid", ns)
# 返り値に入る値を作成
Expand Down
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.9"
version = "0.0.10"
dependencies = [
"click",
"numpy",
Expand Down

0 comments on commit 4ffa81a

Please sign in to comment.