[英]FIWARE, NGSI-LD - Understand the @context
我正在为特定应用程序创建数据模型,但我没有从任何基础模型开始; 因为我没有从任何基本模型开始,所以下面的上下文就足够了,对吗?
"@context": [
"https://schema.lab.fiware.org/ld/context",
"https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.3.jsonld"
]
我的数据模型并不复杂,只是这些属性和实体更“复杂”:
"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"
]
}
如果您使用自己的自定义词汇表,您应该在自己的 LD @context 中声明您的类型和属性。 例如,
{
"@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"
]
}
您似乎也没有正确使用 URN,您应该检查一下。 unitCode
似乎也被破坏了,因为它必须遵循 UN/CEFACT 单位代码。
尽管如此,我不建议您为传感器定义自己的词汇表,因为现有的词汇表(例如 SAREF 或 W3C SOSA)可以而且应该重复使用。
我不是数据模型专家,但我确实对 NGSI-LD 和 NGSI-LD 代理了解一两件事。 您使用的@context 是“https://schema.lab.fiware.org/ld/context”和核心上下文v1.3 的数组。
“https://schema.lab.fiware.org/ld/context”又是一个数组“https://fiware.github.io/data-models/context.jsonld”和核心的v1.1语境 ...
而且,“”https://fiware.github.io/data-models/context.jsonld”没有定义您正在使用的三个术语中的任何一个,因此,无需为此提供任何上下文。这些术语将是使用核心上下文的默认 URL 扩展(核心上下文的 @vocab 成员的值定义默认 URL)。
NGSI-LD 代理具有内置的核心上下文,您不需要传递它,所以帮自己一个忙,通过不将核心上下文传递给代理来获得更快的响应。 没必要。 而且,如果您需要用户上下文,请将其传递到 HTTP 标头“链接”中。 将它托管在某个地方(NGSi-LD 代理提供该服务),因此您不会强迫可怜的代理在每个请求中解析 @conterxt。
最后,请遵循 Jose Manuels 的建议并为您的属性使用标准名称(以及 unitCode 的值)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.