@@ -18,6 +18,7 @@ class CityJSONFileResults:
18
18
19
19
Attributes:
20
20
zip_ok (bool): Whether the file is successfully compressed.
21
+ file_ok (bool): Whether the CityJSON file itself is valid.
21
22
nr_building (int): Number of building features.
22
23
nr_buildingpart (int): Number of building part features.
23
24
nr_invalid_building (int): Number of invalid building features. If any of the
@@ -45,6 +46,7 @@ class CityJSONFileResults:
45
46
"""
46
47
47
48
zip_ok : bool = None
49
+ file_ok : bool = None
48
50
nr_building : int = None
49
51
nr_buildingpart : int = None
50
52
nr_invalid_building : int = None
@@ -73,6 +75,7 @@ class OBJFileResults:
73
75
74
76
Attributes:
75
77
zip_ok (bool): Whether the file is successfully compressed.
78
+ file_ok (bool): Whether the OBJ file itself is valid.
76
79
nr_building (int): Number of building features.
77
80
nr_buildingpart (int): Number of building part features.
78
81
nr_invalid_building (int): Number of invalid building features. If any of the
@@ -88,6 +91,7 @@ class OBJFileResults:
88
91
"""
89
92
90
93
zip_ok : bool = None
94
+ file_ok : bool = None
91
95
nr_building : int = None
92
96
nr_buildingpart : int = None
93
97
nr_invalid_building : int = None
@@ -162,6 +166,7 @@ def asdict(self) -> dict:
162
166
163
167
164
168
def cityjson (
169
+ validation : AppImage ,
165
170
dirpath : Path ,
166
171
file_id : str ,
167
172
planarity_n_tol : float ,
@@ -212,14 +217,14 @@ def cityjson(
212
217
try :
213
218
cmd = " " .join (
214
219
[
215
- "/home/bdukai/software/3dbag-pipeline/venvs/venv_core/bin/cjio " ,
220
+ "{exe} " ,
216
221
str (inputfile ),
217
222
"info" ,
218
223
"--long" ,
219
224
]
220
225
)
221
- output , returncode = execute_shell_command_silent (
222
- shell_command = cmd , cwd = str (dirpath )
226
+ output , returncode = validation . execture (
227
+ "cjio" , command = cmd , local_path = str (dirpath )
223
228
)
224
229
try :
225
230
results .nr_building = int (
@@ -254,7 +259,7 @@ def cityjson(
254
259
try :
255
260
cmd = " " .join (
256
261
[
257
- "/opt/bin/val3dity " ,
262
+ "{exe} " ,
258
263
"--planarity_n_tol" ,
259
264
str (planarity_n_tol ),
260
265
"--planarity_d2p_tol" ,
@@ -264,7 +269,13 @@ def cityjson(
264
269
str (inputfile ),
265
270
]
266
271
)
267
- execute_shell_command_silent (shell_command = cmd , cwd = str (dirpath ))
272
+
273
+ returncode , output = validation .execute (
274
+ "val3dity" , command = cmd , local_path = str (dirpath )
275
+ )
276
+ results .file_ok = (
277
+ False if returncode != 0 or "error" in output .lower () else True
278
+ )
268
279
with reportfile .open ("r" ) as fo :
269
280
report = json .load (fo )
270
281
nr_invalid_building = 0
@@ -317,7 +328,7 @@ def cityjson(
317
328
results .nr_mismatch_errors_lod13 = nr_mismatch_errors_lod13
318
329
results .nr_mismatch_errors_lod22 = nr_mismatch_errors_lod22
319
330
reportfile .unlink ()
320
- logfile .unlink ()
331
+ logfile .unlink (missing_ok = True )
321
332
except Exception :
322
333
reportfile .unlink (missing_ok = True )
323
334
logfile .unlink (missing_ok = True )
@@ -326,9 +337,9 @@ def cityjson(
326
337
327
338
# cjval
328
339
try :
329
- cmd = " " .join (["/opt/bin/cjval " , str (inputfile )])
330
- output , returncode = execute_shell_command_silent (
331
- shell_command = cmd , cwd = str (dirpath )
340
+ cmd = " " .join (["{exe} " , str (inputfile )])
341
+ returncode , output = validation . execute (
342
+ "cjval" , command = cmd , local_path = str (dirpath )
332
343
)
333
344
pos = output .find ("SUMMARY" )
334
345
summary = output [pos :]
@@ -344,6 +355,7 @@ def cityjson(
344
355
345
356
346
357
def obj (
358
+ validation : AppImage ,
347
359
dirpath : Path ,
348
360
file_id : str ,
349
361
planarity_n_tol : float ,
@@ -437,7 +449,7 @@ def obj(
437
449
try :
438
450
cmd = " " .join (
439
451
[
440
- "/opt/bin/val3dity " ,
452
+ "{exe} " ,
441
453
"--planarity_n_tol" ,
442
454
str (planarity_n_tol ),
443
455
"--planarity_d2p_tol" ,
@@ -447,7 +459,13 @@ def obj(
447
459
str (inputfile ),
448
460
]
449
461
)
450
- execute_shell_command_silent (shell_command = cmd , cwd = str (dirpath ))
462
+
463
+ returncode , output = validation .execute (
464
+ "val3dity" , command = cmd , local_path = str (dirpath )
465
+ )
466
+ results .file_ok = (
467
+ False if returncode != 0 or "error" in output .lower () else True
468
+ )
451
469
with reportfile .open ("r" ) as fo :
452
470
report = json .load (fo )
453
471
@@ -487,7 +505,7 @@ def obj(
487
505
results .nr_invalid_buildingpart_lod22 = nr_invalid_lod22
488
506
results .errors_lod22 = list (errors_lod22 )
489
507
reportfile .unlink ()
490
- logfile .unlink ()
508
+ logfile .unlink (missing_ok = True )
491
509
except Exception :
492
510
reportfile .unlink (missing_ok = True )
493
511
logfile .unlink (missing_ok = True )
@@ -509,13 +527,6 @@ def gpkg(
509
527
url_root : str ,
510
528
version : str ,
511
529
) -> GPKGFileResults :
512
- results = {
513
- "gpkg_zip_ok" : None ,
514
- "gpkg_ok" : None ,
515
- "gpkg_nr_features" : None ,
516
- "gpkg_sha256" : None ,
517
- "gpkg_download" : None ,
518
- }
519
530
results = GPKGFileResults ()
520
531
inputzipfile = dirpath .joinpath (file_id ).with_suffix (".gpkg.gz" )
521
532
inputfile = dirpath .joinpath (file_id ).with_suffix (".gpkg" )
@@ -573,9 +584,6 @@ def gpkg(
573
584
f"/vsigzip//{ inputzipfile } " ,
574
585
]
575
586
)
576
- output , returncode = execute_shell_command_silent (
577
- shell_command = cmd , cwd = str (dirpath )
578
- )
579
587
returncode , output = gdal .execute (
580
588
"ogrinfo" , command = cmd , local_path = str (dirpath )
581
589
)
@@ -636,7 +644,7 @@ def create_download_link(url_root: str, format: str, file_id: str, version: str)
636
644
637
645
638
646
def check_formats (input ) -> TileResults :
639
- gdal , dirpath , tile_id , url_root , version = input
647
+ gdal , validation , dirpath , tile_id , url_root , version = input
640
648
file_id = tile_id .replace ("/" , "-" )
641
649
planarity_n_tol = 20.0
642
650
planarity_d2p_tol = 0.001
@@ -649,6 +657,7 @@ def check_formats(input) -> TileResults:
649
657
version = version ,
650
658
)
651
659
obj_results = obj (
660
+ validation ,
652
661
dirpath ,
653
662
file_id ,
654
663
planarity_n_tol = planarity_n_tol ,
@@ -666,7 +675,7 @@ def check_formats(input) -> TileResults:
666
675
"metadata" : AssetIn (key_prefix = "export" ),
667
676
},
668
677
deps = [AssetKey (("export" , "compressed_tiles" ))],
669
- required_resource_keys = {"file_store" , "version" , "gdal" },
678
+ required_resource_keys = {"file_store" , "version" , "gdal" , "validation" },
670
679
)
671
680
def compressed_tiles_validation (
672
681
context : OpExecutionContext , export_index : Path , metadata : Path
@@ -700,12 +709,14 @@ def compressed_tiles_validation(
700
709
version = metadata_json ["identificationInfo" ]["citation" ]["edition" ]
701
710
context .log .debug (f"{ version = } " )
702
711
gdal = context .resources .gdal .app
712
+ validation = context .resources .validation .app
703
713
with export_index .open ("r" ) as fo :
704
714
csvreader = csv .reader (fo )
705
715
_ = next (csvreader ) # header
706
716
tileids = [
707
717
(
708
718
gdal ,
719
+ validation ,
709
720
path_export_dir .joinpath ("tiles" , row [0 ]),
710
721
row [0 ],
711
722
url_root ,
0 commit comments