如何从REST API中的航路点获取总距离和时间
我需要得到从这里的航路点到RESTAPI的总距离和时间。 现在我使用路由api:如何从REST API中的航路点获取总距离和时间,rest,here-api,Rest,Here Api,我需要得到从这里的航路点到RESTAPI的总距离和时间。 现在我使用路由api: https://route.api.here.com/routing/7.2/calculateroute.json "app_id=" + API_ID "&app_code=" + APP_CODE "&waypoint0=geo!" + fromCoordsLocation "&waypoint1=geo!" + toCoordsLocatio
https://route.api.here.com/routing/7.2/calculateroute.json
"app_id=" + API_ID
"&app_code=" + APP_CODE
"&waypoint0=geo!" + fromCoordsLocation
"&waypoint1=geo!" + toCoordsLocation
"&mode=fastest;car"
并从json摘要对象(
Response->Route->summary
)中读取它们。此方法返回所有机动,对于长距离,回调速度较慢。有些东西只允许接收摘要(或总距离和时间)?查看这些附加属性,以便您可以根据需要自定义请求。在本例中,我使用了representation=overview,您的请求将是
https://route.api.here.com/routing/7.2/calculateroute.json
"app_id=" + API_ID
"&app_code=" + APP_CODE
"&waypoint0=geo!" + fromCoordsLocation
"&waypoint1=geo!" + toCoordsLocation
"&mode=fastest;car&representation=overview"
响应将减少到78行,默认为232行:
{
"response": {
"metaInfo": {
"timestamp": "2019-11-14T10:03:16Z",
"mapVersion": "8.30.102.151",
"moduleVersion": "7.2.201945-5699",
"interfaceVersion": "2.6.74",
"availableMapVersion": [
"8.30.102.151"
]
},
"route": [
{
"waypoint": [
{
"linkId": "-53623477",
"mappedPosition": {
"latitude": 52.4999825,
"longitude": 13.3999652
},
"originalPosition": {
"latitude": 52.5,
"longitude": 13.4
},
"type": "stopOver",
"spot": 0.3538462,
"sideOfStreet": "left",
"mappedRoadName": "Neuenburger Straße",
"label": "Neuenburger Straße",
"shapeIndex": 0,
"source": "user"
},
{
"linkId": "+1215312511",
"mappedPosition": {
"latitude": 52.4992955,
"longitude": 13.4491968
},
"originalPosition": {
"latitude": 52.5,
"longitude": 13.45
},
"type": "stopOver",
"spot": 1.0,
"sideOfStreet": "left",
"mappedRoadName": "Schlesische Straße",
"label": "Schlesische Straße",
"shapeIndex": 56,
"source": "user"
}
],
"mode": {
"type": "fastest",
"transportModes": [
"car"
],
"trafficMode": "disabled",
"feature": []
},
"summary": {
"distance": 3847,
"trafficTime": 869,
"baseTime": 667,
"flags": [
"noThroughRoad",
"builtUpArea",
"park",
"privateRoad"
],
"text": "The trip takes <span class=\"length\">3.8 km</span> and <span class=\"time\">11 mins</span>.",
"travelTime": 667,
"_type": "RouteSummaryType"
}
}
],
"language": "en-us"
}
}
{
“答复”:{
“元信息”:{
“时间戳”:“2019-11-14T10:03:16Z”,
“地图版本”:“8.30.102.151”,
“模块转换”:“7.2.201945-5699”,
“接口外翻”:“2.6.74”,
“availableMapVersion”:[
"8.30.102.151"
]
},
“路线”:[
{
“航路点”:[
{
“linkId”:“-53623477”,
“映射位置”:{
“纬度”:52.4999825,
“经度”:13.3999652
},
“原始位置”:{
“纬度”:52.5,
“经度”:13.4
},
“类型”:“中途停留”,
“点”:0.3538462,
“sideOfStreet”:“left”,
“mappedRoadName”:“纽恩堡大街”,
“标签”:“纽恩堡大街”,
“形状索引”:0,
“来源”:“用户”
},
{
“linkId”:“+1215312511”,
“映射位置”:{
“纬度”:52.4992955,
“经度”:13.4491968
},
“原始位置”:{
“纬度”:52.5,
“经度”:13.45
},
“类型”:“中途停留”,
“点”:1.0,
“sideOfStreet”:“left”,
“mappedRoadName”:“Schlesische Straße”,
“标签”:“石勒西大街”,
“shapeIndex”:56,
“来源”:“用户”
}
],
“模式”:{
“类型”:“最快”,
“运输方式”:[
“汽车”
],
“交通模式”:“已禁用”,
“功能”:[]
},
“摘要”:{
“距离”:3847,
“我”:869,
“基准时间”:667,
“旗帜”:[
“无路”,
“建筑区”,
“公园”,
“私家路”
],
“文本”:“行程3.8公里11分钟。”,
“旅行时间”:667,
“类型”:“路由摘要类型”
}
}
],
“语言”:“en us”
}
}