I want to avoid the motorway road when calculate the route between the start and destination
https://router.hereapi.com/v8/routes?transportMode=car&motorway:-1&origin=52.120066,11.570918&destination=52.282376,6.687846&return=travelsummary,polyline&apikey=<key>
But above query doesn't work, it not avoid the motorway
Refer documents:https://developer.here.com/documentation/routing/dev_guide/topics/resource-param-type-routing-mode.html
And I already check their is possibility of the route, to avoid the motorway.
https://www.google.com/maps/dir/'52.120066,11.570918'/'52.282376,6.687846'/#52.3407684,7.9868359,8z/data=!3m1!4b1!4m12!4m11!1m3!2m2!1d11.570918!2d52.120066!1m3!2m2!1d6.687846!2d52.282376!2m1!1b1!3e0
As per the Routing v8 documentation the proper parameter to avoid all highways is avoid[features]=controlledAccessHighway instead of motorway:-1
https://router.hereapi.com/v8/routes?transportMode=car&avoid[features]=controlledAccessHighway&origin=52.120066,11.570918&destination=52.282376,6.687846&return=travelsummary,polyline&apikey=..
Note: probably better value to use is tollRoad as it allows highways without tolls (e.g. in Germany)
Related
Problem: I want to tell if the access road to an US address includes dirt or paved road(like if it is in a remote area without proper road). If it is a dirty road we charge more to the customer for delivery.
In technical terms - The input is going to be a house address and I need to find out if the way to it involves dirt road.
I am ok with making multiple calls to get the complete information. What steps do I need to take?
In general, you will probably need two steps:
Use HERE Routing API to calculate the route between the two locations. It will return the path information.
Get the road attribute from one of the following content sources, such as Map Attribute API, Road Physical Attributes in HERE Map Content.
I'm trying to get a route that avoids a specific section of a road using Here routing API. I tried passing in a rectangle area to avoid the road like avoid[areas]=bbox:13.082,52.416,13.628,52.62. The problem is that the road I'm trying to avoid is diagonal. Using a rectangle to define the coordinates of the beginning and end of the diagonal road ends up causing nearby roads to be avoided. What would help me is if I could avoid an area in the shape of a polygon. Is there a better way to get directions that avoid a road?
You can use the avoid[segments] parameter to indicate that you want to avoid a specific section of the road. Here's an example request including this parameter:
https://router.hereapi.com/v8/routes?
apikey=*******&
origin=52.508900,13.388871&
destination=52.512990,13.390536&
return=polyline,summary,actions,instructions&
transportMode=car&
avoid[segments]=here:cm:segment:88390186
The easiest way to find out what's the Segment ID for the section of the road you want to avoid is by calculating a route where both the origin and destination are set to the coordinates of that section, and request the segmentId attribute in the spans parameter:
https://router.hereapi.com/v8/routes?
apikey=*******&
origin=52.51143775483142,13.386767963569321&
destination=52.51143775483142,13.386767963569321&
return=polyline&
spans=segmentId&
transportMode=car
I'm currently trying to use the the calculateroute endpoint to avoid certain roads that I specify.
It accepts avoidLinks parameter in which a list LinkIdTypes can be specified which determines the network links to be avoided when calculating the route.
What I'm having trouble finding is how do I get those LinkIdTypes, does Here provide an endpoint to query them (specifiying lat & lng)? or perhaps an endpoint I can use to define my own which then gives me a LinkIdType which I can reuse for future calls?
tl;dr: Where do I get LinkIdTypes for a specific road?
Addendum: I am aware of avoidAreas but this seems too cumbersome to use since I have to specify a bounding box instead of a road segment.
you can get linkId by doing a reverse geocode of a lat,lng.
Exemple of reverse geocode .
LinkId is available in the field ReferenceId.
You can also get the list of linkId of your route with calculateroute using legAttributes=links.
Exemple of calculate route
can anyone write how to avoid unpaved roads in Here routing (or truck routing) in REST API? I have checked API and I couldn't find answer. Routing API routes cars or trucks via dirty roads, what is unaccepted.
RouteFeatureType:The routing features can be used to define special conditions on the calculated route. The user can weight each feature with non-positive weights.
Possible paramers are: tollroad, motorway, boatFerry, railFerry, tunnel, dirtRoad,
park.
The Feature weights are used to define weighted conditions on special route features like tollroad,
motorways, etc.
-3 strictExclude The routing engine guarantees that the route does not contain strictly
excluded features. If the condition cannot be fulfilled no route is returned.
-2 softExclude The routing engine does not consider links containing the corresponding
feature. If no route can be found because of these limitations the condition is weakened.
-1 avoid The routing engine assigns penalties for links containing the corresponding
feature.
0 normal The routing engine does not alter the ranking of links containing the
corresponding feature.
Of course does the map content play also a huge role here. It is needed for the routing that the attribution e.g. for a dirt road (unpaved road segment) is set correctly.
You can also check details and report issues here: https://mapcreator.here.com
I am trying to get the distance traveled on a transit route -- particularly San Francisco MUNI, but the standards NextBus, GTFS, and Google Maps API appear to be universal. I'm comfortable using any of these APIs, I'm just not sure how to go about this problem.
The easy way - ask Google Maps (this using webservices, but there is also the javascript API):
http://maps.googleapis.com/maps/api/directions/json?origin=37.7954199,-122.397&destination=37.7873299,-122.44691&sensor=false&mode=transit&departure_time=1348109609&alternatives=true
this JSON includes distance traveled, but there are two issues:
Google does not allow you to use this data unless you're displaying a map, which I don't want to do
I would need to ensure that the distance returned is for the correct route/line, since it can/will give multiple routing options. This is probably doable but would require more logic.
EDIT: using alternatives=true (or provideRouteAlternatives: true using the javascript API) only returns a maximum of 3 routes, which here in SF often doesn't include the route I'm looking for (other transit agencies, multiple lines on the same route, etc). So this isn't such a great option.
NextBus:
example route config:
http://webservices.nextbus.com/service/publicXMLFeed?command=routeConfig&a=sf-muni&r=1
The coordinates for each stop are given, but connecting the dots on those is not the same as the route taken -- it will cut corners, etc, and I need this to be accurate. The actual route taken is given under <path>/<point>, but I don't see any obvious correlation between stop and path coordinates. Plus, NextBus says in their documentation (p.10 near the bottom) that you should NOT connect points between <path> segments, they're only meant for drawing on a map and can overlap.
GTFS:
The GTFS data also separates stop and "shape" coordinates (like NextBus paths). Unfortunately, the coordinates are slightly different for the same stops between NextBus and GTFS (rounding), though the stop ID/tags are the same. Also, the data files are in the megabytes, and I need to use this for a mobile app. I suppose I could put all the data in a database and query that, but that still leaves figuring out how to correlate the stops with the shape. The "shapes_distance_traveled" column in the shapes.txt file is especially promising. MUNI chooses to leave the optional "shapes_distance_traveled" field out of stop_times.txt, though.
Any advice would be appreciated, I understand this seems like an epic task to get a simple value. Maybe I'll just throw a map in to legitimately use the distance :)
Instead of using Google Maps, I would look into the un-encumbered licensing of OpenStreetMap. There are multiple
routing engines that can use OSM data. Personally, I would use routing in PostGIS or SQLite, but depending on your skillset you might choose another.
You've clearly done your research, (+1), and as you said, the easy way is to ask Google. If it is worth for you then you might want to look into purchasing a business licence to use the Google Maps API, and negotiate with them about the requirement of displaying a map. That's the only legal way I can think of with the Google API. Alternatively, you can try building you own routing engine with data from the TIGER data set, which is freely available from the US Census Bureau, but again, as you said, it may seem like an epic task. :-)