首页 > 解决方案 > Calculate Route keeps ploting not the shortest route

问题描述

I'm using HERE's calculate route API to present routes on the map. In a few places, I keep getting results that led me here as I am seemingly unable to achieve reasonable results. Near Warsaw, my route keeps turning to the north towards the city just to turn south-west that is back in the main direction whereas there is a straight road that would allow achieving the same. My users expect routes to be as straight as possible and I am not able to defend nor explain such deviations as this in route plotting.

Request parameteres:

url: 'https://route.api.here.com/routing/7.2/calculateroute.json',
  method: 'get',
  params:
   { app_id: 'is-it-possible-to-learn-this-power-?',
     app_code: 'not-from-a-jedi',
     mode:
      'fastest;truck;traffic:disabled;tollroad:0,motorway:0,boatFerry:0,tunnel:0,dirtRoad:0,park:0',
     waypoint0: '54.11025,22.96542',
     waypoint1: '49.19168,16.65446',
     waypoint2: '49.59958,17.26838',
     avoidSeasonalClosures: true,
     language: 'pl-pl',
     excludeCountries: 'CHE,DEU',
     metricSystem: 'metric',
     legAttributes: 'length,travelTime',
     jsonAttributes: 9,
     routeAttributes: 'shape,legs',
     limitedWeight: 40 }
}

It is worth noting that at first I was convinced that I get this result because of the traffic settings, but it turn out no matter which option (concerning traffic) do I choose I always end up with what it look like the same route shape.

Result on map: enter image description here

Result near the city: enter image description here

My question is: is there a way to achieve a straight route without detours such as this in my example or maybe this is totally acceptable route but I am unaware of the reason?

标签: here-api

解决方案


这个问题的解决方案是排除高速公路并避免季节性关闭,因为在华沙和弗罗茨瓦夫附近有一些。

现在请求参数如下所示:

{ app_id: 'i-am-the-senate',
app_code: 'not-yet',
mode: 'fastest;truck;motorway:-2',
waypoint0: '54.11025,22.96542',
waypoint1: '49.19168,16.65446',
waypoint2: '49.59958,17.26838',
avoidSeasonalClosures: true,
avoidAreas: '53.204942,23.05379;53.100605,23.254131',
excludeCountries: 'CHE,DEU',
legAttributes: 'length,travelTime',
jsonAttributes: 9,
routeAttributes: 'shape,legs',
limitedWeight: 40 }

排除区域是比亚韦斯托克市附近和北部的道路,因为这条道路不是最佳的。

在此处输入图像描述


推荐阅读