Shing Ho Tan
Shing Ho Tan

Reputation: 951

Getting speed limit Advanced Datasets API(aka PDE) is not working well

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?

Upvotes: -1

Views: 250

Answers (2)

user3505695
user3505695

Reputation:

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

Upvotes: 0

astro.comma
astro.comma

Reputation: 181

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.

Upvotes: 1

Related Questions