/** * @param zoom level of the tile * @return how many pixels of the screen occupies one pixel of the tile */ private double getTileToScreenRatio(int zoom) { MapView mv = Main.map.mapView; LatLon topLeft = mv.getLatLon(0, 0); LatLon botLeft = mv.getLatLon(0, tileSource.getTileSize()); TileXY topLeftTile = tileSource.latLonToTileXY(topLeft.toCoordinate(), zoom); ICoordinate north = tileSource.tileXYToLatLon(topLeftTile.getXIndex(), topLeftTile.getYIndex(), zoom); ICoordinate south = tileSource.tileXYToLatLon(topLeftTile.getXIndex(), topLeftTile.getYIndex() + 1, zoom); return Math.abs((north.getLat() - south.getLat()) / (topLeft.lat() - botLeft.lat())); }
/** Restores the previous settings in the download dialog. */ public void restoreSettings() { cbDownloadOsmData.setSelected(Main.pref.getBoolean("download.osm", true)); cbDownloadGpxData.setSelected(Main.pref.getBoolean("download.gps", false)); cbNewLayer.setSelected(Main.pref.getBoolean("download.newlayer", false)); cbStartup.setSelected(isAutorunEnabled()); int idx = Main.pref.getInteger("download.tab", 0); if (idx < 0 || idx > tpDownloadAreaSelectors.getTabCount()) { idx = 0; } tpDownloadAreaSelectors.setSelectedIndex(idx); if (Main.isDisplayingMapView()) { MapView mv = Main.map.mapView; currentBounds = new Bounds(mv.getLatLon(0, mv.getHeight()), mv.getLatLon(mv.getWidth(), 0)); boundingBoxChanged(currentBounds, null); } else { Bounds bounds = getSavedDownloadBounds(); if (bounds != null) { currentBounds = bounds; boundingBoxChanged(currentBounds, null); } } }