简体   繁体   English

FIWARE,NGSI-LD - 了解@context

[英]FIWARE, NGSI-LD - Understand the @context

I am creating a data model for a particular application and I did not start from any base model;我正在为特定应用程序创建数据模型,但我没有从任何基础模型开始; since I did not start from any base model, the context below is sufficient, correct?因为我没有从任何基本模型开始,所以下面的上下文就足够了,对吗?

"@context": [
            "https://schema.lab.fiware.org/ld/context",
            "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.3.jsonld"
]

My data model is not complicated, with just these properties and entity being more "complex":我的数据模型并不复杂,只是这些属性和实体更“复杂”:

"address": {
            "type": "Property",
            "value": {
                "streetAddress": "",
                "postalCode": "",
                "addressLocality": "",
                "addressCountry": ""
            }
},
"location": {
            "type": "Point",
            "coordinates": [
                ,
            ]
},
{
        "id": "urn:ngsi-ld:MeasurementSensor:",
        "type": "MeasurementSensor",
        "measurementVariable": {
            "type": "Property",
            "value": "Temperature"
        },
        "measurementValue": {
            "type": "Property",
            "value": 32.0,
            "unitCode": "ºC",
            "observedAt": "2022-05-10T11:09:00.000Z"
        },
        "refX": {
            "type": "Relationship",
            "object": "urn:ngsi-ld:"
        },
        "@context": [
            "https://schema.lab.fiware.org/ld/context",
            "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.3.jsonld"
        ]
}

If you are using your own custom vocabulary you should declare your types and properties in your own LD @context.如果您使用自己的自定义词汇表,您应该在自己的 LD @context 中声明您的类型和属性。 For instance,例如,

{
   "@context": [
    {
     "MeasurementSensor": "https://example.org/my-types/MesaurementSensor"
    },
    "https://schema.lab.fiware.org/ld/context",
    "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.3.jsonld"
   ]
}

it also seems you are not using URNs properly, you should check.您似乎也没有正确使用 URN,您应该检查一下。 unitCode seems to be broken as well, as it must follow the UN/CEFACT unit codes. unitCode似乎也被破坏了,因为它必须遵循 UN/CEFACT 单位代码。

Nonetheless, I would not recommend to define your own vocabulary for sensors, given there are existing Vocabularies such as SAREF or W3C SOSA that can and should be reused.尽管如此,我不建议您为传感器定义自己的词汇表,因为现有的词汇表(例如 SAREF 或 W3C SOSA)可以而且应该重复使用。

I'm not a data model expert but I do know a thing or two about NGSI-LD and NGSI-LD brokers.我不是数据模型专家,但我确实对 NGSI-LD 和 NGSI-LD 代理了解一两件事。 The @context you use is an array of "https://schema.lab.fiware.org/ld/context" and v1.3 of the core context.您使用的@context 是“https://schema.lab.fiware.org/ld/context”和核心上下文v1.3 的数组。

"https://schema.lab.fiware.org/ld/context" in its turn is an array of "https://fiware.github.io/data-models/context.jsonld" and v1.1 of the core context ... “https://schema.lab.fiware.org/ld/context”又是一个数组“https://fiware.github.io/data-models/context.jsonld”和核心的v1.1语境 ...

And, ""https://fiware.github.io/data-models/context.jsonld" doesn't define any of the three terms you are using, so, no need to give any context for that. The terms will be expanded using the default URL of the core context (the value of the @vocab member of the core context defines the default URL).而且,“”https://fiware.github.io/data-models/context.jsonld”没有定义您正在使用的三个术语中的任何一个,因此,无需为此提供任何上下文。这些术语将是使用核心上下文的默认 URL 扩展(核心上下文的 @vocab 成员的值定义默认 URL)。

An NGSI-LD broker has the core context built-in, you don't need to pass it, so do yourself a favor, and get faster responses by not passing the core context to the broker. NGSI-LD 代理具有内置的核心上下文,您不需要传递它,所以帮自己一个忙,通过不将核心上下文传递给代理来获得更快的响应。 No need.没必要。 And, if you need a user context, pass it in the HTTP Header "Link" instead.而且,如果您需要用户上下文,请将其传递到 HTTP 标头“链接”中。 Host it somewhere (an NGSi-LD broker offers that service), so you don't force the poor broker to parse the @conterxt in each and every request.将它托管在某个地方(NGSi-LD 代理提供该服务),因此您不会强迫可怜的代理在每个请求中解析 @conterxt。

Lastly, do follow Jose Manuels recommendations and use standard names for your attributes (and value for unitCode).最后,请遵循 Jose Manuels 的建议并为您的属性使用标准名称(以及 unitCode 的值)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM