I am trying to build a an android application that can determine the type of highway the user is on by latitude and longitude coordinates. Is there a way to query overpass turbo to retrieve the type or classification of highway ?(whether it is motorway, trunk, primary, secondary, tertiary or residential) I was not able to find any relevant tutorials or documentation to do so. Can I implement a query in a Java class method as described below:
LocationManager lm(LocationManager)getSystemService(Context.LOCATION_SERVICE); Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
@Override public void onLocationChanged(Location location)
{
double longitude = location.getLongitude();
double latitude = location.getLatitude();
/*query overpass turbo to classify highway*/
/*store retrieved classification type as a string*/
}
And instead of fetching all ways tagged as highways around the given coordinate, can the current position be identified as to whether the way is which type of highway?
You need to look for ways with a highway tag. You can use the following Overpass API query to locate all ways tagged as highway within 100 meters of 51.033,13.749 (lat, lon):
[out:xml][timeout:25];
way(around:100,51.033,13.749)[highway];
out body;
>;
out skel qt;
You can see the result on overpass turbo or download the results directly via Overpass API.
You can use the last link for building a simple HTTP request from within your application. Note that Overpass API supports different output formats such as XML and JSON, depending on your query.