Web Feature Service を使用してデータセットのクエリを実行する
この記事では、Web Feature Service (WFS) を使用して Azure Maps Creator のデータセットに対してクエリを実行する方法について説明します。 WFS API を使用して、すべての地物コレクションや、データセット内の特定のコレクションに対してクエリを実行できます。 たとえば、WFS を使用して、特定の建物と階にある中規模の会議室をすべて検索することができます。
前提条件
- チュートリアルが正常に完了した場合: Creator を使用して、屋内マップを作成します。
- チュートリアル「Creator を使用して屋内マップを作成する」の「データセットの作成状態を確認する」セクションで取得した
datasetId
。
この記事では、「チュートリアル: Creator を使用して屋内マップを作成する」で使用したのと同じサンプル屋内マップを使用します。
重要
- この記事では、地理的な URL
us.atlas.microsoft.com
を使用します。 Creator サービスが米国内で作成されていない場合は、別の地理的 URL を使用する必要があります。 詳細については、「Creator サービスにアクセスする」を参照してください。 - この記事の URL の例では、以下を置き換える必要があります。
{Azure-Maps-Subscription-key}
を Azure Maps サブスクリプション キーに置き換える必要があります。{datasetId}
を、「Creator を使用して屋内マップを作成する」のチュートリアルの「データセットの作成状態を確認する」セクションで取得したdatasetId
に置き換えます。
地物コレクションのクエリを実行する
データセット内のすべてのコレクションのクエリを実行するには、新しい HTTP GET 要求を作成します。
WFS API への次の URL を入力します。 要求は次の URL のようになります。
https://us.atlas.microsoft.com/wfs/datasets/{datasetId}/collections?subscription-key={Your-Azure-Maps-Subscription-key}&api-version=2.0
応答本文は GeoJSON 形式で返され、データセット内のすべてのコレクションが含まれます。 わかりやすくするために、この例では unit
コレクションのみを示しています。 すべてのコレクションを含む例を参照するには、WFS Describe Collections API に関するページを参照してください。 コレクションの詳細については、links
要素内の任意の URL を選択して確認できます。
{
"collections": [
{
"name": "unit",
"description": "A physical and non-overlapping area which might be occupied and traversed by a navigating agent. Can be a hallway, a room, a courtyard, etc. It is surrounded by physical obstruction (wall), unless the is_open_area attribute is equal to true, and one must add openings where the obstruction shouldn't be there. If is_open_area attribute is equal to true, all the sides are assumed open to the surroundings and walls are to be added where needed. Walls for open areas are represented as a line_element or area_element with is_obstruction equal to true.",
"links": [
{
"href": "https://atlas.microsoft.com/wfs/datasets/{datasetId}/collections/unit/definition?api-version=1.0",
"rel": "describedBy",
"title": "Metadata catalogue for unit"
},
{
"href": "https://atlas.microsoft.com/wfs/datasets/{datasetId}/collections/unit/items?api-version=1.0",
"rel": "data",
"title": "unit"
}
{
"href": "https://atlas.microsoft.com/wfs/datasets/{datasetId}/collections/unit?api-version=1.0",
"rel": "self",
"title": "Metadata catalogue for unit"
}
]
},
ユニット地物コレクションのクエリを実行する
このセクションでは、unit
地物コレクションに対する WFS API のクエリ実行について説明します。
データセット内のユニット コレクションのクエリを実行するには、新しい HTTP GET 要求を作成します。
https://us.atlas.microsoft.com/wfs/datasets/{datasetId}/collections/unit/items?subscription-key={Your-Azure-Maps-Subscription-key}&api-version=2.0
応答が返された後、unit
地物の 1 つに地物 id
をコピーします。 次の例では、地物 id
は "UNIT26" です。 地物状態を更新するときに "UNIT26" を地物 id
として使用します。
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": ["..."]
},
"properties": {
"original_id": "b7410920-8cb0-490b-ab23-b489fd35aed0",
"category_id": "CTG8",
"is_open_area": true,
"navigable_by": [
"pedestrian"
],
"route_through_behavior": "allowed",
"level_id": "LVL14",
"occupants": [],
"address_id": "DIR1",
"name": "157"
},
"id": "UNIT26",
"featureType": ""
}, {"..."}
]
}