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.
- Get new position
- If speed is > 0, call overpass API and get speedlimit for lat,lon
- 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" } } ] }
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.
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" } } ] }