日本語
属性を足す
カタログのモデルはほぼ合うけれど、自分のシステムにはいくつか属性が足りない。そんなときは新しいモデルを作る必要も、カタログを複製する必要もありません。カタログの @context を取り込み、足したい属性だけを定義した小さな @context を自分で公開します。これを拡張と呼びます(技術的には、モデルのプロファイルです)。
名前だけが違うときや、合うモデルがないときに読むページは、ガイドの図で選べます。
拡張ビルダー
いちばん簡単な方法は、拡張ビルダーです。モデルを選んで属性を入力すると、次の 2 つのファイルができます。
- @context:カタログの
@contextを URL で読み込み、自分の属性だけを定義します。カタログの属性の意味は変わりません。次の節と同じ書き方です。 - JSON Schema:カタログの属性と自分の属性の両方を検証します。カタログのスキーマをその時点のバージョンで丸ごと写したものなので、カタログの新しいマイナーバージョンには追従しません(カタログに新しい属性が増えたとき)。
名前空間には、自分が管理するドメインの URL を使ってください。多くのシステムで役に立つ属性なら、カタログへの提案をお願いします(ビルダーの下のリンクから)。入力した内容はこのページの中だけで使われ、どこにも送られません。ただし、提案フォームへのリンクを開くと、フォームに入力済みの状態で開くため、次の内容が GitHub に送られます。モデルの型と、名前を付けた属性ごとの名前、NGSI-LD の種類、値の型と形式、必須かどうか、説明です。
あなたの属性
あなたの @context
{
"@context": [
"https://datamodels.jp/context/transportation/v1.jsonld",
{
"acme": "https://example.com/ns/acme/",
"patrolRoute": "acme:patrolRoute"
}
]
}JSON Schema(カタログの属性 + あなたの属性)
カタログのスキーマは閉じている(additionalProperties: false)ため、参照だけでは属性を足せません。これは https://datamodels.jp/schema/transportation/RoadRestriction/v1.0.0.json をもとに作ったもので、新しいバージョンに移るときは作り直してください。$id はあなたの URL に書き換えてください。
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/schema/acme/RoadRestriction.json",
"title": "RoadRestriction (acme)",
"description": "One road restriction, including closures: road name, regulated section as a point, line or area, status and category.",
"x-license-url": "https://datamodels.jp/LICENSE-CONTENT",
"x-model-tags": "road, transportation, Japan",
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uri",
"description": "Entity id (URN)"
},
"type": {
"type": "string",
"const": "RoadRestriction",
"description": "Entity type"
},
"@context": {
"description": "JSON-LD context of the entity, optional: a context URL or a list of context URLs",
"oneOf": [
{
"type": "string",
"format": "uri"
},
{
"type": "array",
"items": {
"type": "string",
"format": "uri"
},
"minItems": 1
}
]
},
"roadName": {
"description": "Road name",
"type": "string",
"x-ngsi": {
"type": "Property"
},
"x-iri": "https://smartdatamodels.org/dataModel.Transportation/roadName"
},
"roadType": {
"description": "Road class by the Road Act (道路法第3条): expressway (高速自動車国道), nationalRoad (一般国道), prefecturalRoad (都道府県道), municipalRoad (市町村道), or other for a road outside the Act (農道, 林道, private road). A motorway designation (自動車専用道路) is not a class of its own: give the class of the road it is on",
"type": "string",
"enum": [
"expressway",
"nationalRoad",
"prefecturalRoad",
"municipalRoad",
"other"
],
"x-ngsi": {
"type": "Property"
},
"x-iri": "https://datamodels.jp/ns/transportation/roadType"
},
"address": {
"$ref": "https://datamodels.jp/schema/common/JapaneseAddress/v1.0.0.json",
"description": "Address of the location, as a JapaneseAddress value (common subject)",
"x-ngsi": {
"type": "Property",
"model": "https://datamodels.jp/ns/common/JapaneseAddress"
},
"x-iri": "https://schema.org/address"
},
"location": {
"$ref": "https://datamodels.jp/schema/common/Geometry/v1.0.0.json",
"description": "The regulated section, as a GeoJSON geometry. A point for a single-spot restriction, a LineString for a section, a polygon for an area, matching the point/line/area regulation forms (点規制・線規制・面規制) of the NPA's traffic regulation data format (交通規制情報(拡張版標準フォーマット)説明書 Ver: k_2.1, JARTIC, 2025-01-20)",
"x-ngsi": {
"type": "GeoProperty",
"model": "https://datamodels.jp/ns/common/Geometry"
},
"x-iri": "https://uri.etsi.org/ngsi-ld/location"
},
"restrictionLength": {
"type": "number",
"minimum": 0,
"description": "Length of the regulated section in metres, for a line. The NPA format (距離・延長, item 133) and EEI (距離・延長) carry it; the geometry alone may be simplified",
"x-ngsi": {
"type": "Property"
},
"x-iri": "https://datamodels.jp/ns/transportation/restrictionLength"
},
"maximumAllowedWeight": {
"type": "number",
"minimum": 0,
"description": "Weight limit in kilograms: vehicles heavier than this may not pass (for example 4000 when the source limit is 4 t). The same term as Smart Data Models RoadSegment; the NPA format gives it in tonnes (制限重量, item 135). Whether it is gross weight or payload follows the source; keep its wording in statusLabel",
"x-ngsi": {
"type": "Property"
},
"x-iri": "https://smartdatamodels.org/dataModel.Transportation/maximumAllowedWeight"
},
"restrictionStatus": {
"description": "Normalised restriction state, the value space of Smart Data Models RoadSegment.status: closed (no traffic), limited (traffic possible but not in full capacity), open (restriction lifted or not yet in place). The local wording goes in statusLabel; regulationCategory gives the finer public-sector category. When no value fits, leave it out and give the local wording in statusLabel",
"type": "string",
"enum": [
"closed",
"limited",
"open"
],
"x-ngsi": {
"type": "Property"
},
"x-iri": "https://datamodels.jp/ns/transportation/restrictionStatus"
},
"regulationCategory": {
"description": "Regulation category, from the legend of MLIT's Road Information Provision System (道路情報提供システム 通行規制情報, road-info-prvs.mlit.go.jp, accessed 2026-09-24): the categories a road administrator uses for a driver-facing closure or restriction. closedWeather (通行止(異常気象等)) also covers closures after a disaster, such as a landslide or a collapsed road shoulder. Optional and independent of restrictionStatus",
"type": "string",
"enum": [
"closedWeather",
"closedConstruction",
"closedHeavyVehicle",
"closedWinter",
"laneRestriction",
"alternatingOneWay",
"mobileRestriction",
"chainRestriction",
"chainGuidance",
"other"
],
"x-ngsi": {
"type": "Property"
},
"x-iri": "https://datamodels.jp/ns/transportation/regulationCategory"
},
"statusLabel": {
"type": "string",
"minLength": 1,
"description": "The restriction status in the local or source system's wording (依頼中, 通行止め中, 解除済み). Required when restrictionStatus is left out",
"x-ngsi": {
"type": "Property"
},
"x-iri": "https://datamodels.jp/ns/task/statusLabel"
},
"validFrom": {
"description": "When the restriction takes effect",
"type": "string",
"format": "date-time",
"x-ngsi": {
"type": "Property"
},
"x-iri": "https://smartdatamodels.org/validFrom"
},
"validTo": {
"description": "When the restriction is lifted",
"type": "string",
"format": "date-time",
"x-ngsi": {
"type": "Property"
},
"x-iri": "https://smartdatamodels.org/dataModel.Alert/validTo"
},
"description": {
"type": "string",
"description": "Free-text memo",
"x-ngsi": {
"type": "Property"
},
"x-iri": "http://purl.org/dc/terms/description"
},
"patrolRoute": {
"type": "string",
"x-ngsi": {
"type": "Property"
},
"x-iri": "https://example.com/ns/acme/patrolRoute"
}
},
"required": [
"id",
"type",
"location"
],
"anyOf": [
{
"required": [
"restrictionStatus"
]
},
{
"required": [
"statusLabel"
]
}
],
"additionalProperties": false,
"x-extends": "https://datamodels.jp/schema/transportation/RoadRestriction/v1.0.0.json"
}@context の書き方
カタログの @context を URL で並べ、その横に自分の属性を定義します。次の例は RoadRestriction に巡回ルート patrolRoute を足すものです。
json
{
"@context": [
"https://datamodels.jp/context/transportation/v1.jsonld",
{
"acme": "https://example.com/ns/acme/",
"patrolRoute": "acme:patrolRoute"
}
]
}カタログの属性の意味はそのままで、足した属性だけが新しくなります。足した属性の名前は、自分が管理するドメインの下に置きます(この例では example.com)。datamodels.jp の下の名前は、カタログが管理するものです。
データで使う
データには、カタログの @context の代わりに自分の @context を書き、カタログの属性の横に自分の属性を書きます。
json
{
"@context": "https://example.com/context/acme-transportation-v1.jsonld",
"id": "urn:ngsi-ld:RoadRestriction:0001",
"type": "RoadRestriction",
"roadName": "靖国通り",
"location": {
"type": "LineString",
"coordinates": [[139.7505, 35.695], [139.752, 35.6956]]
},
"restrictionStatus": "closed",
"patrolRoute": "A-3"
}NGSI-LD のブローカーに送るときは、属性を normalized の形に変え、自分の @context と NGSI-LD のコアコンテキストの両方を並べます(normalized の形)。
置き場所
@context は、自分が管理する、変わらない HTTPS のアドレスに置きます(自分のドメイン、GitHub Pages、アドレスが固定のオブジェクトストレージなど)。ブローカーや JSON-LD のツールは、そこから読みます。
- バージョンごとに別のアドレスで公開し、公開したファイルは変えず、消さないでください。
Content-Type: application/ld+jsonとAccess-Control-Allow-Origin: *で配信します。
自分の @context の置き場所は、カタログでは用意していません。ただし、モデルのページの「このモデルをもとにしたもの」に載せることはできます(拡張を載せる)。同じ意味の属性が要るほかの組織が、その名前を使えます。
カタログに新しい属性が増えたとき
自分の @context はカタログの @context をバージョンの別名(v1.jsonld)で取り込んでいるので、カタログの新しい属性もすぐデータで使えます。JSON Schema は自動では追従しません。拡張ビルダーで作り直してください。
Smart Data Models のモデルから始めるとき
書き方は同じです。上流の @context は、master ではなく、コミットを固定したアドレスで取り込みます。上流が変わっても、データの意味が変わらないようにするためです。アドレスの形は次のとおりです。
https://raw.githubusercontent.com/smart-data-models/dataModel.<Subject>/<commit>/context.jsonld
他の人にも役立ちそうなら
その属性を提案フォームでカタログに提案してください。カタログに入れば、新しいデータではカタログの属性を使えます。すでに書いたデータは、変換するまで自分の属性(とその意味)のままです。