[OSM-dev] Relations without members?
frederik at remote.org
Thu Oct 11 14:17:40 BST 2007
> I am curious how filtering should work with the new data model though,
> ideally I should use the same mechanism as the perl scripts. Note
> osmosis uses most of the same code for polygon filtering and bounding
> box filtering, the only difference is the logic deciding whether a
> lies within an area.
The polygon excerpt script does the same. If you run it on a polygon,
a bounding box is first computed and every node is first filtered
against the bounding box before the polygon test is made, because
when I designed that script I was using a 5,000+ node border polygon
which made for slow "is-in-polygon" testing. If you run it on just a
bonding box, then the polygon part is simply skipped and the bounding
box defined by the user.
In the most primitive mode of operation the script will not care for
referential integrity and might output ways for which not all nodes
are present. But you can force it (with -r) to re-read the nodes
afterwards, adding all those that are required to make the ways
complete. The code is engineered to allow one to easily extend that
to as many levels as you like, i.e. you could also have it re-scan
the ways, add any that have been used by relations, and then re-scan
the nodes to again add any required by these ways, and so on. You can
even operate it in a mode where it does not require ordered input but
it is moch slower then.
> Ways are selected if one or more of its nodes are in the bitset. The
> way is modified to only include nodes that are inside the area. The
> selected way ids are added to a bitset.
This is something that the extract-polygon script cannot do - it
either gives you the full way or no way. I would actually like to
implement that functionality, plus an extra hardcore function that
will not only drop some nodes off the way, but insert one border node
exactly where the way intersects with the bounding box... ;-)
> Relations are trickier, obviously they are selected if one or more of
> its members are already in the node bitset or way bitset. And I can
> modify the relations to only include nodes and ways that are inside
The perl script makes no attempt at modifying relations, In primitive
mode, the perl script will simply give you the relations of which at
least one member has been selected before; in referential integrity
mode, it should give you the nodes and ways referenced by a relation
as well. It does not recurse into relations, although this could be
enabled in the code. I haven't yet found a good way for cutting off
though - when giving out extra relations, should I also select their
way/node type members, or will I then quickly accumulate the whole
I would advise against removing member from relations as this might
render them useless.
Frederik Ramm ## eMail frederik at remote.org ## N49°00.09' E008°23.33'
More information about the dev