Speed limit for multiple locations using HERE API - here-api

I need to know the speed limit for some coordinates from the vehicle's trip.
If I do POST request like:
https://fleet.cit.api.here.com/2/calculateroute.json?routeMatch=1&mode=car&attributes=SPEED_LIMITS_FCn(*)&&app_id=APP_ID&app_code=APP_CODE
with body:
LATITUDE,LONGITUDE
37.401996,-122.041338
37.416438,-122.086022
I'm receiving back built route with very many coordinates.
But I'm interested in only two coordinates...
Is there a better way to get speed-limit for a few (~10-100) coordinates?

This will get an array of link and if speed limit is available in map data, it would be returned for the link. linkAttributes and routeAttributes will limit the response of parameters. the default response however can't be limited.
https://route.ls.hereapi.com/routing/7.2/calculateroute.json?apiKey=xxx&waypoint0=42.4065,-113.3798&waypoint1=42.2821,-83.74847&mode=fastest;car&inkAttributes=speedLimit,dynamicSpeedInfo&legAttributes=links
speedinfo can come via geocoder API in the form of speed category like below that will be based on the address location.
https://geocoder.ls.hereapi.com/6.2/geocode.json?searchtext=Castro%20St%20Mountain%20View%20Santa%20Clara%20US&gen=9&apiKey=xxxxx&locationattributes=li

Related

How many way points can I pass in the URL? Can I pass more than 100 way points?

I've been using HERE api to calculate the roughness profiles of the route. I need to pass more than 100 waypoints to get the IRI index. Is it possible to pass n number of waypoints or is there certain limit to it?
We only support GET method, POST will allow more, but it is not (yet) supported currently support whatever URL length limits allow.. So something like 100+ waypoints, but for optimising the route, there is a separate service which solves this is provided below.
https://developer.here.com/documentation/routing-waypoints/dev_guide/topics/quick-start-simple-car.html

Use Places API (Discover/Here) with Address instead of Lat/Long

I currently have a POC working that retrieves places information using the Places HERE api by passing Lat and Long values. Our addresses are being converted to lat and long before the api is called and we fear we might be losing precision in the process. Instead of feeding the API the coordinates, is there a way to send the actual address and get the address information back? Business name, type, etc?
res = requests.get('https://places.cit.api.here.com/places/v1/discover/here?app_id=<>&app_code=<>&at='+str(lat)+','+str(long))
Based on what I see in the API docs (https://developer.here.com/documentation/places/dev_guide/topics_api/resource-search.html) the answer is no. You can see more detail here as well: https://developer.here.com/documentation/places/dev_guide/topics/location-contexts.html. Is there a particular example of where you think geocoding is returning bad results?
Use Geocoder API to get coordinates for address and then use these coordinates to make a request to Places API.

Coordinates from Geocoding Autocomplete

We are integrating Here Autocomplete with our current typeahead feature. Currently this Autocomplete endpoint is not returning any coordinates, and to retrieve them, we must make an additional call to the Geocoding endpoint with the location id. Effectively doubling HERE calls for any one address.
Is there any way that the Autocomplete endpoint can include GPS coordinate?
To find the corresponding geocoordinates based on free-form input, send the following GET request.
https://geocoder.api.here.com/6.2/geocode.json?app_id={YOUR_APP_ID}
&app_code={YOUR_APP_CODE}
&searchtext=425+W+Randolph+Chicago
The response to the above request delivers the following high-level elements:
1) Metadata about the request
Results that match the request.
2) The number of results depends on the completeness of the address provided.

How to retreive speed limit from here maps given a latitude and longitude?

I'm trying to get speed limit from Here API maps but I can't find the way to do it. I tryed few example on web site but the only one that works is the one which require point of start and point of stop of the route.
I would like to get the speed limit given only one point ( or a box ). Which api do I have to use? Is there an example?
https://route.cit.api.here.com/routing/7.2/calculateroute.json?jsonAttributes=1&waypoint0=51.31854,9.51183&waypoint1=50.11208,8.68342&departure=2019-01-18T10:33:00&routeattributes=sh,lg&legattributes=li&linkattributes=nl,fc&mode=fastest;car;traffic:enabled&app_code=appcode&app_id=appid
This is the waypoint one but is not what I'm looking for, I would like to pass it only a Latitude / Longitude.
Thank you
You can achieve this by using PDE API(Platform Data Extension)
You have to first map your geocordinates(lat,long) to a navigable position(lat,long) for the given coord and the Functional Class(FC1-5) it is located in. This you can achieve by a simple geocoder request
You can calculate tilexy values based on the navigable lat,long and pass it to PDE API for querying speed limit layer on that particular FC class.
Look at https://tcs.ext.here.com/examples/v3/link_speed_locator example which covers this exact usecase.
Below is a sample geocoder request. Here prox parameter is your lat,long
https://reverse.geocoder.cit.api.here.com/6.2/reversegeocode.json?app_id=xxxx&app_code=yyyy&prox=50.133848, 8.715332,500&mode=retrieveAddresses&maxResults=1&additionaldata=SuppressStreetType,Unnamed&locationattributes=linkInfo
Below is a sample pde request
https://pde.cit.api.here.com/1/tiles.json?layers=SPEED_LIMITS_VAR_FC1,SPEED_LIMITS_VAR_FC2,SPEED_LIMITS_VAR_FC3,SPEED_LIMITS_VAR_FC4,SPEED_LIMITS_VAR_FC5,ROAD_GEOM_FC1,ROAD_GEOM_FC2,ROAD_GEOM_FC3,ROAD_GEOM_FC4,ROAD_GEOM_FC5&levels=9,10,11,12,13,9,10,11,12,13&tilexy=536,398,1073,797,2147,1594,4294,3188,8588,6377,536,398,1073,797,2147,1594,4294,3188,8588,6377&app_id=xxxx&app_code=yyyy
Read more about it in the developer site - https://developer.here.com/documentation/platform-data/topics/quick-start-view-map-data.html
Hope you find this useful!
The ReverseGeocoder has rarely used mode "trackPosition" (mode=trackPosition).
In combination with locationattributes=linkInfo you may retrieve the speed limit for that matching road.

Google Places API bounds in http request

Is it possible to limit the search area for Google Places in an http request? The website mentions bounds are possible (using SW and NE lat and long for the corners) for the javascript method but I would like to stick to the http request because I know nothing about javascript. Any help would be really appreciated because I am struggling with this. Thank you!
So, your http request should be something similar to this:
https://maps.googleapis.com/maps/api/place/nearbysearch/output?parameters
There are a required set of parameters, including the radius parameter (unless rankby=distance is set) that need to be used with the places api. The radius parameter is what you are looking for, the maximum allowed value is 50,000. The units are in meters, so the maximum distance would be 50km.
An example http api call would look something like this:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=AddYourOwnKeyHere
This will output the requested places of type 'food' within a 500m radius of a point in Sydney, Australia, containing the word 'harbour' in their name. The data will be returned in the Json format. You may be working with XML data instead of Json, if that's the case then just replace json with xml in the http request.
More information on using the Places API can be found Here.

Resources