Hi First let me say that I am fairy new to OSM and the Overpass api. So forgive my ignorance ;) I'm working on a small private app where I want to get information about the road I am currently driving on. I am using the following query to get information about the road from the phones current location:
In the example above i get the way: "Midtjyske Motorvej" with ID=111435507 I am not sure if this is the best way to do it, but it seems to work quite good for now. Because I do not want to query Overpass every single second, but still want the information to be rather accurate, I thought about trying to make the app make an educated guess about where I'm heading, and then cache some of this information locally. So I want the app to query via the overpass API, and then find for example the next 10 adjacent ways (or the next x adjacent ways within a 2 KM radius) of the current way i'm driving on. If for instance I was driving south on the above road: "111435507", the immediate next adjacent way would be: "111435449", the next one would be: "111435478" etc. Is it possible to create one query that can get all the adjacent ways like this? I don't expect the API to handle direction/course, so I guess I will have to do that calculation my self, and figure out which end point of the way I want to start from - so to speak. But if it is possible, that would of course be great :) Thanx in advance! ...Allan asked 28 Sep '13, 21:13 as_dk |
Although it looks a bit weird this will give you the next 5 adjacent roads for way id 111435507.
Try it on Overpass Turbo Note that "around" has no concept of directly connected roads, so you will get some roads which are only crossing the motorway. You will have to manually filter those out in a post processing step. Edit: Global bbox added to restrict your search to the area you're interested in. Otherwise really long ways will cause some far away data to be fetched. answered 21 Apr '14, 11:50 mmd |
Silly question : the radius is one parameter in your current query (expressed in meters). Why simply not change this 'radius' from '5' to '2000' ? Then you will retrieve all highways within the circle. Then you will have to build a function retrieving the nearest highway from the current phone position (this will depend how you store the geodata in your app but they are plenty of geo-libs doing this for you). answered 30 Sep '13, 14:32 Pieren Thanks for the answer :) I have of course already tried that and it also works fine. But I really want the response data to be as minimal as possible and only return what I need in order to save bandwidth on the mobile device. With a radius of 2km I get about 200Kb at the location in the previous message. Upping that to 5km gives 1Mb – still semi ok I guess. But in a bigger city like (55.703956,12.518066) I get 1Mb of data for only 2 km and 7mb with 5 Km. A lot of data when I know I will only need a small part of that in the current request.
(01 Oct '13, 16:04)
as_dk
I really only want to get connecting (better word perhaps than adjacent ways I guess) ways, and nothing else. And preferably only ways at the endnodes, so I don’t get side roads etc. I’m sorry I did not make that clear in my question.
(01 Oct '13, 16:04)
as_dk
1
You can edit and improve your question at any time. I'm surprised by the size of the data. Perhaps the radius should vary with the speed. In urban and dense areas, the speed is necessarily smaller than in country side.
(01 Oct '13, 16:36)
Pieren
|