enes

Enes Altınkaya

1 - Setup Openstreetmap for Maxspeed Query

1 - Setup Openstreetmap for Maxspeed Query
DRAFT

In this series, I will share my findings about installing Openstreetmap data on a local server.

Specifically for querying maxspeed data. But of course you can import any type of data you want and query those.

We will use latitude and longitude as input.

For example, if we wanted to find out the maxspeed allowed for a road closest to coordinates 51.4526, -2.5685 we would use the following postgres query.

SELECT 
  maxspeed, name,
  ST_AsText(ST_Transform(way,4326)) as coordinates,
  Ceil(ST_Distance(point.geom,way)) as distance
FROM 
  planet_osm_line,
  (select ST_Transform(ST_SetSRID(ST_Point(-2.5685, 51.4526), 4326),3857) as geom) point
WHERE
  maxspeed is not null and
  name is not null and
  ST_DWithin(point.geom, way, 1000)
ORDER BY distance
LIMIT 10;

And the output;

osm maxspeed query result

After setting it all up, we will wrap this query in a webservice.
I will be using Java - Spring, but you can use your favorite backend language.

Share on