cityjson / cjio

CityJSON/io: Python CLI to process and manipulate CityJSON files
MIT License
119 stars 31 forks source link

cjio crashes when merging empty cityjson (ValueError: math domain error) #156

Open pcace opened 1 year ago

pcace commented 1 year ago

cjio crashes when merging multiple files and one is an empty cityJson (according to specification allowed: https://www.cityjson.org/specs/1.1.3/#cityjson-object)

with the following error:

cjio LoD2_33_388_5816_1_BE.json merge "*.json" save merged.json
Parsing LoD2_33_388_5816_1_BE.json
Merging files
Traceback (most recent call last):
  File "/home/user/.local/bin/cjio", line 8, in <module>
    sys.exit(cli())
  File "/home/user/.local/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/user/.local/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/user/.local/lib/python3.9/site-packages/click/core.py", line 1689, in invoke
    return _process_result(rv)
  File "/home/user/.local/lib/python3.9/site-packages/click/core.py", line 1626, in _process_result
    value = ctx.invoke(self._result_callback, value, **ctx.params)
  File "/home/user/.local/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/user/.local/lib/python3.9/site-packages/cjio/cjio.py", line 94, in process_pipeline
    cm = processor(cm)
  File "/home/user/.local/lib/python3.9/site-packages/cjio/cjio.py", line 356, in processor
    cm.merge(lsCMs)
  File "/home/user/.local/lib/python3.9/site-packages/cjio/cityjson.py", line 1258, in merge
    if math.ceil(abs(math.log(cm.j["transform"]["scale"][0], 10))) > imp_digits:
ValueError: math domain error

example files here: (see example3 folder) https://cloud.johannes-froelich.de/s/xtwyW4rrNoeZTE5

any quick fix? since the cityJson files are generated in my case here its hard for me to avoid "empty" cityJson files

cheers and thanks!

hugoledoux commented 1 year ago

hmmm, it's not the empty file that causes this but the fact that the scale is 0... this should be fixed indeed but in the meantime put 1.0 for scale and this should work