Ticket #23913: 23913.2.patch
File 23913.2.patch, 3.2 KB (added by , 5 weeks ago) |
---|
-
src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java
43 43 if (baseUrl != null && baseUrl.endsWith("/")) { 44 44 baseUrl = baseUrl.substring(0, baseUrl.length()-1); 45 45 } 46 this.id = info.get Url();46 this.id = info.getId(); 47 47 this.noTileHeaders = info.getNoTileHeaders(); 48 48 this.noTileChecksums = info.getNoTileChecksums(); 49 49 this.metadataHeaders = info.getMetadataHeaders(); -
src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java
80 80 * Constructs a new {@code BingAerialTileSource}. 81 81 */ 82 82 public BingAerialTileSource() { 83 super(new TileSourceInfo("Bing", null, null));83 super(new TileSourceInfo("Bing", null, "Bing")); 84 84 minZoom = 1; 85 85 } 86 86 … … 131 131 protected URL getAttributionUrl() throws MalformedURLException { 132 132 try { 133 133 return new URI(FeatureAdapter.getSetting(METADATA_API_SETTING, METADATA_API_URL) 134 .replace(API_KEY_PLACEHOLDER, FeatureAdapter.getSetting(API_KEY_SETTING, API_KEY))134 .replace(API_KEY_PLACEHOLDER, getKey()) 135 135 .replace(API_KEY_LAYER, this.layer)).toURL(); 136 136 } catch (URISyntaxException e) { 137 137 MalformedURLException malformedURLException = new MalformedURLException(e.getMessage()); … … 140 140 } 141 141 } 142 142 143 /** 144 * Get the API key for Bing imagery 145 * Order of preference is as follows: 146 * <ol> 147 * <li>Custom API key provided by {@link FeatureAdapter#getSetting(String, String)} via {@link #API_KEY_SETTING}</li> 148 * <li>API key provided by {@link FeatureAdapter#retrieveApiKey(String)}</li> 149 * <li>The hardcoded API key. This should not be used whenever possible.</li> 150 * </ol> 151 * @return The API key to use 152 */ 153 private String getKey() { 154 // Preference order for key 155 // 1. Custom API key 156 // 2. Remote API key 157 // 3. Hardcoded API key 158 final String customKey = FeatureAdapter.getSetting(API_KEY_SETTING, API_KEY); 159 String key; 160 try { 161 key = FeatureAdapter.retrieveApiKey(this.getId()); 162 if (!API_KEY.equals(customKey)) { 163 key = customKey; 164 } 165 } catch (IOException ioException) { 166 FeatureAdapter.getLogger(this.getClass()).log(Level.WARNING, "Failed to retrieve api key", ioException); 167 key = customKey; 168 } 169 return key; 170 } 171 143 172 protected List<Attribution> parseAttributionText(InputSource xml) throws IOException { 144 173 try { 145 174 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();