This is an automated email from the git hooks/post-receive script. sebastic pushed a commit to branch master in repository jmapviewer.
commit 37824042229b2c8adc494283042d069ed9d63c58 Author: Bas Couwenberg <sebas...@xs4all.nl> Date: Fri Oct 9 10:37:59 2015 +0200 Imported Upstream version 1.11+dfsg --- build.xml | 2 +- .../openstreetmap/gui/jmapviewer/JMapViewer.java | 36 ++-- .../gui/jmapviewer/JobDispatcher.java | 183 --------------------- .../gui/jmapviewer/OsmTileLoader.java | 10 +- src/org/openstreetmap/gui/jmapviewer/Tile.java | 11 +- .../gui/jmapviewer/TileController.java | 9 +- .../gui/jmapviewer/events/JMVCommandEvent.java | 2 +- .../gui/jmapviewer/interfaces/TileLoader.java | 6 + .../gui/jmapviewer/interfaces/TileSource.java | 114 ------------- .../tilesources/AbstractMapQuestTileSource.java | 9 +- .../tilesources/AbstractTMSTileSource.java | 40 ----- .../tilesources/BingAerialTileSource.java | 13 +- .../gui/jmapviewer/tilesources/OsmTileSource.java | 10 -- .../jmapviewer/tilesources/ScanexTileSource.java | 23 --- .../gui/jmapviewer/tilesources/TMSTileSource.java | 5 - 15 files changed, 50 insertions(+), 423 deletions(-) diff --git a/build.xml b/build.xml index 573115e..49c98c4 100644 --- a/build.xml +++ b/build.xml @@ -77,7 +77,7 @@ <target name="checkstyle"> <taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties" - classpath="tools/checkstyle/checkstyle-6.9-all.jar"/> + classpath="tools/checkstyle/checkstyle-6.11-all.jar"/> <checkstyle config="tools/checkstyle/jmapviewer_checks.xml"> <fileset dir="${basedir}/src" includes="**/*.java" /> <formatter type="xml" toFile="checkstyle-jmapviewer.xml"/> diff --git a/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java b/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java index b3d1fc5..8602f33 100644 --- a/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java +++ b/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java @@ -81,7 +81,7 @@ public class JMapViewer extends JPanel implements TileLoaderListener { protected JButton zoomInButton; protected JButton zoomOutButton; - public static enum ZOOM_BUTTON_STYLE { + public enum ZOOM_BUTTON_STYLE { HORIZONTAL, VERTICAL } @@ -102,17 +102,26 @@ public class JMapViewer extends JPanel implements TileLoaderListener { * retrieving the tiles. */ public JMapViewer() { - this(new MemoryTileCache(), 8); + this(new MemoryTileCache()); new DefaultMapController(this); } /** * Creates a new {@link JMapViewer} instance. * @param tileCache The cache where to store tiles - * @param downloadThreadCount The number of parallel threads for retrieving the tiles + * @deprecated @param downloadThreadCount not used anymore */ + @Deprecated public JMapViewer(TileCache tileCache, int downloadThreadCount) { - JobDispatcher.setMaxWorkers(downloadThreadCount); + this(tileCache); + } + + /** + * Creates a new {@link JMapViewer} instance. + * @param tileCache The cache where to store tiles + * + */ + public JMapViewer(TileCache tileCache) { tileSource = new OsmTileSource.Mapnik(); tileController = new TileController(tileSource, tileCache, this); mapMarkerList = Collections.synchronizedList(new LinkedList<MapMarker>()); @@ -456,25 +465,6 @@ public class JMapViewer extends JPanel implements TileLoaderListener { /** * Calculates the position on the map of a given coordinate * - * @param lat Latitude - * @param offset Offset respect Latitude - * @param checkOutside check if the point is outside the displayed area - * @return Integer the radius in pixels - * @deprecated use {@link #getLatOffset(double, double, double, boolean)} - */ - @Deprecated - public Integer getLatOffset(double lat, double offset, boolean checkOutside) { - int y = tileSource.latToY(lat + offset, zoom); - y -= center.y - getHeight() / 2; - if (checkOutside && (y < 0 || y > getHeight())) { - return null; - } - return y; - } - - /** - * Calculates the position on the map of a given coordinate - * * @param marker MapMarker object that define the x,y coordinate * @param p coordinate * @return Integer the radius in pixels diff --git a/src/org/openstreetmap/gui/jmapviewer/JobDispatcher.java b/src/org/openstreetmap/gui/jmapviewer/JobDispatcher.java deleted file mode 100644 index e689151..0000000 --- a/src/org/openstreetmap/gui/jmapviewer/JobDispatcher.java +++ /dev/null @@ -1,183 +0,0 @@ -// License: GPL. For details, see Readme.txt file. -package org.openstreetmap.gui.jmapviewer; - -import java.util.concurrent.BlockingDeque; -import java.util.concurrent.LinkedBlockingDeque; -import java.util.concurrent.TimeUnit; - -import org.openstreetmap.gui.jmapviewer.interfaces.TileJob; - -/** - * A generic class that processes a list of {@link Runnable} one-by-one using - * one or more {@link Thread}-instances. The number of instances varies between - * 1 and {@link #workerThreadMaxCount} (default: 8). If an instance is idle - * more than {@link #workerThreadTimeout} seconds (default: 30), the instance - * ends itself. - * - * @author Jan Peter Stotz - */ -public final class JobDispatcher { - - private static final JobDispatcher instance = new JobDispatcher(); - - private static int workerThreadMaxCount = 8; - - /** - * Specifies the time span in seconds that a worker thread waits for new - * jobs to perform. If the time span has elapsed the worker thread - * terminates itself. Only the first worker thread works differently, it - * ignores the timeout and will never terminate itself. - */ - private static int workerThreadTimeout = 30; - - /** - * Type of queue, FIFO if <code>false</code>, LIFO if <code>true</code> - */ - private boolean modeLIFO = false; - - /** - * Total number of worker threads currently idle or active - */ - private int workerThreadCount = 0; - - /** - * Number of worker threads currently idle - */ - private int workerThreadIdleCount = 0; - - /** - * Just an id for identifying an worker thread instance - */ - private int workerThreadId = 0; - - private final BlockingDeque<TileJob> jobQueue = new LinkedBlockingDeque<>(); - - private JobDispatcher() { - addWorkerThread().firstThread = true; - } - - /** - * @return the singelton instance of the {@link JobDispatcher} - */ - public static JobDispatcher getInstance() { - return instance; - } - - /** - * Removes all jobs from the queue that are currently not being processed. - */ - public void cancelOutstandingJobs() { - jobQueue.clear(); - } - - /** - * Function to set the maximum number of workers for tile loading. - * @param workers maximum number of workers - */ - public static void setMaxWorkers(int workers) { - workerThreadMaxCount = workers; - } - - /** - * Function to set the LIFO/FIFO mode for tile loading job. - * - * @param lifo <code>true</code> for LIFO mode, <code>false</code> for FIFO mode - */ - public void setLIFO(boolean lifo) { - modeLIFO = lifo; - } - - /** - * Adds a job to the queue. - * Jobs for tiles already contained in the are ignored (using a <code>null</code> tile - * prevents skipping). - * - * @param job the the job to be added - */ - public void addJob(TileJob job) { - try { - if (job.getTile() != null) { - for (TileJob oldJob : jobQueue) { - if (job.getTile().equals(oldJob.getTile())) { - return; - } - } - } - jobQueue.put(job); - synchronized (this) { - if (workerThreadIdleCount == 0 && workerThreadCount < workerThreadMaxCount) - addWorkerThread(); - } - } catch (InterruptedException e) { - System.err.println("InterruptedException: " + e.getMessage()); - } - } - - private JobThread addWorkerThread() { - JobThread jobThread = new JobThread(++workerThreadId); - synchronized (this) { - workerThreadCount++; - } - jobThread.start(); - return jobThread; - } - - public class JobThread extends Thread { - - private Runnable job; - private boolean firstThread = false; - - /** - * Constructs a new {@code JobThread}. - * @param threadId Thread ID - */ - public JobThread(int threadId) { - super("OSMJobThread " + threadId); - setDaemon(true); - job = null; - } - - @Override - public void run() { - executeJobs(); - synchronized (instance) { - workerThreadCount--; - } - } - - protected void executeJobs() { - while (!isInterrupted()) { - try { - synchronized (instance) { - workerThreadIdleCount++; - } - if (modeLIFO) { - if (firstThread) - job = jobQueue.takeLast(); - else - job = jobQueue.pollLast(workerThreadTimeout, TimeUnit.SECONDS); - } else { - if (firstThread) - job = jobQueue.take(); - else - job = jobQueue.poll(workerThreadTimeout, TimeUnit.SECONDS); - } - } catch (InterruptedException e1) { - return; - } finally { - synchronized (instance) { - workerThreadIdleCount--; - } - } - if (job == null) - return; - try { - job.run(); - job = null; - } catch (Exception e) { - e.printStackTrace(); - } - } - } - } -} diff --git a/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java b/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java index c26a61c..7064be3 100644 --- a/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java +++ b/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java @@ -9,6 +9,8 @@ import java.net.URLConnection; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; +import java.util.concurrent.Executor; +import java.util.concurrent.Executors; import org.openstreetmap.gui.jmapviewer.interfaces.TileJob; import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader; @@ -20,6 +22,7 @@ import org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener; * @author Jan Peter Stotz */ public class OsmTileLoader implements TileLoader { + private static final Executor jobDispatcher = Executors.newSingleThreadExecutor(); private final class OsmTileJob implements TileJob { private final Tile tile; @@ -88,7 +91,7 @@ public class OsmTileLoader implements TileLoader { @Override public void submit(boolean force) { this.force = force; - run(); + jobDispatcher.execute(this); } } @@ -177,4 +180,9 @@ public class OsmTileLoader implements TileLoader { public String toString() { return getClass().getSimpleName(); } + + @Override + public void cancelOutstandingTasks() { + // intentionally left empty - OsmTileLoader doesn't maintain queue + } } diff --git a/src/org/openstreetmap/gui/jmapviewer/Tile.java b/src/org/openstreetmap/gui/jmapviewer/Tile.java index d4bf072..4edbf43 100644 --- a/src/org/openstreetmap/gui/jmapviewer/Tile.java +++ b/src/org/openstreetmap/gui/jmapviewer/Tile.java @@ -95,7 +95,7 @@ public class Tile { * Wraps callable so it is evaluated only once * @param callable to cache */ - public CachedCallable(Callable<V> callable) { + CachedCallable(Callable<V> callable) { this.callable = callable; } @@ -434,4 +434,13 @@ public class Tile { public TileSource getTileSource() { return source; } + + /** + * indicate that loading process for this tile has been canceled + */ + public void loadingCanceled() { + loading = false; + loaded = false; + } + } diff --git a/src/org/openstreetmap/gui/jmapviewer/TileController.java b/src/org/openstreetmap/gui/jmapviewer/TileController.java index efd2287..c22cc05 100644 --- a/src/org/openstreetmap/gui/jmapviewer/TileController.java +++ b/src/org/openstreetmap/gui/jmapviewer/TileController.java @@ -1,7 +1,6 @@ // License: GPL. For details, see Readme.txt file. package org.openstreetmap.gui.jmapviewer; -import org.openstreetmap.gui.jmapviewer.JobDispatcher.JobThread; import org.openstreetmap.gui.jmapviewer.interfaces.TileCache; import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader; import org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener; @@ -12,18 +11,15 @@ public class TileController { protected TileCache tileCache; protected TileSource tileSource; - protected JobDispatcher jobDispatcher; - public TileController(TileSource source, TileCache tileCache, TileLoaderListener listener) { this.tileSource = source; this.tileLoader = new OsmTileLoader(listener); this.tileCache = tileCache; - this.jobDispatcher = JobDispatcher.getInstance(); } /** * retrieves a tile from the cache. If the tile is not present in the cache - * a load job is added to the working queue of {@link JobThread}. + * a load job is added to the working queue of {@link TileLoader}. * * @param tilex the X position of the tile * @param tiley the Y position of the tile @@ -80,8 +76,9 @@ public class TileController { /** * Removes all jobs from the queue that are currently not being processed. + * */ public void cancelOutstandingJobs() { - jobDispatcher.cancelOutstandingJobs(); + tileLoader.cancelOutstandingTasks(); } } diff --git a/src/org/openstreetmap/gui/jmapviewer/events/JMVCommandEvent.java b/src/org/openstreetmap/gui/jmapviewer/events/JMVCommandEvent.java index 7ffc3ce..34996df 100644 --- a/src/org/openstreetmap/gui/jmapviewer/events/JMVCommandEvent.java +++ b/src/org/openstreetmap/gui/jmapviewer/events/JMVCommandEvent.java @@ -11,7 +11,7 @@ import java.util.EventObject; * */ public class JMVCommandEvent extends EventObject { - public static enum COMMAND { + public enum COMMAND { MOVE, ZOOM } diff --git a/src/org/openstreetmap/gui/jmapviewer/interfaces/TileLoader.java b/src/org/openstreetmap/gui/jmapviewer/interfaces/TileLoader.java index 60fd704..8d1b5fd 100644 --- a/src/org/openstreetmap/gui/jmapviewer/interfaces/TileLoader.java +++ b/src/org/openstreetmap/gui/jmapviewer/interfaces/TileLoader.java @@ -20,4 +20,10 @@ public interface TileLoader { * action. */ TileJob createTileLoaderJob(Tile tile); + + /** + * cancels all outstanding tasks in the queue. This should rollback the state of the tiles in the queue + * to loading = false / loaded = false + */ + void cancelOutstandingTasks(); } diff --git a/src/org/openstreetmap/gui/jmapviewer/interfaces/TileSource.java b/src/org/openstreetmap/gui/jmapviewer/interfaces/TileSource.java index 64aa6c4..742b5a2 100644 --- a/src/org/openstreetmap/gui/jmapviewer/interfaces/TileSource.java +++ b/src/org/openstreetmap/gui/jmapviewer/interfaces/TileSource.java @@ -17,34 +17,6 @@ import org.openstreetmap.gui.jmapviewer.TileXY; public interface TileSource extends Attributed { /** - * Specifies the different mechanisms for detecting updated tiles - * respectively only download newer tiles than those stored locally. - * - * <ul> - * <li>{@link #IfNoneMatch} Server provides ETag header entry for all tiles - * and <b>supports</b> conditional download via <code>If-None-Match</code> - * header entry.</li> - * <li>{@link #ETag} Server provides ETag header entry for all tiles but - * <b>does not support</b> conditional download via - * <code>If-None-Match</code> header entry.</li> - * <li>{@link #IfModifiedSince} Server provides Last-Modified header entry - * for all tiles and <b>supports</b> conditional download via - * <code>If-Modified-Since</code> header entry.</li> - * <li>{@link #LastModified} Server provides Last-Modified header entry for - * all tiles but <b>does not support</b> conditional download via - * <code>If-Modified-Since</code> header entry.</li> - * <li>{@link #None} The server does not support any of the listed - * mechanisms.</li> - * </ul> - * - * @deprecated not used anymore - */ - @Deprecated - enum TileUpdate { - IfNoneMatch, ETag, IfModifiedSince, LastModified, None - } - - /** * Specifies the maximum zoom value. The number of zoom levels is [0.. * {@link #getMaxZoom()}]. * @@ -63,12 +35,6 @@ public interface TileSource extends Attributed { int getMinZoom(); /** - * @return The supported tile update mechanism - * @see TileUpdate - */ - TileUpdate getTileUpdate(); - - /** * A tile layer name as displayed to the user. * * @return Name of the tile layer @@ -130,26 +96,6 @@ public interface TileSource extends Attributed { double getDistance(double la1, double lo1, double la2, double lo2); /** - * Transform longitude to pixelspace. - * @param aLongitude longitude - * @param aZoomlevel zoom level - * @return [0..2^Zoomlevel*TILE_SIZE[ - * @deprecated use {@link #latLonToXY(double, double, int)} instead - */ - @Deprecated - int lonToX(double aLongitude, int aZoomlevel); - - /** - * Transforms latitude to pixelspace. - * @param aLat latitude - * @param aZoomlevel zoom level - * @return [0..2^Zoomlevel*TILE_SIZE[ - * @deprecated use {@link #latLonToXY(double, double, int)} instead - */ - @Deprecated - int latToY(double aLat, int aZoomlevel); - - /** * @param lon longitude * @param lat latitude * @param zoom zoom level @@ -165,26 +111,6 @@ public interface TileSource extends Attributed { Point latLonToXY(ICoordinate point, int zoom); /** - * Transforms pixel coordinate X to longitude - * @param aX X coordinate - * @param aZoomlevel zoom level - * @return ]-180..180[ - * @deprecated use {@link #xyToLatLon(int, int, int)} instead - */ - @Deprecated - double XToLon(int aX, int aZoomlevel); - - /** - * Transforms pixel coordinate Y to latitude. - * @param aY Y coordinate - * @param aZoomlevel zoom level - * @return [MIN_LAT..MAX_LAT] - * @deprecated use {@link #xyToLatLon(int, int, int)} instead - */ - @Deprecated - double YToLat(int aY, int aZoomlevel); - - /** * @param point point * @param zoom zoom level * @return WGS84 Coordinates of given point @@ -201,26 +127,6 @@ public interface TileSource extends Attributed { ICoordinate xyToLatLon(int x, int y, int zoom); /** - * Transforms longitude to X tile coordinate. - * @param lon longitude - * @param zoom zoom level - * @return [0..2^Zoomlevel[ - * @deprecated use {@link #latLonToTileXY(double, double, int)} instead - */ - @Deprecated - double lonToTileX(double lon, int zoom); - - /** - * Transforms latitude to Y tile coordinate. - * @param lat latitude - * @param zoom zoom level - * @return [0..2^Zoomlevel[ - * @deprecated use {@link #latLonToTileXY(double, double, int)} instead - */ - @Deprecated - double latToTileY(double lat, int zoom); - - /** * @param lon longitude * @param lat latitude * @param zoom zoom level @@ -237,26 +143,6 @@ public interface TileSource extends Attributed { TileXY latLonToTileXY(ICoordinate point, int zoom); /** - * Transforms tile X coordinate to longitude. - * @param x X coordinate - * @param zoom zoom level - * @return ]-180..180[ - * @deprecated use {@link #tileXYToLatLon(int, int, int)} instead - */ - @Deprecated - double tileXToLon(int x, int zoom); - - /** - * Transforms tile Y coordinate to latitude. - * @param y Y coordinate - * @param zoom zoom level - * @return [MIN_LAT..MAX_LAT] - * @deprecated use {@link #tileXYToLatLon(int, int, int)} instead - */ - @Deprecated - double tileYToLat(int y, int zoom); - - /** * @param xy X/Y coordinates * @param zoom zoom level * @return WGS84 coordinates of given tile diff --git a/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractMapQuestTileSource.java b/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractMapQuestTileSource.java index 5db7eca..cd2553c 100644 --- a/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractMapQuestTileSource.java +++ b/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractMapQuestTileSource.java @@ -11,7 +11,7 @@ import javax.xml.bind.DatatypeConverter; public class AbstractMapQuestTileSource extends AbstractOsmTileSource { // MapQuest logo in base64: http://developer.mapquest.com/content/osm/mq_logo.png - private static final String LOGO_BASE64 = + private static final String LOGO_BASE64 = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJl"+ "YWR5ccllPAAAAZtJREFUeNpi/P//P0PPcYf/DGSAEssDjIzdx+zJ0gwDLMQqVBWyZVAStGRgBMK33x8wnH62"+ "kngD+DmkGBwUshn42SXA/P8M/xg+/3rDcOPNPuIMMJeKAmv+8OMpw7ffHxikeLUZXBTzgez3DEzEGMDGzAmm"+ @@ -27,7 +27,7 @@ public class AbstractMapQuestTileSource extends AbstractOsmTileSource { protected static final String MAPQUEST_WEBSITE = "http://www.mapquest.com"; private static final int NUMBER_OF_SERVERS = 4; - + private int SERVER_NUM = 1; public AbstractMapQuestTileSource(String name, String base_url, String id) { @@ -42,11 +42,6 @@ public class AbstractMapQuestTileSource extends AbstractOsmTileSource { } @Override - public TileUpdate getTileUpdate() { - return TileUpdate.IfModifiedSince; - } - - @Override public Image getAttributionImage() { try { return ImageIO.read(new ByteArrayInputStream(DatatypeConverter.parseBase64Binary(LOGO_BASE64))); diff --git a/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java b/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java index a2d2582..b8a2683 100644 --- a/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java +++ b/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java @@ -128,16 +128,6 @@ public abstract class AbstractTMSTileSource extends AbstractTileSource { } @Override - public int lonToX(double lon, int zoom) { - return (int) osmMercator.lonToX(lon, zoom); - } - - @Override - public int latToY(double lat, int zoom) { - return (int) osmMercator.latToY(lat, zoom); - } - - @Override public Point latLonToXY(double lat, double lon, int zoom) { return new Point( (int) osmMercator.lonToX(lon, zoom), @@ -151,16 +141,6 @@ public abstract class AbstractTMSTileSource extends AbstractTileSource { } @Override - public double XToLon(int x, int zoom) { - return osmMercator.xToLon(x, zoom); - } - - @Override - public double YToLat(int y, int zoom) { - return osmMercator.yToLat(y, zoom); - } - - @Override public ICoordinate xyToLatLon(Point point, int zoom) { return xyToLatLon(point.x, point.y, zoom); } @@ -174,16 +154,6 @@ public abstract class AbstractTMSTileSource extends AbstractTileSource { } @Override - public double latToTileY(double lat, int zoom) { - return osmMercator.latToY(lat, zoom) / tileSize; - } - - @Override - public double lonToTileX(double lon, int zoom) { - return osmMercator.lonToX(lon, zoom) / tileSize; - } - - @Override public TileXY latLonToTileXY(double lat, double lon, int zoom) { return new TileXY( osmMercator.lonToX(lon, zoom) / tileSize, @@ -197,16 +167,6 @@ public abstract class AbstractTMSTileSource extends AbstractTileSource { } @Override - public double tileYToLat(int y, int zoom) { - return osmMercator.yToLat(y * tileSize, zoom); - } - - @Override - public double tileXToLon(int x, int zoom) { - return osmMercator.xToLon(x * tileSize, zoom); - } - - @Override public ICoordinate tileXYToLatLon(TileXY xy, int zoom) { return tileXYToLatLon(xy.getXIndex(), xy.getYIndex(), zoom); } diff --git a/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java b/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java index 0f4887e..2a24961 100644 --- a/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java +++ b/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java @@ -11,8 +11,8 @@ import java.util.List; import java.util.Locale; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executors; import java.util.concurrent.Future; +import java.util.concurrent.FutureTask; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.regex.Pattern; @@ -172,11 +172,6 @@ public class BingAerialTileSource extends AbstractTMSTileSource { } @Override - public TileUpdate getTileUpdate() { - return TileUpdate.IfNoneMatch; - } - - @Override public boolean requiresAttribution() { return true; } @@ -256,12 +251,14 @@ public class BingAerialTileSource extends AbstractTMSTileSource { // see http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html synchronized (BingAerialTileSource.class) { if (attributions == null) { - attributions = Executors.newSingleThreadExecutor().submit(getAttributionLoaderCallable()); + final FutureTask<List<Attribution>> loader = new FutureTask<>(getAttributionLoaderCallable()); + new Thread(loader, "bing-attribution-loader").start(); + attributions = loader; } } } try { - return attributions.get(1000, TimeUnit.MILLISECONDS); + return attributions.get(10, TimeUnit.MILLISECONDS); } catch (TimeoutException ex) { System.err.println("Bing: attribution data is not yet loaded."); } catch (ExecutionException ex) { diff --git a/src/org/openstreetmap/gui/jmapviewer/tilesources/OsmTileSource.java b/src/org/openstreetmap/gui/jmapviewer/tilesources/OsmTileSource.java index 99adb0c..0188bad 100644 --- a/src/org/openstreetmap/gui/jmapviewer/tilesources/OsmTileSource.java +++ b/src/org/openstreetmap/gui/jmapviewer/tilesources/OsmTileSource.java @@ -30,11 +30,6 @@ public class OsmTileSource { serverNum = (serverNum + 1) % SERVER.length; return url; } - - @Override - public TileUpdate getTileUpdate() { - return TileUpdate.IfNoneMatch; - } } /** @@ -66,10 +61,5 @@ public class OsmTileSource { public int getMaxZoom() { return 18; } - - @Override - public TileUpdate getTileUpdate() { - return TileUpdate.LastModified; - } } } diff --git a/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java b/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java index 0dce239..e535231 100644 --- a/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java +++ b/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java @@ -92,29 +92,6 @@ public class ScanexTileSource extends TMSTileSource { return this.layer.getUri() + "&apikey=" + API_KEY + "&x=" + tilex + "&y=" + tiley + "&z=" + zoom; } - @Override - public int latToY(double lat, int zoom) { - return (int) (latToTileY(lat, zoom) * tileSize); - } - - @Override - public double YToLat(int y, int zoom) { - return tileYToLat((double) y / tileSize, zoom); - } - - @Override - public double latToTileY(double lat, int zoom) { - double tmp = Math.tan(Math.PI/4 * (1 + lat/90)); - double pow = Math.pow(Math.tan(Math.PI/4 + Math.asin(E * Math.sin(Math.toRadians(lat)))/2), E); - - return (EQUATOR/2 - (RADIUS_E * Math.log(tmp/pow))) * Math.pow(2.0, zoom) / EQUATOR; - } - - @Override - public double tileYToLat(int y, int zoom) { - return tileYToLat((double) y, zoom); - } - /* * To solve inverse formula latitude = f(y) we use * Newton's method. We cache previous calculated latitude, diff --git a/src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java b/src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java index 66673de..d224240 100644 --- a/src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java +++ b/src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java @@ -22,9 +22,4 @@ public class TMSTileSource extends AbstractTMSTileSource { public int getMaxZoom() { return (maxZoom == 0) ? super.getMaxZoom() : maxZoom; } - - @Override - public TileUpdate getTileUpdate() { - return TileUpdate.IfNoneMatch; - } } -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/jmapviewer.git _______________________________________________ Pkg-grass-devel mailing list Pkg-grass-devel@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel