Changeset 3878 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2011-02-09T13:01:08+01:00 (14 years ago)
Author:
Upliner
Message:

Add support for ScanEx IRS tilesource (patch by glebius)

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java

    r3835 r3878  
    3333        if (info.isBlacklisted()) {
    3434            setEnabled(false);
    35         } else if (info.getImageryType() == ImageryType.TMS || info.getImageryType() == ImageryType.BING) {
     35        } else if (info.getImageryType() == ImageryType.TMS || info.getImageryType() == ImageryType.BING || info.getImageryType() == ImageryType.SCANEX) {
    3636            setEnabled(true);
    3737        } else if (Main.map != null && Main.map.mapView != null && !Main.map.mapView.getAllLayers().isEmpty()) {
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    r3826 r3878  
    1616        TMS("tms"),
    1717        HTML("html"),
    18         BING("bing");
     18        BING("bing"),
     19        SCANEX("scanex");
    1920
    2021        private String urlString;
  • trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java

    r3826 r3878  
    8080
    8181        @Override public String getTermsOfUseURL() { return source.getTermsOfUseURL(); }
     82
     83        @Override public double latToTileY(double lat, int zoom) { return source.latToTileY(lat,zoom); }
     84
     85        @Override public double lonToTileX(double lon, int zoom) { return source.lonToTileX(lon,zoom); }
     86
     87        @Override public double tileYToLat(int y, int zoom) { return tileYToLat(y, zoom); }
     88
     89        @Override public double tileXToLon(int x, int zoom) { return tileXToLon(x, zoom); }
    8290    }
    8391
  • trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java

    r3852 r3878  
    131131        if (info.getImageryType() == ImageryType.WMS || info.getImageryType() == ImageryType.HTML)
    132132            return new WMSLayer(info);
    133         else if (info.getImageryType() == ImageryType.TMS || info.getImageryType() == ImageryType.BING)
     133        else if (info.getImageryType() == ImageryType.TMS || info.getImageryType() == ImageryType.BING || info.getImageryType() == ImageryType.SCANEX)
    134134            return new TMSLayer(info);
    135135        else throw new AssertionError();
  • trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java

    r3826 r3878  
    4343import org.openstreetmap.gui.jmapviewer.OsmFileCacheTileLoader;
    4444import org.openstreetmap.gui.jmapviewer.OsmTileLoader;
     45import org.openstreetmap.gui.jmapviewer.ScanexIRSTileSource;
    4546import org.openstreetmap.gui.jmapviewer.TMSTileSource;
    4647import org.openstreetmap.gui.jmapviewer.TemplatedTMSTileSource;
     
    238239        } else if (info.getImageryType() == ImageryType.BING)
    239240            return new BingAerialTileSource();
     241        else if (info.getImageryType() == ImageryType.SCANEX)
     242            return new ScanexIRSTileSource();
    240243        return null;
    241244    }
     
    286289        LatLon topLeft = mv.getLatLon(0, 0);
    287290        LatLon botRight = mv.getLatLon(mv.getWidth(), mv.getHeight());
    288         double x1 = lonToTileX(topLeft.lon(), zoom);
    289         double y1 = latToTileY(topLeft.lat(), zoom);
    290         double x2 = lonToTileX(botRight.lon(), zoom);
    291         double y2 = latToTileY(botRight.lat(), zoom);
     291        double x1 = tileSource.lonToTileX(topLeft.lon(), zoom);
     292        double y1 = tileSource.latToTileY(topLeft.lat(), zoom);
     293        double x2 = tileSource.lonToTileX(botRight.lon(), zoom);
     294        double y2 = tileSource.latToTileY(botRight.lat(), zoom);
    292295
    293296        int screenPixels = mv.getWidth()*mv.getHeight();
     
    677680    {
    678681        int zoom = t.getZoom();
    679         return new LatLon(tileYToLat(t.getYtile(), zoom),
    680                 tileXToLon(t.getXtile(), zoom));
     682        return new LatLon(tileSource.tileYToLat(t.getYtile(), zoom),
     683                tileSource.tileXToLon(t.getXtile(), zoom));
    681684    }
    682685
     
    866869    }
    867870    private Point pixelPos(Tile t) {
    868         double lon = tileXToLon(t.getXtile(), t.getZoom());
    869         LatLon tmpLL = new LatLon(tileYToLat(t.getYtile(), t.getZoom()), lon);
     871        double lon = tileSource.tileXToLon(t.getXtile(), t.getZoom());
     872        LatLon tmpLL = new LatLon(tileSource.tileYToLat(t.getYtile(), t.getZoom()), lon);
    870873        return pixelPos(tmpLL);
    871874    }
     
    898901                return;
    899902
    900             x0 = (int)lonToTileX(topLeft.lon(),  zoom);
    901             y0 = (int)latToTileY(topLeft.lat(),  zoom);
    902             x1 = (int)lonToTileX(botRight.lon(), zoom);
    903             y1 = (int)latToTileY(botRight.lat(), zoom);
     903            x0 = (int)tileSource.lonToTileX(topLeft.lon(),  zoom);
     904            y0 = (int)tileSource.latToTileY(topLeft.lat(),  zoom);
     905            x1 = (int)tileSource.lonToTileX(botRight.lon(), zoom);
     906            y1 = (int)tileSource.latToTileY(botRight.lat(), zoom);
    904907            if (x0 > x1) {
    905908                int tmp = x0;
     
    13031306        return needRedraw;
    13041307    }
    1305 
    1306     private static double latToTileY(double lat, int zoom) {
    1307         double l = lat / 180 * Math.PI;
    1308         double pf = Math.log(Math.tan(l) + (1 / Math.cos(l)));
    1309         return Math.pow(2.0, zoom - 1) * (Math.PI - pf) / Math.PI;
    1310     }
    1311 
    1312     private static double lonToTileX(double lon, int zoom) {
    1313         return Math.pow(2.0, zoom - 3) * (lon + 180.0) / 45.0;
    1314     }
    1315 
    1316     private static double tileYToLat(int y, int zoom) {
    1317         return Math.atan(Math.sinh(Math.PI
    1318                 - (Math.PI * y / Math.pow(2.0, zoom - 1))))
    1319                 * 180 / Math.PI;
    1320     }
    1321 
    1322     private static double tileXToLon(int x, int zoom) {
    1323         return x * 45.0 / Math.pow(2.0, zoom - 3) - 180.0;
    1324     }
    13251308}
Note: See TracChangeset for help on using the changeset viewer.