[Imports] Sorting changes

andrzej zaborowski balrogg at gmail.com
Thu Oct 15 20:02:07 BST 2009


Hi,
the other day I talked to Richard Weait on irc about upload utilities
and we thought it would be nice for big uploads, which need to be
split anyway, to be split "logically", so that the changes appear in a
similar order to how a human editor would draw them.  This little
script doesn't exactly achieve this but does the trick for me:
http://www.openstreetmap.pl/balrog/bulkupload/smarter-sort.py

A number of times I had a situation where my upload script first
uploaded all the payload of new nodes, and then before I finished
uploading ways, a human editor saw unused, untagged nodes and started
deleting them causing conflicts, so now I run this script before
splitting changesets.

The script is slow and ugly but appears to work.  It's especially slow
when you have a lot of deletions in your changeset because the
osmChange format doesn't carry full information about what operations
a deletion operations depends on -- say, to delete a node, you need to
first delete or modify all the ways and relations the node appears in.
 Effectively the script has to assume the operation depends on all
such operations that appear before the deletion in the changeset and
add them to the node's dependency tree, so the tree starts growing in
depth.

./smarter-sort.py upload.osc
produces a upload-sorted.osc which is sorted by how "autonomous" each
operation is (and bounding box centre).  Next step could be a smarter
splitter script, so that when you have a changeset that adds 2 ways,
with 4 and 2 nodes respectively (8 operations altogether) and split it
in 2 pieces, the pieces would have 5 and 3 three operations
respectively instead of 4 and 4.

Cheers




More information about the Imports mailing list