This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

How can I match a key containing a colon in an OSMLib stylesheet?

0

I was using the OSMLib osmexport function to produce KML maps of ski areas, when I discovered a problem. The oxr style file doesn't like tags with a semicolon in it it seems and it won't take the tag like this either: 'piste:downhill'

My style file is at: http://www.skimap.org/files/kml-openskimap.oxr And sample data at: http://www.skimap.org/data/28/osm/xml/2011-01-31.osm

Any suggestions? Thanks!

This question is marked "community wiki".

asked 01 Feb '11, 02:00

wbski's gravatar image

wbski
1466914
accept rate: 50%

edited 01 Feb '11, 22:34

TomH's gravatar image

TomH ♦♦
3.3k83943


One Answer:

2

If the tag key is not a valid Ruby word, i.e. if it contains other characters than alpahnumerics and the underscore, you‘ll have to use the following syntax:

  # EDIT: changed "nodes do" to "ways do"
  ways do
    if tags['piste:type']
      ...
    end
  end

This is copy paste from osmlib rules documentation for exports, I use Osmium (also from Jochen) so I can't really tell you if you are doing stuff the right way, for the record osmium isn't at all suited for what you want to do.

answered 01 Feb '11, 08:30

emj's gravatar image

emj
2.0k123547
accept rate: 15%

edited 02 Feb '11, 09:32

But what if I want to select ways where piste:type=downhill? Your syntax only checks for the existence of the key, not the key value pair. Any idea how to do this?

(01 Feb '11, 23:11) wbski
1

I would guess you would do "tags['piste:type'] == 'emjpipe'" and I believe you have to iterate ways on their own just change nodes to ways in that code.

(02 Feb '11, 09:27) emj

Source code available on GitHub .