[jmapviewer] 01/05: Imported Upstream version 2.2+dfsg

Bas Couwenberg sebastic at debian.org
Sun May 28 07:46:55 UTC 2017


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository jmapviewer.

commit f5ea5bcb854c1ec1ab29fa10dcb7ecfcac1cf9ca
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Sun May 28 09:23:55 2017 +0200

    Imported Upstream version 2.2+dfsg
---
 .../gui/jmapviewer/AttributionSupport.java         |  4 ++
 .../openstreetmap/gui/jmapviewer/JMapViewer.java   |  4 +-
 .../jmapviewer/tilesources/AbstractTileSource.java |  3 +-
 .../gui/jmapviewer/tilesources/OsmTileSource.java  | 61 ++++++++++++++++++++++
 .../jmapviewer/tilesources/ScanexTileSource.java   | 10 ++--
 .../gui/jmapviewer/tilesources/TMSTileSource.java  |  4 +-
 6 files changed, 77 insertions(+), 9 deletions(-)

diff --git a/src/org/openstreetmap/gui/jmapviewer/AttributionSupport.java b/src/org/openstreetmap/gui/jmapviewer/AttributionSupport.java
index d038e25..f911a51 100644
--- a/src/org/openstreetmap/gui/jmapviewer/AttributionSupport.java
+++ b/src/org/openstreetmap/gui/jmapviewer/AttributionSupport.java
@@ -101,6 +101,10 @@ public class AttributionSupport {
 
         g.setFont(ATTR_FONT);
         String attributionText = source.getAttributionText(zoom, topLeft, bottomRight);
+        if (attributionText == null) {
+            // In case attribution text has been forgotte, display URL
+            attributionText = source.getAttributionLinkURL();
+        }
         if (attributionText != null) {
             Rectangle2D stringBounds = g.getFontMetrics().getStringBounds(attributionText, g);
             int textHeight = (int) stringBounds.getHeight() - 5;
diff --git a/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java b/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java
index a384cb5..9f7988a 100644
--- a/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java
+++ b/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java
@@ -44,6 +44,8 @@ import org.openstreetmap.gui.jmapviewer.tilesources.OsmTileSource;
  */
 public class JMapViewer extends JPanel implements TileLoaderListener {
 
+    private static final long serialVersionUID = 1L;
+
     /** whether debug mode is enabled or not */
     public static boolean debug;
 
@@ -502,7 +504,7 @@ public class JMapViewer extends JPanel implements TileLoaderListener {
             return (int) marker.getRadius();
         else if (p != null) {
             Integer radius = getLatOffset(marker.getLat(), marker.getLon(), marker.getRadius(), false);
-            radius = radius == null ? null : p.y - radius.intValue();
+            radius = radius == null ? null : p.y - radius;
             return radius;
         } else
             return null;
diff --git a/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTileSource.java b/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTileSource.java
index 185eb04..ae16836 100644
--- a/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTileSource.java
+++ b/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTileSource.java
@@ -19,7 +19,8 @@ public abstract class AbstractTileSource implements TileSource {
 
     @Override
     public boolean requiresAttribution() {
-        return attributionText != null || attributionImage != null || termsOfUseText != null || termsOfUseURL != null;
+        return attributionText != null || attributionLinkURL != null || attributionImage != null
+                || termsOfUseText != null || termsOfUseURL != null;
     }
 
     @Override
diff --git a/src/org/openstreetmap/gui/jmapviewer/tilesources/OsmTileSource.java b/src/org/openstreetmap/gui/jmapviewer/tilesources/OsmTileSource.java
index 7c592a0..e407e5b 100644
--- a/src/org/openstreetmap/gui/jmapviewer/tilesources/OsmTileSource.java
+++ b/src/org/openstreetmap/gui/jmapviewer/tilesources/OsmTileSource.java
@@ -1,6 +1,10 @@
 // License: GPL. For details, see Readme.txt file.
 package org.openstreetmap.gui.jmapviewer.tilesources;
 
+import java.io.IOException;
+
+import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate;
+
 /**
  * OSM Tile source.
  */
@@ -62,4 +66,61 @@ public class OsmTileSource {
             return 18;
         }
     }
+
+    /**
+     * The "Transport Map" OSM tile source.
+     *
+     * Template for thunderforest.com.
+     */
+    public abstract static class TransportMap extends AbstractOsmTileSource {
+
+        private static final String PATTERN = "https://%s.tile.thunderforest.com/transport";
+
+        private static final String[] SERVER = {"a", "b", "c"};
+
+        private int serverNum;
+
+        /**
+         * Constructs a new {@code TransportMap} tile source.
+         */
+        public TransportMap() {
+            super("OSM Transport Map", PATTERN, "osmtransportmap");
+        }
+
+        /**
+         * Get the thunderforest API key.
+         *
+         * Needs to be registered at their web site.
+         * @return the API key
+         */
+        protected abstract String getApiKey();
+
+        @Override
+        public String getBaseUrl() {
+            String url = String.format(this.baseUrl, new Object[] {SERVER[serverNum]});
+            serverNum = (serverNum + 1) % SERVER.length;
+            return url;
+        }
+
+        @Override
+        public int getMaxZoom() {
+            return 18;
+        }
+
+        @Override
+        public String getTileUrl(int zoom, int tilex, int tiley) throws IOException {
+            return this.getBaseUrl() + getTilePath(zoom, tilex, tiley) + "?apikey=" + getApiKey();
+        }
+
+        @Override
+        public String getAttributionText(int zoom, ICoordinate topLeft, ICoordinate botRight) {
+            return "Maps © Thunderforest, Data © OpenStreetMap contributors";
+        }
+
+        @Override
+        public String getAttributionLinkURL() {
+            return "http://www.thunderforest.com/";
+        }
+    }
+
 }
diff --git a/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java b/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java
index 25b5f1d..5b9825e 100644
--- a/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java
+++ b/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java
@@ -109,15 +109,15 @@ public class ScanexTileSource extends TMSTileSource {
     }
 
     // Latitude to Y and back calculations.
-    private static double RADIUS_E = 6378137;   /* radius of Earth at equator, m */
-    private static double EQUATOR = 40075016.68557849; /* equator length, m */
-    private static double E = 0.0818191908426;  /* eccentricity of Earth's ellipsoid */
+    private static final double RADIUS_E = 6378137;   /* radius of Earth at equator, m */
+    private static final double EQUATOR = 40075016.68557849; /* equator length, m */
+    private static final double E = 0.0818191908426;  /* eccentricity of Earth's ellipsoid */
 
     @Override
     public Point latLonToXY(double lat, double lon, int zoom) {
         return new Point(
-                (int) osmMercator.lonToX(lon, zoom),
-                (int) latToTileY(lat, zoom)
+                (int) Math.round(osmMercator.lonToX(lon, zoom)),
+                (int) Math.round(latToTileY(lat, zoom))
                 );
     }
 
diff --git a/src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java b/src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java
index 975ef33..f9bb6b7 100644
--- a/src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java
+++ b/src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java
@@ -50,8 +50,8 @@ public class TMSTileSource extends AbstractTMSTileSource {
     @Override
     public Point latLonToXY(double lat, double lon, int zoom) {
         return new Point(
-                (int) osmMercator.lonToX(lon, zoom),
-                (int) osmMercator.latToY(lat, zoom)
+                (int) Math.round(osmMercator.lonToX(lon, zoom)),
+                (int) Math.round(osmMercator.latToY(lat, zoom))
                 );
     }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/jmapviewer.git



More information about the Pkg-grass-devel mailing list