Changeset 30758 in osm
- Timestamp:
- 2014-10-21T02:54:10+02:00 (10 years ago)
- Location:
- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java
r30426 r30758 4 4 import java.awt.Image; 5 5 import java.io.IOException; 6 import java.io.InputStream; 6 7 import java.net.MalformedURLException; 7 8 import java.net.URL; … … 46 47 private static final Pattern quadkeyPattern = Pattern.compile("\\{quadkey\\}"); 47 48 private static final Pattern culturePattern = Pattern.compile("\\{culture\\}"); 48 49 private String brandLogoUri = null; 50 51 /** 52 * Constructs a new {@code BingAerialTileSource}. 53 */ 49 54 public BingAerialTileSource() { 50 55 super("Bing Aerial Maps", "http://example.com/"); … … 97 102 subdomains[i] = subdomainTxt.item(i).getNodeValue(); 98 103 } 104 105 brandLogoUri = xpath.compile("/Response/BrandLogoUri/text()").evaluate(document); 99 106 100 107 XPathExpression attributionXpath = xpath.compile("Attribution/text()"); … … 175 182 public Image getAttributionImage() { 176 183 try { 177 return ImageIO.read(JMapViewer.class.getResourceAsStream("images/bing_maps.png")); 184 final InputStream imageResource = JMapViewer.class.getResourceAsStream("images/bing_maps.png"); 185 if (imageResource != null) { 186 return ImageIO.read(imageResource); 187 } else { 188 // Some Linux distributions (like Debian) will remove Bing logo from sources, so get it at runtime 189 for (int i = 0; i < 5 && getAttribution() == null; i++) { 190 // Makes sure attribution is loaded 191 } 192 if (brandLogoUri != null && !brandLogoUri.isEmpty()) { 193 System.out.println("Reading Bing logo from "+brandLogoUri); 194 return ImageIO.read(new URL(brandLogoUri)); 195 } 196 } 178 197 } catch (IOException e) { 179 return null; 180 } 198 System.err.println("Error while retrieving Bing logo: "+e.getMessage()); 199 } 200 return null; 181 201 } 182 202
Note:
See TracChangeset
for help on using the changeset viewer.