Find highway near waypoint - here-api

I would like to find the nearest highway (latitude and longitude) of a given position using 'rest'? Is this possible?
The idea is that the user can enter (select) a 'passthrough' waypoint for a route. If the route is from Belgium to France the waypoint would be in Luxemburg to avoid the toll on the French highways. However, the route should use the highways around the waypoint (if possible) instead of passing through the exact coordinate.
I already tried to set the 'TransitRadius' to 5000, but the route is still calculated on the exact waypoint.
This is my complete call:
In the image, I displayed the route around the waypoint. The thin red line is the proposed route passing at the waypoint (gray marker), the thick blue line is the route that I want (without detour).
Map image
Thx in advance

Please check output for the below rest call,
toll cost 18.2 EUR, travelTime 17:24 h, distance 942 km
http://fleet.api.here.com/2/calculateroute.json?app_id=xxxxx&app_code=xxxxxx&waypoint0=50.86892,2.88533&waypoint1=passThrough!49.6096,6.1034;5000&waypoint2=stopOver!45.7896,4.8656&detail=1&legattributes=none,li,sm&currency=EUR&tollVehicleType=3&trailerType=2&trailersCount=1&vehicleNumberAxles=2&trailerNumberAxles=3&hybrid=0&emissionType=6&height=4.0m&trailerHeight=4.0m&vehicleWeight=9.5t&limitedWeight=40.0t&heightAbove1stAxle=3.5m&passengersCount=1&tiresCount=12&commercial=1&disabledEquipped=0&minimalPollution=0&width=2.2&length=18&mode=fastest;truck;traffic:disabled&rollups=none,country;tollsys,country,tollsys,total&alternatives=0&metricsystem=metric&transportmodetype=truck&driver_cost=30
please refer fleet telematics API for more information :
developer.here.com/documentation/fleet-telematics/api-reference.html

Related

Here Fleet Telematics (CalculaterouteAPI) response error

Here Fleet Telematics API - Response Error
Trying to use calculateroute api for the request:
https://fleet.ls.hereapi.com/2/calculateroute.json?apikey=&mode=fastest;truck;traffic:disabled&length=100&height=100&capacity=100&departure=2022-06-17T08:35:58&waypoint0=-34.93522,138.53637&waypoint1=-34.92585,138.5998;opening:2022-06-17T08:35:58;closing:2022-06-17T17:00:00;sort&waypoint2=-34.94613,138.58924;opening:2022-06-17T13:35:37;closing:2022-06-17T17:00:00;sort&waypoint3=-34.86227,138.58331;opening:2022-06-17T14:06:18;closing:2022-06-17T17:00:00;sort&waypoint4=-34.93522,138.53637
But got the bellow error:
"Couldn't reach way point 4 (start links -777941868 777941868 dest links -777941868 777941868 ), closest link to destination reached: -777941868 at -34.93523/138.53602"
Regarding the response HereAPI - Can't reach waypoints requested, I used &ignoreWaypointVehicleRestriction=100000 and &traverseGates=true but got the same error and Here is unable to calculate it.
Is there any solution for getting result without error?
we have a parameter called "proximity" you can check in our API Reference in the documentation, this parameter is a circular search area specified by center latitude, longitude [WGS84 degrees], and radius [meter].
All geometries overlapping this circle will be returned, sorted by distance, closest first. Example: proximity=47.731,7.5549,100 Multiple coordinate pairs can be passed as a semicolon-separated list. For each of them, the layer_ids list is searched. If each coordinate pair is explored in a different set of layers, layer_ids contains a semicolon-separated list of (comma-separated list of) layers.
This parameter will do the trick.
https://developer.here.com/documentation/fleet-telematics/api-reference.html

Routing with avoid area and geofence / polygon

