Changeset 35190 in osm


Ignore:
Timestamp:
2019-10-13T22:09:23+02:00 (5 years ago)
Author:
wiktorn
Message:

Allow zooms up to 24 in JMapViewer.

See: #josm18064

Location:
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java

    r34760 r35190  
    5656
    5757    /** Maximum zoom level */
    58     public static final int MAX_ZOOM = 22;
     58    public static final int MAX_ZOOM = 24;
    5959    /** Minimum zoom level */
    6060    public static final int MIN_ZOOM = 0;
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmMercator.java

    r32602 r35190  
    2929    public static final OsmMercator MERCATOR_256 = new OsmMercator();
    3030
    31     /** tile size of the displayed tiles */
    32     private int tileSize = DEFAUL_TILE_SIZE;
     31    /** tile size of the displayed tiles. Use long so all calculations will be in 64bit to properly handle zooms above 22 for 256 tile size */
     32    private long tileSize = DEFAUL_TILE_SIZE;
    3333
    3434    /**
     
    5757     * @return number of pixels
    5858     */
    59     public int getMaxPixels(int aZoomlevel) {
     59    public long getMaxPixels(int aZoomlevel) {
    6060        return tileSize * (1 << aZoomlevel);
    6161    }
    6262
    63     public int falseEasting(int aZoomlevel) {
     63    public long falseEasting(int aZoomlevel) {
    6464        return getMaxPixels(aZoomlevel) / 2;
    6565    }
    6666
    67     public int falseNorthing(int aZoomlevel) {
     67    public long falseNorthing(int aZoomlevel) {
    6868        return -1 * getMaxPixels(aZoomlevel) / 2;
    6969    }
     
    8080     * @return the distance
    8181     */
    82     public double getDistance(int x1, int y1, int x2, int y2, int zoomLevel) {
     82    public double getDistance(long x1, long y1, long x2, long y2, int zoomLevel) {
    8383        double la1 = yToLat(y1, zoomLevel);
    8484        double lo1 = xToLon(x1, zoomLevel);
     
    130130     */
    131131    public double lonToX(double aLongitude, int aZoomlevel) {
    132         int mp = getMaxPixels(aZoomlevel);
     132        long mp = getMaxPixels(aZoomlevel);
    133133        double x = (mp * (aLongitude + 180L)) / 360L;
    134134        return Math.min(x, mp);
     
    160160        double sinLat = Math.sin(Math.toRadians(aLat));
    161161        double log = Math.log((1.0 + sinLat) / (1.0 - sinLat));
    162         int mp = getMaxPixels(aZoomlevel);
     162        long mp = getMaxPixels(aZoomlevel);
    163163        double y = mp * (0.5 - (log / (4.0 * Math.PI)));
    164164        return Math.min(y, mp - 1);
     
    183183     * @return ]-180..180[
    184184     */
    185     public double xToLon(int aX, int aZoomlevel) {
     185    public double xToLon(long aX, int aZoomlevel) {
    186186        return ((360d * aX) / getMaxPixels(aZoomlevel)) - 180.0;
    187187    }
     
    195195     * @return [MIN_LAT..MAX_LAT] is about [-85..85]
    196196     */
    197     public double yToLat(int aY, int aZoomlevel) {
    198         aY += falseNorthing(aZoomlevel);
    199         double latitude = (Math.PI / 2) - (2 * Math.atan(Math.exp(-1.0 * aY / radius(aZoomlevel))));
     197    public double yToLat(long aY, int aZoomlevel) {
     198        double latitude = (Math.PI / 2) - (2 * Math.atan(Math.exp(-1.0 * (aY + falseNorthing(aZoomlevel)) / radius(aZoomlevel))));
    200199        return -1 * Math.toDegrees(latitude);
    201200    }
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java

    r33973 r35190  
    1212import java.util.Set;
    1313
     14import org.openstreetmap.gui.jmapviewer.JMapViewer;
    1415import org.openstreetmap.gui.jmapviewer.OsmMercator;
    1516import org.openstreetmap.gui.jmapviewer.Tile;
     
    7374    @Override
    7475    public int getMaxZoom() {
    75         return 21;
     76        return JMapViewer.MAX_ZOOM;
    7677    }
    7778
    7879    @Override
    7980    public int getMinZoom() {
    80         return 0;
     81        return JMapViewer.MIN_ZOOM;
    8182    }
    8283
Note: See TracChangeset for help on using the changeset viewer.