[OSM-talk] JOSM "simplify way" option

Frederik Ramm frederik at remote.org
Sun May 20 04:15:40 BST 2007


Hi,

   there's a lot of auto-imported data that looks ugly - I saw a lot of 
"staircase coastlines" somewhere in Asia, and have also encountered 
roads that were obviously created directly from a GPS tracklog without 
any simplification.

While these should ideally be avoided on import, it would be nice to 
have some support in dealing with those that are there. I have added an 
(experimental) "simplify way" function to JOSM; if you want to try it 
out, you have to download this version:

http://www.remote.org/frederik/tmp/josm-with-simplify.jar

I have nicked the algorithm used by gpsbabel when it is called with the 
"-x simplify,error=xxx" option. What this does is essentially compute 
the "cross track error" that would be introduced by removing a node from 
the way (see pic), and remove the node it if the error is less than the 
given threshold.

In this play version, the default for the allowed error is 0.06 in 
whatever units, I think it must be statue miles ;-) (that's what you get 
when you copy code without properly understanding it). This is good for 
fixing staircase coastlines, but will probably break detailed city 
mapping, you'll have to use something closer to 0.0002 for that I guess. 
It can be changed in the preferences option "simplify-way.max-error".

The method only removes nodes (and segments), it never moves nodes. It 
also never removes the first node or last node in a way, nor does it 
remove a node tagged other than "created_by" and "source", and it also 
never removes nodes or segments used by other objects. It isn't very 
talkative at the moment so if you select a way and click simplify and 
nothing happens, maybe the way just isn't simplifiable. A production 
version of this would of course have to talk more, and probably ask for 
the desired maximum error each time it is executed.

gpsbabel supports other methods of simplifying a way: it can look at 
segment lengths instead of cross-track errors, and it can also (instead 
of removing everything that falls below a certain threshold) remove a 
certain number of nodes. This might actually be nice to have in JOSM - 
make the simplify function always remove the 20% of the way's nodes that 
introduce the smallest error, and you can then repeat this until you are 
happy.

Maybe others have experimented with way simplification and want to offer 
different algorithms? I'd also be interested in user reports, so if you 
know of some nasty ways in your area, give the above .jar a try and tell 
me if it is any good.

Bye
Frederik

-- 
Frederik Ramm  ##  eMail frederik at remote.org  ##  N49°00.09' E008°23.33'
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cte.png
Type: image/png
Size: 12174 bytes
Desc: not available
URL: <http://lists.openstreetmap.org/pipermail/talk/attachments/20070520/4f945cc1/attachment.png>


More information about the talk mailing list