Implement Overpass API for Road Speed Limits

roneskinder4 years ago

I have a separate server running a custom Overpass API service in which i send it lat,lon and receive the Road Speed Limit "maxspeed": "40 mph", for that position. I want to save this value as a new column in tc_positions.speedlimit for every position we receive where the speed is > 0.

My question is, what is the best way to implement this inside tracker-server.java, can you give me an idea on how to start? i will figure out the rest.

  1. Get new position
  2. If speed is > 0, call overpass API and get speedlimit for lat,lon
  3. Save position including new column "speedlimit"

I currently have a daemon, looping through table tc_positions, looking for "speedlimit"=null in batches of 100 rows, and calling the API to get the value, but this is not the proper way to do it, since can lock the table tc_positions for all the updates. I want a better way directly inside java.

Thanks in advance for any advise guys,

Example in overpass server: curl --location --request GET 'http://overpass-api.de/api/interpreter?data=[out:json];way[maxspeed](around:100.0,34.854317,%20-82.241088);out%20tags;'
Response:
{ "version": 0.6, "generator": "Overpass API 0.7.56.3 eb200aeb", "osm3s": { "timestamp_osm_base": "2020-08-10T16:25:02Z", "copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL." }, "elements": [ { "type": "way", "id": 749350378, "tags": { "alt_name": "County Road 492", "highway": "tertiary", "lanes": "5", "lanes:backward": "2", "lanes:both_ways": "1", "lanes:forward": "2", "maxspeed": "40 mph", "name": "Pelham Road", "surface": "asphalt", "tiger:cfcc": "A41", "tiger:county": "Greenville, SC", "tiger:name_base": "Pelham", "tiger:name_base_1": "County Road 492", "tiger:name_type": "Rd", "tiger:zip_left": "29615", "tiger:zip_right": "29615" } } ] }

Anton Tananaev4 years ago

You can probably implement it similar to reverse geocoding.

roneskinder4 years ago

Great idea! Can you walk me through the steps for this?

Anton Tananaev4 years ago

I thought you just need an idea and you'll figure out the rest.

roneskinder4 years ago

I will give it a try, thanks Anton

Dibbs4 years ago

@roneskinder - are you able to share any details on your custom Overpass API server? It's something I'm interested in.

Thanks

roneskinder4 years ago

Hi Dibbs, i followed this tutorial on how to set it up

Dibbs4 years ago

Thanks for the reply.

If you don't mind me asking:

  1. Did you restrict yours to a region\country or go all planet?
  2. What kind of spec server did you end up using?

Thanks