[Geoserver-users] Geoserver support for Open street map

Note: forwarded message attached.


Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.

Here are the notes I made as I went along last week importing the OSM
data in postgis and geoserver.

First import Open Street Map data from latest Planet_osm file

./osm2pgsql --bbox
-127.61950064999999,23.7351786,-64.08177035,50.592523400000005 -l -d
gis ../planet-latest.osm.bz2 (just grabbing the USA for now)

This builds four tables in PostGIS on apps planet_osm_line,
planet_osm_point, planet_osm_polygon and planet_osm_roads

Roads looked like an obvious place to start but for some reason didn't
include residential and tertiary roads, so I switched to using
planet_osm_line instead. I built a basic style file and imported the
data into GeoServer. This showed up some basic problems with the data
- most obvious was that for some reason when importing the Tiger data
OSM had chosen to code A63 (Access Road) to motorway_link ( tiger to
osm codes) - this leaves small blue dots all over the map when zoomed
out and looks really odd when zoomed in. To fix this I ran the
following query in PostGIS to determine what sort of roads touched
these access roads:

select distinct l1.highway from planet_osm_line as l1,planet_osm_line
as l2 where
l2.highway='motorway_link' and st_touches(l1.way,l2.way)

and then repeatedly ran the following update for each type found in
descending order of importance: i.e.
motorway,trunk,primary,secondary...

update only planet_osm_line as l2 set highway='trunk' from
planet_osm_line as l1 where
l2.highway='motorway_link' and l1.highway = 'trunk' and
st_touches(l1.way,l2.way)

Each of these queries had to be run multiple times to allow for
recusive touches to propagate.

It might be worth using CREATE TABLE AS to make copies of the data in
smaller tables for just roads etc.

create table roads as select * from planet_osm_line where highway is not null

add to Geometry_columns

Fix types as there are currently one hundred different types - highwaytypes.csv

so run things like

update roads set highway = 'residential' where highway ~* '^.?resid*'

You can see the finished results at
http://www.apps.geovista.psu.edu/geoserver163/wms?bbox=-130.29868211000002,23.242685175000002,-60.92867349000001,51.894599125&styles=&Format=application/openlayers&request=GetMap&version=1.1.1&layers=topp:roads&width=800&height=310&srs=EPSG:4326

when I finish fixing up the SLD file to get the road casing right
(thanks Andreas for pointing out my error) I'll post it and these
notes to the wiki.

Ian

--

Ian Turton
http://www.geotools.org
http://pennspace.blogspot.com/