0

I am making an app where I need access to the maxspeed in the OSM database. I found the api http://overpass-api.de/api/ in the OSM wiki http://wiki.openstreetmap.org/wiki/Overpass_API but I can't find a way to access it and when I search the api online it reaturns the Forbidden error.

How can I program my app to access the api so I can query the database json to find the maxspeed for my android app.

DJ. Aduvanchik
  • 332
  • 5
  • 17
  • http://stackoverflow.com/questions/8194233/open-street-maps-api-for-android – Anis LOUNIS aka AnixPasBesoin Jan 28 '17 at 23:36
  • @AnixPasBesoin, I already have libraries and imported it into my app. I need access to their database. The http address is the api according to the wikipedia page but when I click it, it gives me the access denied message. I don't understand why if it's supposed to be open sourse – DJ. Aduvanchik Jan 28 '17 at 23:42
  • 1
    There are several existing Android apps serving exactly the same purpose, as one example: https://github.com/plusCubed/velociraptor - I'd recommend to study the source code and come back with more specific questions. **Important point**: Overpass API has a usage policy which you have to adhere to. Also OSM API and Overpass API are two completely different APIs. – mmd Jan 29 '17 at 19:45
  • 1
    And of course, for testing your queries, I'm always recommending the excellent overpass turbo: https://overpass-turbo.eu – mmd Jan 29 '17 at 19:57
  • @mmd I actually downloaded the app a few weeks ago and analysed the code as thoroughly as I could and used what I learned in my app, but I couldn't find the address for the api used. I tried this from the overpass/osm wiki page, http://overpass-api.de/api/, but it prompts an `Access denied` screen. – DJ. Aduvanchik Jan 29 '17 at 19:59
  • 1
    The endpoint to use would be overpass-api.de/api/interpreter – mmd Jan 29 '17 at 21:01
  • Take a look at osmbonuspack, it provides functions for accessing Overpass API. – scai Feb 01 '17 at 10:29

1 Answers1

2

OSMBonusPack (an addon lib to osmdroid) has an OverpassAPIProvider, ready to use, without your "Forbidden" issue.

If it doesn't exactly fit your need, looking at the source code should help you to implement what you want.

EDIT

Using OverpassAPI may not be straightforward to get the "current" maxspeed ...

Following mmd suggestion, here is the piece of code from velociraptor to build their OverpassAPI request string:

private String getOsmQuery(Location location) {
    return "[out:json];" +
            "way(around:15,"
            + location.getLatitude() + ","
            + location.getLongitude() +
            ")" +
            "[\"highway\"];out body geom;";
}

This may help...

MKer
  • 3,430
  • 1
  • 13
  • 18
  • thank you for the Update. I actually went through most of the code in Velociraptor while building the app, and I used this piece of code, and I made a query and an HTTP get function, but the api never gave me the information I needed. Trying to get the right query from beginning to end. – DJ. Aduvanchik Feb 05 '17 at 00:20