- Timestamp:
- 2017-02-02T18:52:17+01:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r11461 r11527 107 107 108 108 private static final String[] OBSOLETE_PREF_KEYS = { 109 "hdop.factor" /* remove entry after April 2017 */ 109 "hdop.factor", /* remove entry after April 2017 */ 110 "imagery.layers.addedIds" /* remove entry after June 2017 */ 110 111 }; 111 112 -
trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java
r11347 r11527 1033 1033 */ 1034 1034 public void setNoTileHeaders(MultiMap<String, String> noTileHeaders) { 1035 if (noTileHeaders == null ) {1035 if (noTileHeaders == null || noTileHeaders.isEmpty()) { 1036 1036 this.noTileHeaders = null; 1037 1037 } else { … … 1053 1053 */ 1054 1054 public void setNoTileChecksums(MultiMap<String, String> noTileChecksums) { 1055 if (noTileChecksums == null ) {1055 if (noTileChecksums == null || noTileChecksums.isEmpty()) { 1056 1056 this.noTileChecksums = null; 1057 1057 } else { … … 1073 1073 */ 1074 1074 public void setMetadataHeaders(Map<String, String> metadataHeaders) { 1075 this.metadataHeaders = metadataHeaders; 1075 if (metadataHeaders == null || metadataHeaders.isEmpty()) { 1076 this.metadataHeaders = null; 1077 } else { 1078 this.metadataHeaders = metadataHeaders; 1079 } 1076 1080 } 1077 1081 -
trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java
r11385 r11527 170 170 updateEntriesFromDefaults(); 171 171 buildIdMap(layers, layerIds); 172 dropOldEntries(); 172 173 } 173 174 } … … 232 233 Main.pref.putCollection("imagery.layers.default", newKnownDefaults); 233 234 234 // Add ids to user entries without id.235 // Only do this the first time for each id, so the user can have236 // custom entries that don't get updated automatically237 Collection<String> addedIds = Main.pref.getCollection("imagery.layers.addedIds");238 Collection<String> newAddedIds = new TreeSet<>(addedIds);239 for (ImageryInfo info : layers) {240 for (ImageryInfo def : defaultLayers) {241 if (isSimilar(def, info) && def.getId() != null && !addedIds.contains(def.getId())) {242 if (!defaultLayerIds.containsKey(def.getId())) {243 // ignore ids used more than once (have been purged from the map)244 continue;245 }246 newAddedIds.add(def.getId());247 if (info.getId() == null) {248 info.setId(def.getId());249 changed = true;250 }251 }252 }253 }254 Main.pref.putCollection("imagery.layers.addedIds", newAddedIds);255 256 235 // automatically update user entries with same id as a default entry 257 236 for (int i = 0; i < layers.size(); i++) { … … 263 242 if (matchingDefault != null && !matchingDefault.equalsPref(info)) { 264 243 layers.set(i, matchingDefault); 244 Main.info(tr("Update imagery ''{0}''", info.getName())); 265 245 changed = true; 266 246 } … … 268 248 269 249 if (changed) { 250 save(); 251 } 252 } 253 254 /** 255 * Drop entries with Id which do no longer exist (removed from defaults). 256 */ 257 public void dropOldEntries() { 258 List<String> drop = new ArrayList<>(); 259 260 for (Map.Entry<String, ImageryInfo> info : layerIds.entrySet()) { 261 if (!defaultLayerIds.containsKey(info.getKey())) { 262 remove(info.getValue()); 263 drop.add(info.getKey()); 264 Main.info(tr("Drop old imagery ''{0}''", info.getValue().getName())); 265 } 266 } 267 268 if (!drop.isEmpty()) { 269 for (String id : drop) { 270 layerIds.remove(id); 271 } 270 272 save(); 271 273 }
Note:
See TracChangeset
for help on using the changeset viewer.