Modify

Opened 9 years ago

Closed 9 years ago

#12571 closed defect (fixed)

JMapViewer.getLatOffset bug

Reported by: lasse+josm@… Owned by: team
Priority: major Milestone: 16.02
Component: JMapViewer Version:
Keywords: regression Cc: wiktorn

Description

The current implementation of JMapViewer.getLatOffset contains a bug. This is a regression. The current implementation is as follows:

    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:

    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:

    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;
    }
}

Attachments (0)

Change History (3)

comment:1 by lasse+josm@…, 9 years ago

Note that the effect of this bug is visible in the Demo app. The MapMarkerCircles that are created in the app are way to big.

comment:2 by simon04, 9 years ago

Cc: wiktorn added
Keywords: regression added
Milestone: 16.02

Regression from [o31301].

comment:3 by wiktorn, 9 years ago

Resolution: fixed
Status: newclosed

Fixed in [o32083]. Good catch, thanks.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.