Skip to content

Commit 4ffa81a

Browse files
authored
Merge pull request #43 from eukarya-inc/feature/dev-v3
catch error if uro:buildingStructureType is NoneType
2 parents de966ce + 9a766a0 commit 4ffa81a

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

Diff for: plateauutils/parser/city_gml_parser.py

+22-16
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import glob
21
import numpy as np
32
import os
43
from plateauutils.abc.plateau_parser import PlateauParser
54
from plateauutils.mesh_geocorder.polygon_to_meshcode_list import PolygonToMeshCodeList
65
from shapely.geometry import Polygon
7-
import shutil
86
import xml.etree.ElementTree as ET
97
import zipfile
108

@@ -202,20 +200,28 @@ def _parse(
202200
".//uro:buildingStructureType", ns
203201
)
204202
# uro:codeSpaceを取得
205-
code_space = building_structure_type.get("codeSpace")
206-
# codeSpaceから値を取得
207-
code_space_path = os.path.normpath(os.path.join(target, "..", code_space))
208-
code_space_root = ET.fromstring(zip_file.read(code_space_path))
209-
building_structure_type_text = None
210-
for code_space_root_root_child in code_space_root.findall(
211-
".//gml:dictionaryEntry", ns
212-
):
213-
gml_name = code_space_root_root_child.find(".//gml:name", ns)
214-
if str(gml_name.text) == str(building_structure_type.text):
215-
building_structure_type_text = str(
216-
code_space_root_root_child.find(".//gml:description", ns).text
217-
)
218-
break
203+
try:
204+
code_space = building_structure_type.get("codeSpace")
205+
# codeSpaceから値を取得
206+
code_space_path = os.path.normpath(
207+
os.path.join(target, "..", code_space)
208+
)
209+
code_space_root = ET.fromstring(zip_file.read(code_space_path))
210+
building_structure_type_text = None
211+
for code_space_root_root_child in code_space_root.findall(
212+
".//gml:dictionaryEntry", ns
213+
):
214+
gml_name = code_space_root_root_child.find(".//gml:name", ns)
215+
if str(gml_name.text) == str(building_structure_type.text):
216+
building_structure_type_text = str(
217+
code_space_root_root_child.find(
218+
".//gml:description", ns
219+
).text
220+
)
221+
break
222+
except AttributeError:
223+
print("uro:buildingStructureType is NoneType in", gid, "in", target)
224+
building_structure_type_text = "不明"
219225
# bldg:lod1Solidを取得
220226
lod1_solid = city_object_member.find(".//bldg:lod1Solid", ns)
221227
# 返り値に入る値を作成

Diff for: pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ classifiers = [
1111
"Development Status :: 2 - Pre-Alpha",
1212
"Programming Language :: Python :: 3",
1313
]
14-
version = "0.0.9"
14+
version = "0.0.10"
1515
dependencies = [
1616
"click",
1717
"numpy",

0 commit comments

Comments
 (0)