[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: jmapviewer: Download bing logo via attribution XML at runtime?



On 10/20/2014 11:17 PM, Felix Natter wrote:
> Felix Natter <fnatter@gmx.net> writes:
>> => I think we need to investigate that for jessie+1, but now I think we
>> should parse the "attribution data" and use the included link to
>> download the logo at runtime (many thanks to the patch [1] from Marcus
>> Lundblad <ml@update.uu.se> and Martin Krüger <martin.krueger@gmx.com>)?
>> We should really agree on something now ;-)
> 
> --> Can we all agree on this solution for jessie?
> (which is probably legal if JMapViewer itself is legal)
> 
> I'd suggest to apply this patch now to make sure it's fixed for jessie!

Yes, until we hear otherwise it seems to me the best solution to the
Bing logo license problem.

I've cleaned up the patch a little and added DEP3 headers for inclusion
in the jmapviewer package. When the patch is forwarded upstream we have
a nice opportunity to get the upstream point of view on this issue.

Kind Regards,

Bas

-- 
 GPG Key ID: 4096R/E88D4AF1
Fingerprint: 8182 DE41 7056 408D 6146  50D1 6750 F10A E88D 4AF1

Description: Download the Bing logo when it's not installed.
 The Bing logo is required for attribution when using the imagery, but the
 license terms covering the image are unclear. JMapViewer is licesed under
 the GPL, but the Bing logo is mostly likely not.
 .
 To not require the inclusion of the bing_maps.png file in the jmapviewer
 package, the image is downloaded using the URL provided in the BrandLogoUri
 attribute of the attribution response.
 .
Author: Marcus Lundblad <ml@update.uu.se> & Martin Krüger <martin.krueger@gmx.com>
Bug-Debian: https://bugs.debian.org/765421

--- a/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java
+++ b/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java
@@ -3,6 +3,7 @@ package org.openstreetmap.gui.jmapviewer
 
 import java.awt.Image;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
@@ -45,6 +46,7 @@ public class BingAerialTileSource extend
     private static final Pattern subdomainPattern = Pattern.compile("\\{subdomain\\}");
     private static final Pattern quadkeyPattern = Pattern.compile("\\{quadkey\\}");
     private static final Pattern culturePattern = Pattern.compile("\\{culture\\}");
+    private String BrandLogoUri = null;
 
     public BingAerialTileSource() {
         super("Bing Aerial Maps", "http://example.com/";);
@@ -97,6 +99,9 @@ public class BingAerialTileSource extend
                 subdomains[i] = subdomainTxt.item(i).getNodeValue();
             }
 
+            XPathExpression BrandLogoUriXpath = xpath.compile("/Response/BrandLogoUri/text()");
+            this.BrandLogoUri = BrandLogoUriXpath.evaluate(document);
+
             XPathExpression attributionXpath = xpath.compile("Attribution/text()");
             XPathExpression coverageAreaXpath = xpath.compile("CoverageArea");
             XPathExpression zoomMinXpath = xpath.compile("ZoomMin/text()");
@@ -173,8 +178,17 @@ public class BingAerialTileSource extend
 
     @Override
     public Image getAttributionImage() {
+	for( int i=0 ; i<5 && getAttribution()==null ; i++ ) ;
         try {
-            return ImageIO.read(JMapViewer.class.getResourceAsStream("images/bing_maps.png"));
+            final InputStream imageResource = JMapViewer.class.getResourceAsStream("images/bing_maps.png");
+            if (imageResource != null) {
+                return ImageIO.read(imageResource);
+            } else {
+                if (this.BrandLogoUri != null)
+                    return ImageIO.read(new URL(this.BrandLogoUri));
+                else
+                    return null;
+            }
         } catch (IOException e) {
             return null;
         }

Reply to: