Ticket #14796: JMapViewer-3.patch
File JMapViewer-3.patch, 6.4 KB (added by , 8 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 */ … … 62 65 return 18; 63 66 } 64 67 } 68 69 /** 70 * The "Transport Map" OSM tile source. 71 */ 72 public static class TransportMap extends AbstractOsmTileSource { 73 74 private static final String API_KEY = "API_KEY_HERE"; 75 76 private static final String PATTERN = "https://%s.tile.thunderforest.com/transport"; 77 78 private static final String[] SERVER = { "a", "b", "c" }; 79 80 private int serverNum; 81 82 /** 83 * Constructs a new {@code TransportMap} tile source. 84 */ 85 public TransportMap() { 86 super("OSM Transport Map", PATTERN, "osmtransportmap"); 87 } 88 89 @Override 90 public String getBaseUrl() { 91 String url = String.format(this.baseUrl, new Object[] {SERVER[serverNum]}); 92 serverNum = (serverNum + 1) % SERVER.length; 93 return url; 94 } 95 96 @Override 97 public int getMaxZoom() { 98 return 18; 99 } 100 101 @Override 102 public String getTileUrl(int zoom, int tilex, int tiley) throws IOException { 103 return this.getBaseUrl() + getTilePath(zoom, tilex, tiley); // + "?apikey=" + API_KEY; 104 } 105 106 @Override 107 public String getAttributionText(int zoom, ICoordinate topLeft, ICoordinate botRight) { 108 return "Maps © Thunderforest, Data © OpenStreetMap contributors"; 109 } 110 111 @Override 112 public String getAttributionLinkURL() { 113 return "http://www.thunderforest.com/"; 114 } 115 } 116 65 117 } -
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