logoSpatial Topology

IDs in IMDF

IMDF 裡的各種 ID 到底是怎麼回事?

IMDF 裡的 ID

在 IMDF 中,所有看得到的物件都使用 uuid v4 來當作 ID(例如:ac7adae1-f953-4562-8fdf-a1e0ef1d603e),這樣可以確保每個物件都是唯一的。並且在物件之間有關聯時,也可以透過這個 ID 來建立關聯。 當我們在為一個全新的場域建立 IMDF 時至少會有以下幾個必要的檔案:

  • venue.geojson
  • building.geojson
  • address.geojson
  • footprint.geojson
  • level.geojson
  • unit.geojson
  • amenity.geojson
  • opening.geojson

這些不同的檔案之間都是依靠 ID 來建立關聯的,例如在 venue.geojson, building.geojson 中會有一個 address_id 的欄位,裡面存放的是這個場域地址的 ID。

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "id": "dd59d986-251a-41c1-989e-bf35d4b66e33", // 這是venue的ID
      "feature_type": "venue",
      "properties": {
        "category": "university",
        "restriction": null,
        "name": {
          "en": "National Yang Ming Chiao Tung University - Yangming Campus",
          "zh": "國立陽明交通大學 - 陽明校區"
        },
        "alt_name": {"en": "NYCU - Yangming Campus"},
        "hours": "Mo-Fr 09:00-17:00",
        "phone": "+886228267000",
        "website": "https://nycu.edu.tw/",
        "display_point": {
          "type": "Point",
          "coordinates": [121.5158815, 25.1228118]
        },
        "address_id": "b2c99096-281b-4d6e-b8c9-8042a264609b" // 這裡跟address的ID一樣
      },
      "geometry": {
        "type": "MultiPolygon",
        "coordinates": [
          [
            [
              [121.5156356, 25.1226665],
              [121.5161813, 25.1226938],
              [121.5161582, 25.123056],
              [121.5158315, 25.1230426],
              [121.5158285, 25.1230844],
              [121.5155214, 25.123071],
              [121.5155368, 25.1227527],
              [121.5156309, 25.1227565],
              [121.5156356, 25.1226665]
            ]
          ]
        ]
      }
    }
  ]
}
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "id": "02f9d41b-8b38-4b8b-a13c-5e5288248460", // 這是building的ID
      "feature_type": "building",
      "properties": {
        "name": {"en": "2nd Medical Building", "zh": "醫學二館"},
        "alt_name": null,
        "category": "unspecified",
        "restriction": null,
        "display_point": {
          "type": "Point",
          "coordinates": [121.5158815, 25.1228118]
        },
        "address_id": "b2c99096-281b-4d6e-b8c9-8042a264609b" // 這裡跟address的ID一樣
      },
      "geometry": null
    },
    {
      "type": "Feature",
      "id": "211ae662-0344-45af-aab7-bb0c35ff90e7", // 這是另一棟building的ID
      "feature_type": "building",
      "properties": {
        "name": {"en": "Yangming Campus Library", "zh": "陽明校區圖書館"},
        "alt_name": null,
        "category": "unspecified",
        "restriction": null,
        "display_point": {
          "type": "Point",
          "coordinates": [121.5134608, 25.1204507]
        },
        "address_id": "b2c99096-281b-4d6e-b8c9-8042a264609b" // 這裡跟address的ID一樣
      },
      "geometry": null
    }
  ]
}
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "id": "b2c99096-281b-4d6e-b8c9-8042a264609b", // 這是address的ID
      "feature_type": "address",
      "properties": {
        "address": "No. 155, Sec. 2, Linong St., Beitou Dist., Taipei City",
        "restriction": null,
        "unit": null,
        "locality": "Taipei",
        "province": "TW-TPE",
        "country": "TW",
        "postal_code": "112304",
        "postal_code_ext": null,
        "postal_code_vanity": null,
        "hours": null,
        "phone": null,
        "website": null
      },
      "geometry": null
    }
  ]
}

在 Sandbox 中生成 id

如果在製作過程中,為了確保辨識新加上去的物件,可以先把 id 欄位留空,這樣在上傳到 IMDF Sandbox 時,系統會自動幫你生成一個 uuid v4 的 id。

因為在後期各種類別的物件數量都大大增加,因此在分階段、樓層添加物件時,先留空 id 可以方便製作時分辨剛新增的物件。

例如:id: "",進到 IMDF Sandbox 後,系統會偵測並自動幫你生成一個 id。

id 必須是全球唯一

任何上傳到 IMDF 系統中的檔案,所有 id 都必須是全球唯一的,否則會導致審核失敗。 例如:同一個 id 已經上傳到陽交大交大校區,若再上傳到陽明校區,系統就會告知你 id 重複。