[OSM-dev] Script to fix way ordering

Frederik Ramm frederik at remote.org
Mon Mar 26 00:45:42 BST 2007


Hi,

    80n has recently built "frollo", an XSLT-based approach to order 
unordered ways (as they often cause rendering problems).

In the spirit of healthy competition, I have just submitted my own 
approach at solving the problem to SVN:

/utils/planet.osm/perl/reorder-ways.pl

or

http://trac.openstreetmap.org/browser/utils/planet.osm/perl/reorder-ways.pl

It is not built into t at h or anything, it is a simple stand-alone Perl 
script which takes an OSM file on standard input and writes a modified 
OSM file to standard output. You can use the modified OSM file for 
rendering, or you can load it into JOSM and simply hit "upload changes" 
to write the fixes to the database. (But please have a good look at what 
you're doing before you do that.) Since the script puts XML comments 
into the output file, you can also use "grep" and "wc" to generate 
simple statistics of how many of your ways are broken ;-)

Details are in the comments at the top of the script.

Please note that although I put it into the planet.osm directory, the 
script is not able to handle the whole planet file at once. It does 
handle sizable portions of the planet file (e.g. the full Germany 
dataset, which is roughly 10% of the planet file, is processed in under 
60 seconds and using roughly 400 MB of memory), but to process the whole 
planet file you'd need something around 6 GB of RAM.

The algorithm used for re-ordering ways is exactly the same that JOSM 
uses, and with added code to reverse segments if re-ordering is not 
possible otherwise. There are some caveats to segment reversal, which 
are also documented in the file itself.

Bye
Frederik

-- 
Frederik Ramm  ##  eMail frederik at remote.org  ##  N49°00.09' E008°23.33'




More information about the dev mailing list