[osmosis-dev] TagFilter
Andrew Byrd
andrew at fastmail.net
Mon Nov 23 17:34:03 GMT 2009
Brett Henderson wrote:
> I'm gonna take a back seat on this one :-) If you have some
> time to gather some requirements, tidy up the existing tasks,
> and add new features then go for it.
I put together a new filter using Peter's syntax suggestions. Putting
everything in one class actually seems to simplify things a bit. The
patch is here:
http://global_void.mailc.net/TagFilter.patch
I've tested it on several cases, but I imagine others use filtering in
very different ways, so please try it out and let me know if it meets
your needs, or if there are unexpected results.
Here's my example usage:
osmosis \
--read-xml input.osm \
--tf accept-ways highway=* \
--tf reject-ways highway=motorway,motorway_link \
--tf reject-relations \
--used-node \
--write-xml output.osm
This will keep only ways with tag highway=(anything), then throw away
those ways where tag highway is motorway or motorway_link. All relations
are discarded, then all nodes which are not in the ways are discarded.
The remaining entities are written out in XML.
Each filter operates only on the specified entity type, and within that
type accepts or rejects entities which match its tag parameters. If no
tag parameters are specified, the filter matches all tags. It passes
other entity types through without touching them.
Multiple values can be specified for one key, in a comma-separated list.
A tag value list of * (a single asterisk) matches any value.
> Yep, I was uncomfortable with the current tasks not supporting all
> characters.
I see no simple way of getting around a separator character, the equals
character, and the wildcard character. They are , = * respectively. They
can be included in keys or values using the following escape sequences:
@a *
@c ,
@e =
@s space
@@ literal '@' symbol
Actually, there are only limited circumstances where you absolutely need
to escape these characters.
= must be escaped in tag keys
, must be escaped in tag values
* only needs to be escaped for tag values that consist of a single *
@ and space must always be escaped
Let me know if you have any other comments or questions.
-Andrew
More information about the osmosis-dev
mailing list