Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get speed limits from OpenStreetMap

I'm creating a mobile app that determines if someone if a good driver. The phone sits on the dashboard and collects GPS information while the user is driving. I need to determine a way if the driver is following the speed limit, and I would like to do this via OpenStreetMap. What is the best way to get speed limits from OpenStreetMap?

like image 578
user2233166 Avatar asked Apr 01 '13 18:04

user2233166


People also ask

How do I get data from OpenStreetMap?

Go to openstreetmap.org and zoom to the extent of your area of interest using the search box or the mouse. Click on Export Data in the sidebar on the left to bring up the Export pane. If you are satisfied with the visible extent, click Export. You will be prompted to save map.

Does OpenStreetMap have an API?

OpenStreetMap has an editing API for fetching and saving raw geodata from/to the OpenStreetMap database — this is the entry page for the documentation. If you just want to embed a map into a webpage, you don't want this API. Use a web map library instead.

How do I get POI from OpenStreetMap?

There are two ways you can get this data out of the OSM database. One is by using Overpass, a separate API with a powerful query language which allows you to fetch data matching certain tags. The second is to download the OpenStreetMap data dump and filter it according to your needs.

How do I get OpenStreetMap API?

The Openstreetmap API endpoint is located at http://api.openstreetmap.org/. You can find the Openstreetmap API portal / hompage here. If you need Openstreetmap API support, you can visit developer support here, or reach out to their Twitter account at @OpenStreetMap.


1 Answers

You can make a Web request to get your answer.
Here is one (try it as a browser URL) of a small box where you're supposed to be:

www.overpass-api.de/api/xapi?*[maxspeed=*][bbox=5.6283473,50.5348043,5.6285261,50.534884]

and the answer showing the street passing through it, in front of a school:

<node id="1312239864" lat="50.5348877" lon="5.6286790">
  <tag k="highway" v="crossing"/>
  <tag k="traffic_calming" v="bump"/>
</node>
<node id="2025084665" lat="50.5345623" lon="5.6274183">
  <tag k="traffic_calming" v="choker"/>
</node>
...
<way id="191950462">
  <nd ref="2025084669"/>
...
  <tag k="bicycle" v="yes"/>
  <tag k="highway" v="secondary"/>
  <tag k="maxspeed" v="30"/>
  <tag k="name" v="Rue d'Esneux"/>
  <tag k="source:maxspeed" v="school zone"/>
</way>

I only left the interesting stuff in, most self explanatory. For example, traffic calming features on their own node.
The street is the way made of the nodes and of its own tags.
maxspeed=30 is your answer. Should there be no maxspeed, the default applies for highway=secondary (or =motorway ...)
All the tags are described at wiki.openstreetmap.org
That's using xapi. You may also use the overpass api.
Speed limit coverage is partial but you may improve it. Leave Notes on the main map to provide the data.

like image 107
Papou Avatar answered Oct 02 '22 22:10

Papou