[OSM-dev] [patch] JOSM - make reorder work correctly in more circumstances

Robert Hart bathterror at gmail.com
Wed Aug 29 01:17:56 BST 2007


The attached patch is a first attempt to fix problems with the reorder
tool in JOSM not acting as expected. With this patch the reorder tool
should work on a wider range of ways, particularly ways with loops at
the start and end, and should prefer the existing order when a way is
already sorted (I think). The behaviour with branched ways remains
undefined.

There are two parts to the fix:

1) Prefer to move forward from the end of the segment to the start of
the next. (specifically this prevents certain case where a correctly
ordered way would be scrambled by the reorder tool, by nipping the
wrong way down a loop but then continuing forward the correct way
around the loop.

2) Try and start from a segment that is likely to be at the start of the way.

The logic goes: For each of the nodes in the way count up how many
times it occurs as the start or end node of a segment in the way. Then
pick the first segment that has:
a) a start node used only once (i.e. most common ways)
b) a start node used an odd number of times (e.g. a way with a lollipop loop)
c) an end node used only once (e.g. a partially reversed way)
d) an end node used an odd number of times. (e.g. a partially reversed lollipop)
otherwise pick the first segment (e.g. closed loop)

Logically a non-branched way should contain either exactly two nodes
with odd reference counts or none.

This is related to trac#169, but not an entire fix yet as the reorder
logic is separate for tools that modify ways - I'll look into that
later.

 I don't write much java, so my perl mentality is probably shining
through a bit too much - feel free to complain and I'll try and
address any concerns.

Rob

-- 
-- 
Robert Hart
-------------- next part --------------
A non-text attachment was scrubbed...
Name: makereordernotsuck.diff
Type: text/x-patch
Size: 4361 bytes
Desc: not available
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20070829/8a327977/attachment.bin>


More information about the dev mailing list