﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
11263	[PATCH] Rounding errors in displaying of tiles	asdqweasd	team	"In function drawImageInside in file TMSLayer.java there are several casts from double to int, so rounding is performed towards zero.

        int img_x_offset = (int)(screen_x_offset * imageXScaling);
        int img_y_offset = (int)(screen_y_offset * imageYScaling);

        int img_x_end   = img_x_offset + (int)(target.getWidth() * imageXScaling);
        int img_y_end   = img_y_offset + (int)(target.getHeight() * imageYScaling);

However, the values before rounding are often close to integer values. In some cases they are less then the nearest integer and are like 255.999..., but in some cases they are greater, for example 256.000... This causes corresponding integer value to be decreased by one randomly.

I have changed these lines to make rounding to the nearest value:
        int img_x_offset = (int)(screen_x_offset * imageXScaling + 0.5);
        int img_y_offset = (int)(screen_y_offset * imageYScaling + 0.5);

        int img_x_end   = img_x_offset + (int)(target.getWidth() * imageXScaling + 0.5);
        int img_y_end   = img_y_offset + (int)(target.getHeight() * imageYScaling + 0.5);

I have noticed several enhancements in appearance of the imagery by comparing the old version and the new one by running them simultaneously.
1. Zooming of the map has become much smoother and some jitter, which was previously present, has disappeared.
2. While dragging the map, new tiles previously sometimes appeared misplaced by about a pixel, and after dragging further, they jumped to the correct position. After the fix the imagery looks more solid.
3. When zoomed to the maximum level and trying to zoom more, the imagery previously jumped to a random offset each time.

I'm not sure that this is the correct way to fix the bug, because I don't understand the whole process of calculating offsets and rendering the tiles, and I need help of somebody experienced in this.

Also, similar pieces of code should be checked (for example, WMSLayer) to see, if this bug affects them too."	defect	closed	normal	15.03	Core imagery	latest	fixed		
