Changeset 11844 in josm for trunk/src


Ignore:
Timestamp:
2017-04-05T20:38:08+02:00 (7 years ago)
Author:
bastiK
Message:

see #7427 - avoid roundtrip conversion EastNorth -> LatLon -> EastNorth

This circumvents LatLon clamping, so may have an impact on display near lon=+/-180 degrees

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/coor/EastNorth.java

    r11830 r11844  
    22package org.openstreetmap.josm.data.coor;
    33
     4import org.openstreetmap.gui.jmapviewer.Projected;
    45import org.openstreetmap.gui.jmapviewer.interfaces.IProjected;
    56
     
    181182    }
    182183
     184    public IProjected toProjected() {
     185        return new Projected(east(), north());
     186    }
     187
    183188    @Override
    184189    public String toString() {
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java

    r11842 r11844  
    6464import org.openstreetmap.gui.jmapviewer.MemoryTileCache;
    6565import org.openstreetmap.gui.jmapviewer.OsmTileLoader;
     66import org.openstreetmap.gui.jmapviewer.Projected;
    6667import org.openstreetmap.gui.jmapviewer.Tile;
    6768import org.openstreetmap.gui.jmapviewer.TileAnchor;
     
    984985    private TileSet getVisibleTileSet() {
    985986        ProjectionBounds bounds = Main.map.mapView.getState().getViewArea().getProjectionBounds();
    986         return getTileSet(bounds.getMin(), bounds.getMax(), currentZoomLevel);
     987        return getTileSet(bounds, currentZoomLevel);
    987988    }
    988989
     
    12581259    private final TileSet nullTileSet = new TileSet();
    12591260
    1260     private class TileSet extends TileRange {
     1261    protected class TileSet extends TileRange {
    12611262
    12621263        protected TileSet(TileXY t1, TileXY t2, int zoom) {
     
    13941395    /**
    13951396     * Create a TileSet by EastNorth bbox taking a layer shift in account
    1396      * @param topLeft top-left lat/lon
    1397      * @param botRight bottom-right lat/lon
     1397     * @param bounds the EastNorth bounds
    13981398     * @param zoom zoom level
    13991399     * @return the tile set
    1400      * @since 10651
    1401      */
    1402     protected TileSet getTileSet(EastNorth topLeft, EastNorth botRight, int zoom) {
    1403         return getTileSet(getShiftedLatLon(topLeft), getShiftedLatLon(botRight), zoom);
    1404     }
    1405 
    1406     /**
    1407      * Create a TileSet by known LatLon bbox without layer shift correction
    1408      * @param topLeft top-left lat/lon
    1409      * @param botRight bottom-right lat/lon
    1410      * @param zoom zoom level
    1411      * @return the tile set
    1412      * @since 10651
    1413      */
    1414     protected TileSet getTileSet(LatLon topLeft, LatLon botRight, int zoom) {
    1415         if (zoom == 0)
    1416             return new TileSet();
    1417 
    1418         TileXY t1 = tileSource.latLonToTileXY(topLeft.toCoordinate(), zoom);
    1419         TileXY t2 = tileSource.latLonToTileXY(botRight.toCoordinate(), zoom);
     1400     */
     1401    protected TileSet getTileSet(ProjectionBounds bounds, int zoom) {
     1402        EastNorth topLeftUnshifted = coordinateConverter.shiftDisplayToServer(bounds.getMin());
     1403        EastNorth botRightUnshifted = coordinateConverter.shiftDisplayToServer(bounds.getMax());
     1404        TileXY t1 = tileSource.projectedToTileXY(topLeftUnshifted.toProjected(), zoom);
     1405        TileXY t2 = tileSource.projectedToTileXY(botRightUnshifted.toProjected(), zoom);
    14201406        return new TileSet(t1, t2, zoom);
    14211407    }
     
    14721458                TileSet ts = tileSets[zoom-minZoom];
    14731459                if (ts == null) {
    1474                     ts = AbstractTileSourceLayer.this.getTileSet(bounds.getMin(), bounds.getMax(), zoom);
     1460                    ts = AbstractTileSourceLayer.this.getTileSet(bounds, zoom);
    14751461                    tileSets[zoom-minZoom] = ts;
    14761462                }
     
    16571643            Main.debug("getTileForPixelpos("+px+", "+py+')');
    16581644        }
    1659         MapView mv = Main.map.mapView;
    16601645        Point clicked = new Point(px, py);
    1661         EastNorth topLeft = mv.getEastNorth(0, 0);
    1662         EastNorth botRight = mv.getEastNorth(mv.getWidth(), mv.getHeight());
    1663         TileSet ts = getTileSet(topLeft, botRight, currentZoomLevel);
     1646        TileSet ts = getVisibleTileSet();
    16641647
    16651648        if (!ts.tooLarge()) {
  • trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileCoordinateConverter.java

    r11841 r11844  
    4848    private MapViewPoint pos(IProjected p) {
    4949        return mapView.getState().getPointFor(new EastNorth(p)).add(settings.getDisplacement());
     50    }
     51
     52    /**
     53     * Apply reverse shift to EastNorth coordinate.
     54     *
     55     * @param en EastNorth coordinate representing a pixel on screen
     56     * @return EastNorth coordinate as it would e.g. be sent to a WMS server
     57     */
     58    public EastNorth shiftDisplayToServer(EastNorth en) {
     59        return en.subtract(settings.getDisplacement());
    5060    }
    5161
Note: See TracChangeset for help on using the changeset viewer.