How to refer to only the first part of complex OpenStreetMap keys?

34 Views Asked by At

I have a PostgreSQL table with OSM data. In the hstore type tags column I have the key:value components of the tags. In some cases there is two or more part of the key like oneway:bicycle, or psv:lanes:forward, and only after that comes the value. How can I refer to only the first part of the key, so to all of the records that has keys that starts with oneway? Because if I try this:

SELECT * FROM m_temp.osm_road WHERE exist(tags,'oneway')

it only returns where nothing is following the key, but the value.

Now I realize that I could search these records with regular expressions such as:

SELECT * FROM m_temp.osm_road WHERE tags::text ~'oneway:'

But that's just a workaround and I cannot fetch the values with tags->'oneway:'

Is there any solution to this what I missed?

0

There are 0 best solutions below