here-api - 如何查找 Here Maps 链接 ID 的几何形状/形状
问题描述
我有一个 Here Maps 链接 ID 的列表。我想得到他们的几何形状。我尝试调用 v7 calculateroute REST API,在 waypoint0 和 waypoint1 中传递一个 link_id,如下所示,
https://route.ls.hereapi.com/routing/7.2/calculateroute.json?apiKey={API_KEY}&mode=fastest;car&waypoint0=link!-893783351&waypoint1=link!-893783351&routeAttributes=notes&linkAttributes=shape,speedLimit
{
"response": {
"metaInfo": {
"timestamp": "2021-09-28T04:03:39Z",
"mapVersion": "8.30.124.155",
"moduleVersion": "7.2.202138-9419",
"interfaceVersion": "2.6.77",
"availableMapVersion": [
"8.30.124.155"
]
},
"route": [
{
"waypoint": [
{
"linkId": "+893783351",
"mappedPosition": {
"latitude": 26.711034,
"longitude": -80.1374786
},
"originalPosition": {
"latitude": 26.711034,
"longitude": -80.1374786
},
"type": "stopOver",
"spot": 0.4929245,
"sideOfStreet": "neither",
"mappedRoadName": "",
"label": "",
"shapeIndex": 0,
"source": "user"
},
{
"linkId": "+893783351",
"mappedPosition": {
"latitude": 26.711034,
"longitude": -80.1374786
},
"originalPosition": {
"latitude": 26.711034,
"longitude": -80.1374786
},
"type": "stopOver",
"spot": 0.4929245,
"sideOfStreet": "neither",
"mappedRoadName": "",
"label": "",
"shapeIndex": 1,
"source": "user"
}
],
"mode": {
"type": "fastest",
"transportModes": [
"car"
],
"trafficMode": "disabled",
"feature": []
},
"shape": [
"26.711034,-80.1374786",
"26.711034,-80.1374786"
],
"leg": [
{
"start": {
"linkId": "+893783351",
"mappedPosition": {
"latitude": 26.711034,
"longitude": -80.1374786
},
"originalPosition": {
"latitude": 26.711034,
"longitude": -80.1374786
},
"type": "stopOver",
"spot": 0.4929245,
"sideOfStreet": "neither",
"mappedRoadName": "",
"label": "",
"shapeIndex": 0,
"source": "user"
},
"end": {
"linkId": "+893783351",
"mappedPosition": {
"latitude": 26.711034,
"longitude": -80.1374786
},
"originalPosition": {
"latitude": 26.711034,
"longitude": -80.1374786
},
"type": "stopOver",
"spot": 0.4929245,
"sideOfStreet": "neither",
"mappedRoadName": "",
"label": "",
"shapeIndex": 1,
"source": "user"
},
"length": 0,
"travelTime": 0,
"maneuver": [
{
"position": {
"latitude": 26.711034,
"longitude": -80.1374786
},
"instruction": "Take ramp.",
"travelTime": 0,
"length": 0,
"id": "M1",
"_type": "PrivateTransportManeuverType"
},
{
"position": {
"latitude": 26.711034,
"longitude": -80.1374786
},
"instruction": "Arrive at your destination.",
"travelTime": 0,
"length": 0,
"id": "M2",
"_type": "PrivateTransportManeuverType"
}
]
}
],
"note": [
{
"type": "violation",
"code": "routingOptionViolated",
"text": "startDirection"
}
],
"summary": {
"distance": 0,
"trafficTime": 0,
"baseTime": 0,
"flags": [
"tollroad"
],
"text": "The trip takes <span class=\"length\">0 m</span> and less than <span class=\"time\">1 min</span>.",
"travelTime": 0,
"_type": "RouteSummaryType"
}
}
],
"language": "en-us"
}
}
但是响应中返回的形状似乎不是链接的形状,即使开发人员指南提到参数“linkAttributes”可以用于获取链接形状。
如果我在这里做错了什么,请告知。另外,如果我可以使用另一个 API 来获得链接的形状。
我可以根据 link_id 进行 API 调用。
解决方案
航路点用于定义路线必须经过的地图上的位置。航路点可以是 StopOver(例如,起点或目的地)或 PassThrough。一个有效的 CalculateRoute 请求必须包含至少两个 StopOver 航路点。为路线分配航路点的三种方法
- 粗略的定位:GeoWaypointParameterType
- 对街道的引用:带有 StreetPositions 的 NavigationWaypointParameter
- 对链接的精确引用:带有 LinkPositions 的 NavigationWaypointParameter
让我专注于第三点,因为您使用的是链接位置。请注意,NavigationWaypointParameter 通过 LinkId 和可选的 Spot 值定义航点。Spot 定义为从链接的参考节点到非参考节点的小数距离,其值介于 0 和 1 之间。当请求中未提供 Spot 值或 DisplayPosition 时,假定默认值 0.5
航点的可选显示位置定义了该位置在地图上的显示位置。它表示位置的中心并且不可导航,与位置的导航位置相比,它不位于路由网络中的链路上。显示位置允许路由引擎决定航路点是位于路线的左侧还是右侧。
这是文档中的示例:
// using exact link information with display position and spot:
&waypoint0=link!37.7914050,-122.3987030!-743460791,0.8996
// using exact link information with display position and spot and additional stopover delay of 5 minutes:
&waypoint0=link!stopOver,300!37.7914050,-122.3987030!-743460791,0.8996
// the display position is optional:
&waypoint0=link!!-743460795,0.1342
&waypoint0=link!-743460795,0.1342
// using user label:
&waypoint0=link!37.7914050,-122.3987030;My Home!-743460791,0.8996
// using user label without display position:
&waypoint1=link!;My Work!-743460795
// link traveled in any direction:
&waypoint0=link!*743460795
由于请求中的链接参数对于航点 0 和航点 1 相同,因此仅返回该点。但是,如果您设置点例如,链接将显示如下: https://refclient.ext.here.com/#url=https://route.api.here.com/routing/7.2/calculateroute。 json?routeattributes=sh,gr&mode=fastest;car&maneuverattributes=po,ti,pt,ac,di,fj,ix&language=en-us&jsonattributes=41&metricsystem=metric&waypoint0=link!stopOver!-893783351,0.1342&waypoint1=link!stopOver!-893783351&app_code =kg72HCGA7Um5GdCdXRp5mw&app_id=wkkI0nFlieJAZT1KrbpW
但是,如果您正在寻找特定于链接 ID 的详细信息,您可以使用 PDE 请求,如下所述: https ://tcs.ext.here.com/examples/v3/pde_get_any_link_info
推荐阅读
- iis - IIS下ASP.NET Core随机重启
- javascript - 如何在 MongoDB 中创建长时间戳的 TTL 索引
- javascript - NodeJS Ajv 模块总是记录消息'$ref:路径“#”的架构中忽略的关键字'
- c# - Windows Forms exe 文件可以在我的电脑上运行,而不能在其他电脑上运行
- featuretools - 来自 featuretools 的 feature_matrix[["MEAN_SUNDAY(log.value, datetime)", "MEAN_SUNDAY(log.value_2, datetime)"]] 中的“log”是什么意思?
- html - 禁止父 div 宽度动态高度扩展以适应子内容
- java - 如何修改 Ctakes 的 CVD 和 CPE 以访问 UMLS?
- java - Tinkerpop/Gremlin:选择顶点和输出边数
- asp.net - 允许所有人访问特定页面
- ios - 如何禁用某个 oslog 日志级别?