﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
12571	JMapViewer.getLatOffset bug	lasse+josm@…	team	"The current implementation of JMapViewer.getLatOffset contains a bug. This is a regression. The current implementation is as follows:

{{{#!java
    public Integer getLatOffset(double lat, double lon, double offset, boolean checkOutside) {
        Point p = tileSource.latLonToXY(lat, lon, zoom);
        int y = p.y - center.y - getHeight() / 2;
        if (checkOutside && (y < 0 || y > getHeight())) {
            return null;
        }
        return y;
    }
}}}

If we look at the implementation in July 2015 it was as follows:

{{{#!java
    public Integer getLatOffset(double lat, double offset, boolean checkOutside) {
        int y = tileSource.latToY(lat + offset, zoom);
        y -= center.y - getHeight() / 2;
        if (checkOutside) {
            if (y < 0 || y > getHeight())
                return null;
        }
        return y;
    }
}}}

We see that in the new version, the offset is no longer used, and there should be brackets around the calculation on the second line of the method. The correct implementation is as follows:

{{{#!java
    public Integer getLatOffset(double lat, double lon, double offset, boolean checkOutside) {
        Point p = tileSource.latLonToXY(lat + offset, lon, zoom);
        int y = p.y - (center.y - getHeight() / 2);
        if (checkOutside && (y < 0 || y > getHeight())) {
            return null;
        }
        return y;
    }
}"	defect	closed	major	16.02	JMapViewer		fixed	regression	wiktorn
