Using Maxspeed information for own position

Hello!
I am a new user of OpenStreetMap and I found a very interesting map, containing the maximum allowed speed on streets, see here: http://wince.dentro.info/koord/osm/KosmosMap.htm

A already had a look to the xml code of a small region around Braunschweig (Germany).

I would like to use the maxspeed information of OpenStreetMap for a small own application.
I make some experiments concidering driver behaviour. Therefore I have a special equipped vehicle. GPS position is one of the data sets that I measure. To evaluate the data I have to know the speed limit on the highway on my recent position.

Is it possible to read my GPS data records, compare the position in my data records with OpenStreetMap database, taking the nearest highway in consideration and read the maximum allowed speed for this highway and then write this information back to a simple txt file? (I do not need this information in real time. I want to evaluate the information after the test drive.)

This should be like this (I record gps position every second):
My old GPS file:
time, recorded gps-positon
time+1sec, recorded next gps-positon
time+2sec, recorded next gps-position

The file I want to get:
time, recorded gps-positon, max. allowed speed at this section of the street
time+1sec, recorded next gps-positon, max. allowed speed at this section of the street
time+2sec, recorded next gps-position, max. allowed speed at this section of the street

I didn’t understand how to get this information from the database. In a first step I tried to use osmxapi (like mentioned here: http://wiki.openstreetmap.org/wiki/DE:MaxSpeed_Karte)) only for one position of my gps data, but osmxapi found no information about this position.

Thanks a lot,
Stefan

Hi,

That should not be very difficult if you first import OSM data into PostGIS database. Osm2pgsql is the tool for that, but you need to edit the configuration file so that maxspeed tags are also imported. After that you should query the database like

SELECT * FROM osm_line
WHERE highway is not null
ORDER BY
Distance(way,PointFromText(‘POINT(517651 2121421)’)) LIMIT 1

The query returns from the osm_line table one object that has some highway tag and that is closest to the POINT given in the query. Mayby you would like enhance the query and exclude cycleways and footways?
POINT should be your location, and naturally the coordinates must be in the same projection that was used while importing the data. With GPS usage it would be best to import the data in EPSG:4326 projection.