Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra attributes to all city objects #204

Open
clausnagel opened this issue Sep 21, 2024 · 3 comments
Open

Add extra attributes to all city objects #204

clausnagel opened this issue Sep 21, 2024 · 3 comments

Comments

@clausnagel
Copy link
Contributor

In CityGML, you can define ADE attributes for abstract CityGML classes, and these attributes are inherited and available for all subclasses. For example, when you add an attribute myAdeAttribute to the abstract root class AbstractCityObject, you can automatically use this attribute for all derived instances like Building, CityFurniture, or LandUse.

In a CityJSON extension schema, you can assign additional attributes to city objects through the "extraAttributes" object. The CityJSON schema itself uses some sort of "abstract" definitions like, for example, "_AbstractCityObject" (see https://3d.bk.tudelft.nl/schemas/cityjson/2.0.1/cityobjects.schema.json).

Is it allowed and supported to reference this "_AbstractCityObject" in an extension schema like shown below?

{
  "type": "CityJSONExtension",
  ...
  "extraAttributes": {
    "_AbstractCityObject": {
      "+myAdeAttribute": {
        "type": "string"
      }
    }
  }
}
@hugoledoux
Copy link
Member

No it's not currently allowed nor supported. The CityObjects of CityJSON are hard-coded in cjval, see https://github.com/cityjson/cjval/blob/main/schemas/extensions/20/extension.schema.json#L51

The question this raises is: should it be? I think this is a rather extreme example, and adding this to the validator would mean adding a lot of code. But I see the reasoning for it, since in Extensions you're allowed to reuse the Geometry Primitives...

@clausnagel
Copy link
Contributor Author

I'm currently mapping a CityGML ADE to a CityJSON Extension. There are 21 attributes defined for AbstractCityObect in this CityGML ADE. So, in the "extraAttributes" object, I have to add an entry for every CityObject of CityJSON and copy&paste the 21 attributes into it. I guess, it would make my life simpler if it would be possible to have a single entry for "AbstractCityObject", but it's not required, of course.

Would using "allOf" be allowed? At least, I would just have to define my attributes once and reuse them?

{
  "type": "CityJSONExtension",
  ...
  "extraAttributes": {
    "Building": {
      "+myBuildingAttr": { "type": "string" },
      "allOf": [
        {
          "$ref": "#/$defs/my21Attributes"
        }
      ]
    }
  }
}

@hugoledoux
Copy link
Member

I don't think "allOf" is meant to be used this way, and if you try with cjval it crashes (which doesn't mean that it's wrong, but at the moment it crashes).

I understand that at the moment you need to copy a lot, but this is the only way I reckon. I spoke to @balazsdukai and what we thought could help -- in the next release -- would be to add a "ALL" to indicate that all CityObjects are affected by this "extraAttributes". That would be simple solution.

For the 21 attributes, I don't think there's an easy solution; I'll think about it.

But nice that you report those (it's for CHEK, right?), we haven't had many serious users of Extensions who dived into the details, so it's very useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants