logo separator

[mkgmap-dev] What's d for? (possibly related to clipping issue?)

From Steve Ratcliffe steve at parabola.demon.co.uk on Sat Feb 21 14:39:52 GMT 2009

On Fri, Feb 20, 2009 at 12:03:59AM +0000, Mark Burton wrote:
> 
> Why does the line clipper add a tiddly amount (d) in these expressions? 
> 
> 
> 		double d = 0.00001;
> 		if (t[0] > 0)
> 			ends[0] = new Coord((int) (y0 + t[0] * dy + d), (int) (x0 + t[0] * dx + d));
> 
> 		if (t[1] < 1)
> 			ends[1] = new Coord((int)(y0 + t[1] * dy + d), (int) (x0 + t[1] * dx + d));

It for rounding to the nearest map unit.  I remember I was just adjusting
it until I got something that worked, but can't quite remember what the
problem I was solving was.

If I'd thought about it more I would have said that the correct value would be:

  360/(2 * 2^24)

which comes to 0.000010728, so perhaps close enough.

> On a similar note, why have the non-zero DELTA here?
> 
> 	public static int toMapUnit(double l) {
> 		double DELTA = 0.000001; // TODO check if we really mean this

That is a much smaller delta and is just protecting against floating point
numbers that are intended to be an exact value but are just a bit less.
It is not trying to round to the closest map unit one in this case.

It may not be needed but it is the rouding of the areas in the TDB file
that was affected if I remember correctly, so if you want to experiment
without it, or think it is causing trouble elsewhere we need to check the
TDB areas.

..Steve



More information about the mkgmap-dev mailing list