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

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Tue May 31 19:56:18 UTC 2016


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

sebastic pushed a commit to branch master
in repository jmapviewer.

commit d063eeae5a3827168cc5aedc813c3368c09aabb4
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Mon May 30 23:16:14 2016 +0200

    Imported Upstream version 1.16+dfsg
---
 build.xml                                          |  2 +-
 .../openstreetmap/gui/jmapviewer/JMapViewer.java   | 15 ++++++++-----
 .../gui/jmapviewer/MemoryTileCache.java            |  2 +-
 .../gui/jmapviewer/OsmTileLoader.java              |  2 +-
 src/org/openstreetmap/gui/jmapviewer/Tile.java     |  2 +-
 .../tilesources/AbstractTMSTileSource.java         |  2 +-
 .../tilesources/BingAerialTileSource.java          | 26 ++++++++++++----------
 7 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/build.xml b/build.xml
index b13ba03..9370d4e 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.16-all.jar"/>
+        	classpath="tools/checkstyle/checkstyle-6.19-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 91f43fc..d1993d4 100644
--- a/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java
+++ b/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java
@@ -9,6 +9,7 @@ import java.awt.Point;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.MouseEvent;
+import java.net.URL;
 import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
@@ -169,10 +170,11 @@ public class JMapViewer extends JPanel implements TileLoaderListener {
         zoomSlider.setFocusable(false);
         add(zoomSlider);
         int size = 18;
-        try {
-            ImageIcon icon = new ImageIcon(JMapViewer.class.getResource("images/plus.png"));
+        URL url = JMapViewer.class.getResource("images/plus.png");
+        if (url != null) {
+            ImageIcon icon = new ImageIcon(url);
             zoomInButton = new JButton(icon);
-        } catch (Exception e) {
+        } else {
             zoomInButton = new JButton("+");
             zoomInButton.setFont(new Font("sansserif", Font.BOLD, 9));
             zoomInButton.setMargin(new Insets(0, 0, 0, 0));
@@ -187,10 +189,11 @@ public class JMapViewer extends JPanel implements TileLoaderListener {
         });
         zoomInButton.setFocusable(false);
         add(zoomInButton);
-        try {
-            ImageIcon icon = new ImageIcon(JMapViewer.class.getResource("images/minus.png"));
+        url = JMapViewer.class.getResource("images/minus.png");
+        if (url != null) {
+            ImageIcon icon = new ImageIcon(url);
             zoomOutButton = new JButton(icon);
-        } catch (Exception e) {
+        } else {
             zoomOutButton = new JButton("-");
             zoomOutButton.setFont(new Font("sansserif", Font.BOLD, 9));
             zoomOutButton.setMargin(new Insets(0, 0, 0, 0));
diff --git a/src/org/openstreetmap/gui/jmapviewer/MemoryTileCache.java b/src/org/openstreetmap/gui/jmapviewer/MemoryTileCache.java
index bdb2e13..e194a43 100644
--- a/src/org/openstreetmap/gui/jmapviewer/MemoryTileCache.java
+++ b/src/org/openstreetmap/gui/jmapviewer/MemoryTileCache.java
@@ -77,7 +77,7 @@ public class MemoryTileCache implements TileCache {
             while (lruTiles.getElementCount() > cacheSize) {
                 removeEntry(lruTiles.getLastElement());
             }
-        } catch (Exception e) {
+        } catch (NullPointerException e) {
             log.warning(e.getMessage());
         }
     }
diff --git a/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java b/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java
index 02c451e..c7ab9a2 100644
--- a/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java
+++ b/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java
@@ -61,7 +61,7 @@ public class OsmTileLoader implements TileLoader {
                 }
                 tile.setLoaded(true);
                 listener.tileLoadingFinished(tile, true);
-            } catch (Exception e) {
+            } catch (IOException e) {
                 tile.setError(e.getMessage());
                 listener.tileLoadingFinished(tile, false);
                 if (input == null) {
diff --git a/src/org/openstreetmap/gui/jmapviewer/Tile.java b/src/org/openstreetmap/gui/jmapviewer/Tile.java
index 7233bd7..67c8c1e 100644
--- a/src/org/openstreetmap/gui/jmapviewer/Tile.java
+++ b/src/org/openstreetmap/gui/jmapviewer/Tile.java
@@ -81,7 +81,7 @@ public class Tile {
     private static BufferedImage loadImage(String path) {
         try {
             return ImageIO.read(JMapViewer.class.getResourceAsStream(path));
-        } catch (Exception ex) {
+        } catch (IOException | IllegalArgumentException ex) {
             ex.printStackTrace();
             return null;
         }
diff --git a/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java b/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java
index 38afc21..98c7e82 100644
--- a/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java
+++ b/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java
@@ -185,7 +185,7 @@ public abstract class AbstractTMSTileSource extends AbstractTileSource {
                 }
             }
         }
-        if (noTileChecksums != null) {
+        if (noTileChecksums != null && content != null) {
             for (Entry<String, Set<String>> searchEntry: noTileChecksums.entrySet()) {
                 MessageDigest md = null;
                 try {
diff --git a/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java b/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java
index 98f32cc..534d93e 100644
--- a/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java
+++ b/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java
@@ -36,6 +36,10 @@ import org.w3c.dom.NodeList;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
+/**
+ * Tile source for the Bing Maps REST Imagery API.
+ * @see <a href="https://msdn.microsoft.com/en-us/library/ff701724.aspx">MSDN</a>
+ */
 public class BingAerialTileSource extends TMSTileSource {
 
     private static final String API_KEY = "Arzdiw4nlOJzRwOz__qailc8NiR31Tt51dN2D7cm57NrnceZnCpgOkmJhNpGoppU";
@@ -65,7 +69,7 @@ public class BingAerialTileSource extends TMSTileSource {
     }
 
     protected static class Attribution {
-        private String attribution;
+        private String attributionText;
         private int minZoom;
         private int maxZoom;
         private Coordinate min;
@@ -101,8 +105,7 @@ public class BingAerialTileSource extends TMSTileSource {
 
             XPathFactory xPathFactory = XPathFactory.newInstance();
             XPath xpath = xPathFactory.newXPath();
-            imageUrlTemplate = xpath.compile("//ImageryMetadata/ImageUrl/text()").evaluate(document);
-            imageUrlTemplate = imageUrlTemplate.replace(
+            imageUrlTemplate = xpath.compile("//ImageryMetadata/ImageUrl/text()").evaluate(document).replace(
                     "http://ecn.{subdomain}.tiles.virtualearth.net/",
                     "https://ecn.{subdomain}.tiles.virtualearth.net/");
             imageUrlTemplate = culturePattern.matcher(imageUrlTemplate).replaceAll(Locale.getDefault().toString());
@@ -128,7 +131,7 @@ public class BingAerialTileSource extends TMSTileSource {
 
             NodeList imageryProviderNodes = (NodeList) xpath.compile("//ImageryMetadata/ImageryProvider")
                     .evaluate(document, XPathConstants.NODESET);
-            List<Attribution> attributions = new ArrayList<>(imageryProviderNodes.getLength());
+            List<Attribution> attributionsList = new ArrayList<>(imageryProviderNodes.getLength());
             for (int i = 0; i < imageryProviderNodes.getLength(); i++) {
                 Node providerNode = imageryProviderNodes.item(i);
 
@@ -138,7 +141,7 @@ public class BingAerialTileSource extends TMSTileSource {
                 for (int j = 0; j < coverageAreaNodes.getLength(); j++) {
                     Node areaNode = coverageAreaNodes.item(j);
                     Attribution attr = new Attribution();
-                    attr.attribution = attribution;
+                    attr.attributionText = attribution;
 
                     attr.maxZoom = Integer.parseInt(zoomMaxXpath.evaluate(areaNode));
                     attr.minZoom = Integer.parseInt(zoomMinXpath.evaluate(areaNode));
@@ -150,11 +153,11 @@ public class BingAerialTileSource extends TMSTileSource {
                     attr.min = new Coordinate(southLat, westLon);
                     attr.max = new Coordinate(northLat, eastLon);
 
-                    attributions.add(attr);
+                    attributionsList.add(attr);
                 }
             }
 
-            return attributions;
+            return attributionsList;
         } catch (SAXException e) {
             System.err.println("Could not parse Bing aerials attribution metadata.");
             e.printStackTrace();
@@ -181,10 +184,9 @@ public class BingAerialTileSource extends TMSTileSource {
 
     @Override
     public String getAttributionLinkURL() {
-        //return "http://bing.com/maps"
-        // FIXME: I've set attributionLinkURL temporarily to ToU URL to comply with bing ToU
+        // Terms of Use URL to comply with Bing Terms of Use
         // (the requirement is that we have such a link at the bottom of the window)
-        return "http://go.microsoft.com/?linkid=9710837";
+        return "https://www.microsoft.com/maps/assets/docs/terms.aspx";
     }
 
     @Override
@@ -283,13 +285,13 @@ public class BingAerialTileSource extends TMSTileSource {
                 if (zoom <= attr.maxZoom && zoom >= attr.minZoom) {
                     if (topLeft.getLon() < attr.max.getLon() && botRight.getLon() > attr.min.getLon()
                             && topLeft.getLat() > attr.min.getLat() && botRight.getLat() < attr.max.getLat()) {
-                        a.append(attr.attribution);
+                        a.append(attr.attributionText);
                         a.append(' ');
                     }
                 }
             }
             return a.toString();
-        } catch (Exception e) {
+        } catch (RuntimeException e) {
             e.printStackTrace();
         }
         return "Error loading Bing attribution data";

-- 
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