Azure / opendigitaltwins-dtdl

Digital Twins Definition Language
Creative Commons Attribution 4.0 International
481 stars 163 forks source link

Can a geospatial point be a property in DTDL v3? #185

Open KaiDrange opened 1 month ago

KaiDrange commented 1 month ago

I'm currently unsure if the geospatial schemas can be used for properties in DTDL v3. I have a model with a point as property in my model:

    {
      "@type": "Property",
      "name": "GeoLocation",
      "schema": "point"
    }

I have a BasicDigitalTwin instance with "GeoLocation" in my Contents dictionary. I try to set the value to the following:

basicTwin.Contents["GeoLocation"] = new Dictionary<string, object>
{
    { "type", "Point" },
    { "coordinates", new[] { 10f, 20f } }
};

The twin gets created, but in the explorer, I get a "Properties missing a model..." error. I can see GeoLocation with type and a coordinates array, but with warning icons.

I just read that for older DTDL versions geospatial types could only be used for telemetry. The example for v3 is also for telemetry, but I haven't spotted any v3 information indicating that it can't be used for properties , so now I'm unsure if still is still a limitation or not.

So, perhaps the v3 documentation should be updated to explicitly mention this (unless it is there, but I have just missed it)?

If geospatial properties ARE supported, any pointers to what I'm currently doing wrong would be much appreciated.

jrdouceur commented 1 month ago

The DTDL v2 limitation on Properties was removed in DTDL v3, as highlighted by the first bullet in the Changes from Version 2 section of the DTDL v3 doc:

Arrays are now supported in a Property's schema hierarchy. Consequently, geospatial schemas may now be used in a Property.

From a DTDL perspective, your model looks fine. I'm afraid I lack sufficient familiarity with ADT to assist with your code.

KaiDrange commented 1 month ago

The DTDL v2 limitation on Properties was removed in DTDL v3, as highlighted by the first bullet in the Changes from Version 2 section of the DTDL v3 doc

Ah! I somehow missed that. My apologies. Thanks! :)

As for my actual problem, some more info in case an ADT person reads it: the json when fetching the twin from ADT looks like this "GeoLocation": { "type": "Point", "coordinates": [47.643742, -122.128014] } ...so same as in this example in the docs.

However, in the Azure Digital Twins explorer, this is what I see:

image