[OSM-dev] Relations without members?

Brett Henderson brett at bretth.com
Thu Oct 11 14:30:07 BST 2007

Frederik Ramm wrote:
> 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.
Fortunately for me the java Area class seems pretty smart in this 
regard, I thought about wrapping it with a bounding box but it didn't 
seem necessary.
> 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.
That is pretty cool, not something that will be easy (or even possible) 
to do with osmosis.  Unless I use temp files, each task only gets one 
shot at reading data.  Re-reading nodes isn't simple to do.
>> 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... ;-)
That would be neat :-)  Again, not something osmosis will be able to do 
because I only have node ids at this point, I have no idea where they 
are from a coordinate perspective.
>> 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
>> area.
> 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 
> planet?
> I would advise against removing member from relations as this might 
> render them useless.
Makes sense.  It's easy for me to just leave them alone, it will just 
affect referential integrity ...

I'll have a crack at getting it working again, it will just have a few 
"known" issues around relations.  For now people will definitely be 
better off with your perl script.

More information about the dev mailing list