-1

https://knowledge.here.com/csm_kb?id=public_kb_csm_details&number=KB0017817

I've referenced this doc for getting the speed limit but it's not working well in a specific location. I'm not sure if I'm doing right.

For latitude: 34.9531064, longitude: -82.4189515, I was able to get 33712897 for ReferenceId using this api. https://reverse.geocoder.ls.hereapi.com/6.2/reversegeocode.json?prox=34.97147,-104.89752&mode=retrieveAddresses&maxresults=1&apiKey={{YOUR_API_KEY}}&locationattributes=linkInfo

tile size = 180° / 2^level [degree] tileY = trunc((latitude + 90°) / tile size) tileX = trunc((longitude + 180°) / tile size)

And using this formula, I am able to get 277 for tileX and 355 for tileY in case the level is 9.

But after calling https://pde.api.here.com/1/tiles.json?layers=SPEED_LIMITS_FC1&levels=9&tilexy=213,355&app_id={{YOUR_APP_ID}}&app_code={{YOUR_APP_CODE}}&meta=1&callback=onLoadPDETiles, I cannot get 33712897 ReferenceId in the response. So the result is I cannot get speed limit of that specific location.

What did I do wrong?

Shing Ho Tan
  • 931
  • 11
  • 30

2 Answers2

1

The way you're constructing your last request will not work because you forgot to consider the Functional Class of the link. Because of this, the layers, level and tilexy parameters are not correct.

The linkInfo object in the Reverse Geocoding response indicates that link 33712897 has a Functional Class = 5, so you want to call layer SPEED_LIMITS_FC5 isntead of SPEED_LIMITS_FC1. Also, according to the documentation available here, you should be using level=13:

For road link based layers, the level is always "road functional class" + 8

This means that your calculated tiles will be 4441,5686, and your request will look like this:

https://pde.api.here.com/1/tiles.json?
layers=SPEED_LIMITS_FC5&
levels=13&
tilexy=4441,5686&
app_id={{YOUR_APP_ID}}&
app_code={{YOUR_APP_CODE}}&
meta=1

Now, this request will still return an empty result because the link you chose doesn't have a Speed Limit in the HERE map, but at least your request is properly structured now. For example, if you change your coordinates to 32.705470,-96.784640 for link 17748385 (tilexy=3787,5584) using the exact same request structure, you will get a non-empty result.

astro.comma
  • 181
  • 9
  • 34.959344,-82.440082 using this position, I was able to get the speed limit in OpenStreetMap. https://ibb.co/pvDM8B2 But I cannot get the correct answer. – Shing Ho Tan Dec 24 '21 at 03:30
  • With this position, I was able to get level 13 and tilex - 4440, tiley - 5687. And the url is https://pde.api.here.com/1/tiles.json?layers=SPEED_LIMITS_FC5&levels=13&tilexy=4440,5687&app_id=xxx&app_code=xxx&meta=1 – Shing Ho Tan Dec 24 '21 at 04:08
  • If you're trying to get the Speed Limit on South Main Street, then your query is wrong again. That road is a Functional Class 4, so the correct layer is SPEED_LIMITS_FC4, the correct level is 12, and tilexy is 2220,2843. – astro.comma Dec 24 '21 at 17:42
  • In the response, I'm getting 5 in the functionalClass. how do you know, the functional class is 4? – Shing Ho Tan Dec 24 '21 at 18:14
  • With you query for coordinates 34.959344,-82.440082 and limited to 1 result you are not getting any matches for "South Main Street"; only "Swamp Rabbit Trl" is returned. That's how you know that you're not getting the road you want, so you have to adjust your query. If you increase your results limit to 2 for example, you'll get a match for the road you're searching for, which is a Functional Class 4. – astro.comma Dec 26 '21 at 20:37
0

If you want to check speed limit using coordinates, we would suggest to use Route Matching instead. Take these steps:

  1. Compose a trace with coordinates, if for example you can compose it in csv format as below:

latitude,longitude

34.9531064,-82.4189515

  1. Encode it into base64 format, you will get:

bGF0aXR1ZGUsbG9uZ2l0dWRlCjM0Ljk1MzEwNjQsLTgyLjQxODk1MTU=

  1. Pass it to Route Matching API, such as:

https://m.fleet.ls.hereapi.com/2/matchroute.json?file=bGF0aXR1ZGUsbG9uZ2l0dWRlCjM0Ljk1MzEwNjQsLTgyLjQxODk1MTU=&attributes=SPEED_LIMITS_FCn(*)&apiKey=YOUR_API_KEY

Note attributes=SPEED_LIMITS_FCn(*) means to get all attributes of SPEED_LIMITS_FCn table, which means FC1-5.

enter image description here

Then you will notice you get nothing about speed limits because the location 34.9531064,-82.4189515 is located near a FC5 road which has no speed limits.

You can try a new location, such as 34.962142745546274,-82.4333132247333 which is on a highway, then you will get speed limits:

https://m.fleet.ls.hereapi.com/2/matchroute.json?file=bGF0aXR1ZGUsbG9uZ2l0dWRlCjM0Ljk2MjE0Mjc0NTU0NjI3NCwtODIuNDMzMzEzMjI0NzMzMw==&attributes=SPEED_LIMITS_FCn(*)&apiKey=YOUR_API_KEY

enter image description here