问题
In v7, this is the way of getting route with multiple passthrough waypoints:
https://route.api.here.com/routing/7.2/calculateroute.json?waypoint0=32.353514,-61.126775&waypoint1=passThrough!32.365181,-61.102086&waypoint2=32.360273,-61.091979&mode=fastest;pedestrian...
In v8 api reference, there's "via" which seems to be used for stop over waypoints.
I tried https://router.hereapi.com/v8/routes?transportMode=pedestrian&return=summary,polyline,actions,instructions&origin=42.353514,-71.126775;42.365181,-71.102086&destination=42.360273,-71.091979&via=42.365181,-71.102086..
It's generating 2 legs ("section" in v8 definition) in the route. I'm expecting 1 leg.
This v8 developer guide page mentioned passThrough:
Waypoints may represent stopover points (that is, points where some time will be spent before retaking the route), or passthrough points that only influence the route's shape, but where no actual stop is carried out.
But I wasn't able to figure out how to query a route with multiple pass through points in v8.
Any advice?
Thanks!!
回答1:
I am not sure if returning 2 sections instead of one in V8 is an issue.
Regarding the passthrough point, it's described in API reference as WaypointOptions
for query parameter via
:
Supported waypoint options:
- stopDuration: desired duration for the stop, in seconds.
So I assume that all requests treat via
parameter without option stopDuration
as passthrough point. But you always can add !stopDuration=0
to be 100% sure.
This request (with stopDuration=0 or without this option) https://router.hereapi.com/v8/routes?transportMode=car&return=travelSummary,summary,polyline,actions&origin=42.353514,-71.126775&destination=42.360273,-71.091979&via=42.365181,-71.102086!stopDuration=0&apikey=YOUR_API_KEY
returns summary:
"summary": {
"duration": 714,
"length": 3893,
"baseDuration": 637
}
and this request with stopDuration=900 https://router.hereapi.com/v8/routes?transportMode=car&return=travelSummary,summary,polyline,actions&origin=42.353514,-71.126775&destination=42.360273,-71.091979&via=42.365181,-71.102086!stopDuration=900&apikey=YOUR_API_KEY
returns summary:
"summary": {
"duration": 714,
"length": 3893,
"baseDuration": 1537
}
As you can see baseDuration
was increased by 900 as requested.
回答2:
Alternative option to solve this type of problem you can sent the two request.
For example : A-->B B-->C You pass the request like this
First request A-->B
https://router.hereapi.com/v8/routes?transportMode=pedestrian&return=summary,polyline,actions,instructions&origin=42.353514,-71.126775;42.365181,-71.102086&destination=42.365181,-71.102086
Second request B-->C
https://router.hereapi.com/v8/routes?transportMode=pedestrian&return=summary,polyline,actions,instructions&origin=42.365181,-71.102086&destination=42.360273,-71.091979
enter code here
Now add the result of both, you will get the desired distance and time.
来源:https://stackoverflow.com/questions/61513987/here-routing-api-v8-how-to-get-route-with-multiple-pass-through-waypoints