使用 Web Feature Service 查詢資料集
本文說明如何使用 Web Feature Service (WFS) 查詢 Azure 地圖服務 Creator 資料集。 您可以使用 WFS API 來查詢資料集內的所有功能集合或特定集合。 例如,您可以使用 WFS 來尋找特定建物和樓層中的所有中型會議室。
必要條件
- 順利完成教學課程:使用 Creator 建立室內地圖。
- 在使用 Creator 建立室內地圖教學課程的檢查資料集建立狀態一節中取得的
datasetId
。
本文使用與教學課程:使用 Creator 建立室內地圖相同的範例室內地圖。
重要
- 本文章使用
us.atlas.microsoft.com
地理 URL。 如果您的 Creator 服務未在美國建立,您必須使用不同的地理 URL。 如需詳細資訊,請參閱存取 Creator 服務。 - 在本文中的 URL 範例中,您將需要取代:
{Azure-Maps-Subscription-key}
,使用您的 Azure 地圖服務訂用帳戶金鑰。{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 說明集合 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 以取得 unit
功能集合。
若要查詢資料集中的 unit 集合,請建立新的 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
功能的功能 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": ""
}, {"..."}
]
}