Ticket #14796: JMapViewer-2.patch
| File JMapViewer-2.patch, 6.3 KB (added by , 9 years ago) |
|---|
-
src/org/openstreetmap/gui/jmapviewer/JMapViewer.java
44 44 */ 45 45 public class JMapViewer extends JPanel implements TileLoaderListener { 46 46 47 private static final long serialVersionUID = 1L; 48 47 49 /** whether debug mode is enabled or not */ 48 50 public static boolean debug; 49 51 … … 502 504 return (int) marker.getRadius(); 503 505 else if (p != null) { 504 506 Integer radius = getLatOffset(marker.getLat(), marker.getLon(), marker.getRadius(), false); 505 radius = radius == null ? null : p.y - radius .intValue();507 radius = radius == null ? null : p.y - radius; 506 508 return radius; 507 509 } else 508 510 return null; -
src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java
9 9 import java.util.HashMap; 10 10 import java.util.Map; 11 11 import java.util.Map.Entry; 12 import java.util.concurrent. Executors;12 import java.util.concurrent.LinkedBlockingQueue; 13 13 import java.util.concurrent.ThreadPoolExecutor; 14 import java.util.concurrent.TimeUnit; 14 15 15 16 import org.openstreetmap.gui.jmapviewer.interfaces.TileJob; 16 17 import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader; … … 22 23 * @author Jan Peter Stotz 23 24 */ 24 25 public class OsmTileLoader implements TileLoader { 25 private static final ThreadPoolExecutor jobDispatcher = (ThreadPoolExecutor) Executors.newFixedThreadPool(3); 26 27 private static final ThreadPoolExecutor jobDispatcher = new ThreadPoolExecutor(8, 24, 30, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(2_000)); 26 28 27 29 private final class OsmTileJob implements TileJob { 28 30 private final Tile tile; … … 178 180 179 181 @Override 180 182 public void cancelOutstandingTasks() { 181 jobDispatcher.getQueue().clear(); 183 for (Runnable item : jobDispatcher.getQueue()) { 184 jobDispatcher.remove(item); 185 } 182 186 } 183 187 184 188 /** -
src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java
263 263 } 264 264 } 265 265 try { 266 return attributions.get( 0, TimeUnit.MILLISECONDS);266 return attributions.get(1500, TimeUnit.MILLISECONDS); 267 267 } catch (TimeoutException ex) { 268 268 System.err.println("Bing: attribution data is not yet loaded."); 269 269 } catch (ExecutionException ex) { -
src/org/openstreetmap/gui/jmapviewer/tilesources/OsmTileSource.java
1 1 // License: GPL. For details, see Readme.txt file. 2 2 package org.openstreetmap.gui.jmapviewer.tilesources; 3 3 4 import java.io.IOException; 5 import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate; 6 4 7 /** 5 8 * OSM Tile source. 6 9 */ … … 37 40 */ 38 41 public static class CycleMap extends AbstractOsmTileSource { 39 42 40 private static final String PATTERN = "http://%s.tile.opencyclemap.org/cycle";43 private static final String API_KEY = "API_KEY"; 41 44 42 private static final String [] SERVER = {"a", "b", "c"};45 private static final String PATTERN = "https://%s.tile.thunderforest.com/cycle"; 43 46 47 private static final String[] SERVER = { "a", "b", "c" }; 48 44 49 private int serverNum; 45 50 46 51 /** … … 47 52 * Constructs a new {@code CycleMap} tile source. 48 53 */ 49 54 public CycleMap() { 50 super(" Cyclemap", PATTERN, "opencyclemap");55 super("OSM Cycle Map", PATTERN, "opencyclemap"); 51 56 } 52 57 53 58 @Override … … 61 66 public int getMaxZoom() { 62 67 return 18; 63 68 } 69 70 @Override 71 public String getTileUrl(int zoom, int tilex, int tiley) throws IOException { 72 return this.getBaseUrl() + getTilePath(zoom, tilex, tiley); // + "?apikey=" + API_KEY; 73 } 74 75 @Override 76 public String getAttributionText(int zoom, ICoordinate topLeft, ICoordinate botRight) { 77 return "Maps © Thunderforest, Data © OpenStreetMap contributors"; 78 } 79 80 @Override 81 public String getAttributionLinkURL() { 82 return "http://www.thunderforest.com/"; 83 } 64 84 } 85 65 86 } -
src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java
116 116 @Override 117 117 public Point latLonToXY(double lat, double lon, int zoom) { 118 118 return new Point( 119 (int) osmMercator.lonToX(lon, zoom),120 (int) latToTileY(lat, zoom)119 (int) Math.round(osmMercator.lonToX(lon, zoom)), 120 (int) Math.round(latToTileY(lat, zoom)) 121 121 ); 122 122 } 123 123 -
src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java
50 50 @Override 51 51 public Point latLonToXY(double lat, double lon, int zoom) { 52 52 return new Point( 53 (int) osmMercator.lonToX(lon, zoom),54 (int) osmMercator.latToY(lat, zoom)53 (int) Math.round(osmMercator.lonToX(lon, zoom)), 54 (int) Math.round(osmMercator.latToY(lat, zoom)) 55 55 ); 56 56 } 57 57
