你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
使用 Web 地理要素服务查询数据集
本文介绍如何使用 Web 地理要素服务 (WFS) 查询 Azure Maps Creator 数据集。 可以使用 WFS API 查询数据集中所有功能的集合或某个特定的集合。 例如,可以使用 WFS 查找特定建筑和楼层的所有中型会议室。
先决条件
- 成功完成教程:使用 Creator 创建室内地图。
- 从“使用 Creator 创建室内地图”教程的“检查数据集创建状态”部分获取
datasetId
。
本文使用与“使用 Creator 创建室内地图”教程相同的示例室内地图。
重要
- 本文使用
us.atlas.microsoft.com
地理 URL。 如果 Creator 服务不是在美国创建的,则必须使用不同的地理 URL。 有关详细信息,请参阅访问 Creator 服务。 - 在本文的 URL 示例中,需要:
- 将
{Azure-Maps-Subscription-key}
替换为你的 Azure Maps 订阅密钥。 - 将
{datasetId}
替换为datasetId
(从“使用 Creator 创建室内地图”教程的检查数据集创建状态 部分获取)。
- 将
查询特征集合
若要查询数据集中的所有集合,请创建新的“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 集合,请创建新的“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": ""
}, {"..."}
]
}