[OSM-dev] Playing with MapServer WMS and WFS

Jukka Rahkonen jukka.rahkonen at latuviitta.fi
Sat Sep 11 07:26:52 BST 2010

Sven Geggus wrote:
> Jukka Rahkonen <jukka.rahkonen at latuviitta.fi> wrote:
>> My source data is Finland.osm file imported into PostGIS with -k option
>> for getting all the tags. Sea and borders layers are from Vmap0. Images
>> are rendered on-demand, and data can be selected by editing the &tag=
>> and
>> &value parameters.
> Nice! The only thing which should be solved for POI Maps is with polygon
> POIs. Usually we want to get them as points as well. In brewpub map I do
> this using ST_PointOnSurface.
> Probably this can be added to your mapfile using the UNION Operator in
> SQL.

You are rigth. This query does combine point POIs and polygon POIs into
one single point layer which can be used as input for Mapserver WMS and

select way,tags from (select (way),osm_id,tags from osm_point UNION ALL
select ST_PointOnSurface(way),osm_id,tags from osm_polygon) as foo;

UNION ALL was needed because else:
ERROR:  could not identify an ordering operator for type hstore
HINT:  Use an explicit ordering operator or modify the query.

Pretty easy and in theory it works immediately after osm2pgsql import
without any other preprocessing. However, I did not put it into mapfile
because rendering fails after ST_PointOnSurface failing first with some
NOTICE:  TopologyException: found non-noded intersection between
LINESTRING (8569.5 4234.62, 8623.96 4373.11) and LINESTRING (8637.48
4400.77, 8610.45 4345.45)at 8623.96 4373.1

Obviously topology errors in imported osm_polygon table should be
corrected first if somebody wants to use this system. I can imagine a very
commonly needed use case: address data could be downloaded in vector
format through WFS so that the output is just points, even in the source
data part of the addresses are given for buildings.


More information about the dev mailing list