[OSM-dev] Filtering by tags (was Re: OsmNote - system for keeping and sharing notes on your OSM surveying)

Dan Karran dan at karran.net
Sat Dec 2 22:20:47 GMT 2006

On 12/2/06, Christopher Schmidt <crschmidt at metacarta.com> wrote:
> On Sat, Dec 02, 2006 at 06:57:07PM +0100, Dan Karran wrote:
> > It wouldn't be too difficult (not sure how processor heavy this would
> > be, especially for large areas) to pull out all the nodes in a
> > bounding box, joined with the tags table where tag key = whatever...
> > Oh, I've just checked the schema and notice there isn't a nodes_tags
> > table like there is for ways. Are they stored in the tags field on the
> > current_nodes table?
> And therein lies the problem :) Tags are stored in a single field using
> something like:
>    foo=bar|||baz=quux

Ah, ok. I guess I should go off and read the Database schema wiki page  :)

Not meaning to troll, and sorry if I've missed this discussion in the
past, but is there a reason for keeping the nodes and segments tagging
system the way it is instead of upgrading it to work the way the ways
work? It seems like it'd give more flexibility and standardise on the
way tags are dealt with.

> There is no way to filter on specific tags in a SQL query, because the
> tags are all shoved into one field (unless something has changed
> recently). This is what makes the type of behavior you're seeking
> difficult in the current OSM database, and why changing the database to
> match would be a significant cost.

You could probably still do a WHERE tags LIKE 'something=%' to filter
them down, then maybe go further and split the tags down to their
constituent parts for proper checking before sending them out through
the API.


Dan Karran
dan at karran.net

More information about the dev mailing list