I want to avoid specific streets when using the routing API. I have data points to create a geofence or polygon to represent those specific streets.
The router API accepts only up to 20 bounding boxes. I tried to send 20 avoid area bounding boxes to represent the road, but the result is not reliable (e.g. on diagonal roads).
Is there a way to send a geofence/polygon instead of bounding boxes?
Or any other way to avoid certain streets?
Thank you very much
Please try to use avoid[segments] instead of avoid[areas] for avoiding specific roads. In the case of having too many roads to avoid, you can also put the avoid[segments] parameters into request body and send a POST request to the same endpoint.
In order to get the segmentId of the roads you would like to avoid, you can do a normal routing call with parameter spans=segmentId added and then look at the topologySegmentId attributes in spans section of the response.
https://developer.here.com/documentation/routing-api/api-reference-swagger.html
HERE Routing API now supports polygons for avoid area, https://www.here.com/learn/blog/routing-supports-polygons-for-avoid-areas
You have to make below calls for your usecase.
1>Rest call to get segmentId For the route.
https://router.hereapi.com/v8/routes? apikey={your_app_id}& origin=32.834496,74.81515& destination=32.811632,75.816037& return=polyline,summary,actions,instructions& spans=segmentId& transportMode=car&
2>Rest Call to get the get Route with avoid[segments]
https://router.hereapi.com/v8/routes? apikey={your_app_id}& origin=32.834496,74.81515& destination=32.811632,74.816037& return=polyline,summary,actions,instructions& spans=segmentId& transportMode=car& avoid[segments]=here:cm:segment:808368834,here:cm:segment:808095972

HERE API: How to check does (lat, lon) belong to intersection or no?

I have GPS coordinates and want to check if it's an intersection.
I'm using POST request to "https://fleet.api.here.com/2/calculateroute.json" with payload:
LATITUDE,LONGITUDE
37.775210, -122.419203
And I'm getting back response with
"INTERSECTION_CATEGORY": "0" - means "NOTAPPLICABLE".
But this point corresponds to a very big intersection in San Fransico.
Please see google-map
I checked many other points with the same result. So how can I check if it is an intersection or no?
The "INTERSECTION_CATEGORY" attribute of "LINK_ATTRIBUTE" layer is using for very specific intersections. For normally intersections the "INTERSECTION_CATEGORY" is null that means no applicable.
You can recognize if a link has intersections utilize "LINK" layer by checking attributes "REF_NODE_NEIGHBOR_LINKS"/"NON_REF_NODE_NEIGHBOR_LINKS" if one from these attributes has more than one link then it belongs to intersection, see please example for the link 576441292 on https://tcs.ext.here.com/examples/v3/pde_get_any_link_info and see please screenshot for it
Another one example to find intersections you can see on https://tcs.ext.here.com/examples/v3/find_intersection_along_route

Get shape of route link

Is there a possibility to get a shape, either polyline or coordinates, of route link by it's id using HERE API? I am calculating a road using calculate route endpoint by passing few avoid link's which I would like to show on the map. How can I achieve that? I was able to get tileX and tileY for each link using https://pde.cit.api.here.com/1/index.json but when I convert it to coordinates(per documentation) it gives me inaccurate results.
if you are using REST API, you can get shape with a request like this:
http://route.api.here.com/routing/7.2/calculateroute.json?
app_id=XXXX
&app_code=YYYYY
&mode=fastest;car
&routeattributes=shape
&waypoint0=48.98381310475713,2.5028838962316513
&waypoint1=48.83000339882299,2.2315230274810745

Google Maps API Alternative Route Description

I am working with Google Maps API V3 to calculate all the possible routes from a given Source to the specified Destination. For this I takes the Destination and Source as inputs from the user and pass these values in the request with option provideRouteAlternatives: true. I am successful in calculating different Routes and also marking i.e. displaying them on my Map.
Now I am wondering if it is possible to name the Different Routes. By naming the Routes I mean adding a small description to each Route like the Street Name etc. which that particular route takes while moving from Source to Destination. I want to do this so as to make it look more interactive. For example if there are 3 Routes possible from location A (Arizona Street, San Diego, CA, USA) to location B (Fenton Parkway, San Diego, CA 92108, USA) then instead of showing results like Route 1, Route 2, Route 3 it should show the Street names like "Texas St & Rio San Diego Dr", "Texas St & Friar Rd", "Friars Rd".
I am able to calculate all the other things like the trip distance and total trip time for each of my Route but have no clue to how to add this description to each of my Route.
Any help will be appreciated.
Thanks
That is what appears in the panel if you provide one:
Suggested routes:
Texas St and Rio San Diego Dr 2.6 mi - about 9 mins
Texas St and Friars Rd 3.3 mi - about 10 mins
Friars Rd 4.8 mi - about 11 mins
example
Try using summary from the returned result. From the Google Maps API:
summary contains a short textual description for the route, suitable for naming and disambiguating the route from alternatives.

Resources