cityjson / cityjson-qgis-plugin

A QGIS plugin that adds support for CityJSON files
Apache License 2.0
35 stars 8 forks source link

Create parents as attribute #35

Closed StefanCiesilski closed 3 years ago

StefanCiesilski commented 3 years ago

Is it possible to pass the parent attribute in QGIS as an attribute when loading. Otherwise I have entries and do not know which main entry they belong to.

"CityObjects": { "UUID_fab50c6d-4cc0-45c7-ae1d-994de421c72c": { "type": "BuildingPart", "attributes": { "measuredHeight": 7.251, "creationDate": "2020-01-20", "DatenquelleDachhoehe": "1000", "Grundrissaktualitaet": "2020-01-01", "DatenquelleLage": "1000", "DatenquelleBodenhoehe": "1200", "BezugspunktDach": "1000" }, "parents": [ "DETHL57P0000QHJG" ],

CityJson.zip

liberostelios commented 3 years ago

Hi @StefanCiesilski

Thanks for reporting this. That's a good point! I've missed that.

Will fix it asap.

StefanCiesilski commented 3 years ago

Thanks. Do you know when approx.

liberostelios commented 3 years ago

Probably today. Otherwise, for sure by the end of the week.

StefanCiesilski commented 3 years ago

Thanks. Great

liberostelios commented 3 years ago

The version 0.7.0 now supports parents and children.

StefanCiesilski commented 3 years ago

Hi @liberostelios I have test it. It works, but is it possible to create the Attribute without "[' ']" grafik

The children id is not set. And its possible if the parents id is NULL, to add the uid to parents id? So I can sort by a building.

liberostelios commented 3 years ago

For me children works fine, but there was an ambiguity regarding the field size so it might be fixed now. Which version of QGIS are you using?

parents is supposed to be an array, hence the [' '] wrapping. But since the most common case is to have one parent, I made an exception so when one parent is present it treats it as a single value.

Can you please try this version: CityJSON-loader.zip? If it works for you, I'll push it as version 0.7.1.

StefanCiesilski commented 3 years ago

I have test it. Parents id is correct. And children works also fine. grafik

I have QGIS 3.18.0

How can I best sort it. So that all parts of the building stand one below the other.

liberostelios commented 3 years ago

Glad that it works. I've pushed this as version 0.7.1.

I am not sure if I can help you with your question. There is a way to setup relationships between different layers. I've tried setting a relationship between parents and uuid but QGIS crashed.

StefanCiesilski commented 3 years ago

I solved my problem.. I have create a new attribute "building". With field calculator copy "parents" into "buildings". They are still missing copy "uid" into "building" . Is this possible by load the CityJSON file?

liberostelios commented 3 years ago

Sounds like a very specific case to me. I'd refrain from doing so, because this would introduce too much redundancy and end up creating data that are much altered compared to the initial file. Plus, parents is supposed to be an array and not a single value.

I don't get exactly what you did. Sounds to me like all you need is to copy the uuid in parents when it's null, right? So you can make it with this formula: if ( "parents" is null, "uuid", "parents" ). Then you can use this to sort. But this only works if you know you have one parent.

StefanCiesilski commented 3 years ago

that's true Thank you anyway