citygml4j / citygml4j

The Open Source Java API for CityGML
Apache License 2.0
115 stars 38 forks source link

conversion CityGML to CityJSON: empty list of CityObjects (<grp:CityObjectGroup> supported?) #10

Closed hugoledoux closed 6 years ago

hugoledoux commented 6 years ago

I'm trying to convert a file and the resulting json has an empty list of CityObjects, would it be caused by the setup as below? From a file I have called waldbruecke_v1.0.0.gml, I think it's open data but not sure; I can send you directly if needed.

<cityObjectMember>
        <grp:CityObjectGroup gml:id="g_12529">
            <gml:description>Gebäude und Freifläche Wohnen(1300)</gml:description>
            <gml:name> g_12529</gml:name>
            <creationDate>2009-01-11</creationDate>
            <externalReference>
                <informationSystem>WB3 Project</informationSystem>
                <externalObject>
                    <uri>http://www.wb3-project.de/wb_g_id.html?db=waldbruecke&amp;id=12529</uri>
                </externalObject>
            </externalReference>
            <grp:groupMember>
                <luse:LandUse gml:id="l_12529">
clausnagel commented 6 years ago

You got me :-) Simply forgot to implement CityObjectGroups. I will add it and let you know.

hugoledoux commented 6 years ago

oooohhh, how nice to prove you wrong on a CityGML issue! That makes my day 😬

But, seriously, I just processed that file and got nothing... Opened it and spotted <grp:CityObjectGroup>, which I didn't even know existed... My val3dity parser just ignores many tags, hence I had never noticed.

clausnagel commented 6 years ago

:rofl: Of course, CityObjectGroups are supported by citygml4j in general, but I missed it for the CityJSON implementation.

Did not find the waldbruecke_v1.0.0.gml dataset on the internet anymore. But no problem, I have some other datasets with groups for testing. It just strikes me that you are testing with this dataset. As a master student back in ... well, too long ago ... I was working on the WB3 project of my former professor in which this dataset was produced. You always meet twice :-)

clausnagel commented 6 years ago

Added support for CityObjectGroups in 2bfe80a3432703c8163812ac722593758c53a98a.

Members and parents of a CityObjectGroup are now added to "CityObjects" in CityJSON. Since CityJSON 0.5 has no grouping mechanism, the gml:id of the CityObjectGroup is added as "group" attribute to each city object in order to keep the information,

When converting the resulting CityJSON back to CityGML, the "group" is however only mapped onto a generic attribute. I opted against rebuilding a CityObjectGroup from this information (it would be possible though) as this would be a citygml4j-only solution.

hugoledoux commented 6 years ago

Sounds like a good solution to me.

However, should CityJSON specific groups too you reckon? In the way you describe that is: just an attribute.

clausnagel commented 6 years ago

Hm, good question. The way I implemented it for citygml4j for now is really just an attribute. If you ask for a CityJSON grouping mechanism, then an alternative option would be to introduce a new CityObject type:

"CityObjects": {
  "id_01": {
    "type": "CityObjectGroup",
    "parent": "id_of_parent",
    "members": ["id_of_member_1", "id_of_member_2", "id_of_member_3"] 
  }
}

So the CityObjectGroup would basically just list its parent and members by gml:id. Would make the group more explicit and possibly more easy to query. In CityGML, a group can even have geometry, so this could also be represented in CityJSON if the group is represented in this way.

I have not seen too many CityGML datasets making reasonable use of CityObjectGroups. So I think CityJSON could nicely go along without a grouping mechanism. On the other hand, why not include it.

Should we open an issue on the CityJSON GitHub in order to have the discussion there?