cityjson / Up3date

A Blender add-on to import, edit and export 3D city models encoded in CityJSON v.1.0 format preserving geometries, attributes and semantics
MIT License
65 stars 12 forks source link

Using LOD subversion numbers problem in CityJSON output #16

Open sambaas opened 2 years ago

sambaas commented 2 years ago

Using LOD subversions gives a problem in the json output. It looks like the part of the name is not stripped out properly (The two extra characters for the decimal character seem to be ignored when removing the '[LOD2.1]' part of the name.

{
    "type": "CityJSON",
    "version": "1.0",
    "metadata": {
        "geographicalExtent": [121578.775, 486020.60199999996, -4.7540000000000004, 121966.761, 486232.568, 309.487]
    },
    "CityObjects": {
        "] Cube": {
            "geometry": [{
                    "type": "MultiSurface",
                    "boundaries": [[[0, 1, 2, 3]], [[3, 2, 4, 5]], [[5, 4, 6, 7]], [[7, 6, 1, 0]], [[3, 5, 7, 0]], [[4, 2, 1, 6]]],
                    "lod": 2
                }
            ]
        },
        "Cube": {
            "geometry": [],
            "type": "Building"
        }
    },
    "vertices": [[236940.0, 60919.0, 163194.0], [236940.0, 60919.0, 314241.0], [236940.0, 211966.0, 314241.0], [236940.0, 211966.0, 163194.0], [387986.0, 211966.0, 314241.0], [387986.0, 211966.0, 163194.0], [387986.0, 60919.0, 314241.0], [387986.0, 60919.0, 163194.0]],
    "transform": {
        "scale": [0.001, 0.001, 0.001],
        "translate": [121578.775, 486020.60199999996, -4.7540000000000004]
    }
}
sambaas commented 2 years ago

It appears to be line 260 in objects.py, because a hardcoded length is stripped off to get the ID: CityObject_id = objid[10:]

Getting the part after the second space should fix this. I'll see if that works and make a pull request.

sambaas commented 2 years ago

Made a pull request https://github.com/cityjson/Up3date/pull/17

liberostelios commented 2 years ago

Thanks a lot for raising the issue and submitting the PR! I'll review the fix and let you know.

konmast3r commented 2 years ago

That is indeed an improvement. Back in the day when developing the add-on I never thought of decimal point LODs :-). Thanks Sam!

liberostelios commented 2 years ago

Tbf, at that point extended LoDs weren't really supported that well in the CityJSON specs. Thankfully, this is fixed now!