[英]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.