[OSM-dev] Hstore revolution

Jukka Rahkonen jukka.rahkonen at latuviitta.fi
Thu May 20 13:09:57 BST 2010

>> I tried to use the way you suggested with Mapserver run time
>> substitution system
>> but I was not able to resolve the correct way for quoting some
>> characters.
> try (tags @> '"amenity"=>"fire_station"'::hstore)
> if it does not work, please point out which chars did not work.


I managed to get the tags@> format to work in the layr definitions of
Mapserver mapfile. It does not look difficult when it is correct.

DATA "way from (select (way),osm_id,tags from osm_point where (tags @>
'amenity=>cafe')) as foo using unique osm_id using srid=2393"

Next I changed DATA so that it takes keys and values from variables %tag%
and %value% instead of hard coded strings.

DATA "way from (select (way),osm_id,tags from osm_point where (tags @>
'%tag%=>%value%')) as foo using unique osm_id using srid=2393"

And that's all.  Now I can make my new WMS layer "tags" to show me a map
about features having any tag=value combination simply by sending two
extra parameters with WMS GetMap request. This is a working example


It shows me all the cafes, while using &key=highway&value=traffic_signals
shows me all the traffig signals. Just wonderful.

Note that this does not necessarily work with GIS clients which respect
the WMS standard. They are taking the GetMap URL from the GetCapabilities
document and then the extra parameters get dropped out. A properly made
OSM-WMS service should perhaps rewrite the GetCapabilities document so
that these query parameters would be added to advertised GetMap URL.
However, many WMS clients do not bother to investigate the GetCapabilities
that well and they just use the same URL for GetCapabilities and GetMap.
Some clients like OpenJUMP and QGis from the trunk let users to select and
enjoy the OSM any-tag layers just by adding extra parameters into
connection string. Clients which are taking the GetMap url directly will
work out-of-the-box. JOSM and OpenLayers belong to these.

-Jukka Rahkonen-

More information about the dev mailing list