[josm-dev] When to move a node?

Harald Kucharek harald.kucharek at gmx.net
Tue Nov 18 17:05:07 GMT 2008


When Frederik added my orthogonalization action to JOSM, he remarked:
--
There's one thing I do not like yet, and that is that multiple changes 
are generated if you call the function repeatedly (it doesn't recognize 
that the shape is already rectangular, makes minuscle adjustments). I 
tried to build in a treshold under which there would be no change 
recorded but it didn't work out well.
--
It seems, this hold for all similar actions, like "Align nodes in 
circle" etc.

Frederik used from LatLon this method:

public boolean equalsEpsilon(LatLon other) {
   final double p = 1/Projection.MAX_SERVER_PRECISION;
   return Math.abs(lat()-other.lat()) <= p && 
Math.abs(lon()-other.lon()) <= p;
}

where
/**
* Minimum difference in location to not be represented as the same position.
*/
MAX_SERVER_PRECISION = 1e12;

Almost all operations will make this method return false, just due to 
numeric inaccuracies, I guess. Also, this is a very non-intuitive test.

I made a quick change by using 	
public double greatCircleDistance(LatLon other)
also from LatLon, only really moving nodes when the distance computed by 
above method is less than 2 meters (the method computes the distance in 
meters).
This way, it is very clear when a node really moves and when not. I had 
no time for long tests, but it seemed to me that the computed distance 
is either smaller than expected or the scale of the map, as nodes I 
expected to move weren't moved. I've to check this next weekend.
Sure, greatCircleDistance() is computationally much more expensive than 
equalsEpsilon(), but we usually don't move millions of nodes.

That was my idea. Now, any other ideas or thoughts about the problem?

Regards,

Harald






More information about the josm-dev mailing list