Thanks for your patch. Now we have code for two possible solutions to
our problem.

Ideally the logo URL is not hardcoded but extracted from the attribution
response. If the service changes the URL the code doesn't need changing.

Is it possible to implement that in your patch?

Kind Regards,

Bas

I extendet the patch from Marcus Lundblad pulling the image from the URL provided in the attribution-xml:


diff -r fea61f11732a src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java --- a/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java Sat Oct 18 15:48:00 2014 +0200 +++ b/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java Sat Oct 18 15:48:43 2014 +0200
@@ -3,6 +3,7 @@

 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 @@
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/";);
@@ -96,6 +98,12 @@
             for(int i = 0; i < subdomainTxt.getLength(); i++) {
                 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");
@@ -173,11 +181,21 @@

     @Override
     public Image getAttributionImage() {
-        try {
- return ImageIO.read(JMapViewer.class.getResourceAsStream("images/bing_maps.png"));
-        } catch (IOException e) {
-            return null;
-        }
+        for( int i=0 ; i<5 && getAttribution()==null ;i++ ) ;
+        try {
+            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;
+        }
     }

     @Override



Works fine for me.

Best regards
     martin


--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to