Changeset 13536 in josm
- Timestamp:
- 2018-03-17T17:01:12+01:00 (7 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/data/maps.xsd
r13284 r13536 20 20 <!-- exclude white space characters and characters that are not valid for file names in Windows --> 21 21 <xs:restriction base="xs:string"> 22 <xs:pattern value='[^\s/\\:*?"<>| ]+' />22 <xs:pattern value='[^\s/\\:*?"<>|,;]+' /> 23 23 </xs:restriction> 24 24 </xs:simpleType> 25 26 <xs:complexType name="oldid"> 27 <xs:simpleContent> 28 <xs:extension base="tns:id"> 29 <!-- date of the retirement of this ID --> 30 <xs:attribute name="date" type="xs:date" use="required" /> 31 </xs:extension> 32 </xs:simpleContent> 33 </xs:complexType> 25 34 26 35 <xs:simpleType name="type"> … … 623 632 <!-- A unique id for the imagery source --> 624 633 <xs:element name="id" minOccurs="0" maxOccurs="1" type="tns:id" /> 634 <!-- Historic id for the imagery source --> 635 <xs:element name="oldid" minOccurs="0" maxOccurs="unbounded" type="tns:oldid" /> 625 636 <!-- The type. Can be tms, wms and html. In addition, there are the special types bing and scanex 626 637 with hardcoded behaviour. --> … … 666 677 <xs:all> 667 678 <xs:element name="type" minOccurs="1" maxOccurs="1" type="tns:type" /> 679 <xs:element name="id" minOccurs="0" maxOccurs="1" type="tns:id" /> 668 680 <xs:element name="url" minOccurs="1" maxOccurs="1" type="xs:string" /> 669 681 <xs:element name="projections" minOccurs="0" maxOccurs="1" type="tns:projections" /> … … 707 719 <xs:attribute name="last-check" type="xs:date" use="optional" /> 708 720 <xs:attribute name="eli-best" type="xs:boolean" use="optional" /> 721 <xs:attribute name="overlay" type="xs:boolean" use="optional" /> 709 722 </xs:complexType> 710 723 </xs:element> -
trunk/scripts/SyncEditorLayerIndex.groovy
r13533 r13536 272 272 stream.write "<imagery xmlns=\"http://josm.openstreetmap.de/maps-1.0\">\n" 273 273 for (def e : entries) { 274 def best = "eli-best".equals(getQuality(e)) 275 stream.write " <entry"+(best ? " eli-best=\"true\"" : "" )+">\n" 274 stream.write(" <entry" 275 + ("eli-best".equals(getQuality(e)) ? " eli-best=\"true\"" : "" ) 276 + (getOverlay(e) ? " overlay=\"true\"" : "" ) 277 + ">\n") 276 278 stream.write " <name>${cdata(getName(e), true)}</name>\n" 277 279 stream.write " <id>${getId(e)}</id>\n" … … 608 610 } 609 611 } 612 et = getOverlay(e) 613 jt = getOverlay(j) 614 if (!et.equals(jt)) { 615 if (!jt) { 616 myprintln "! Missing JOSM overlay flag: ${getDescription(j)}" 617 } else if (!options.nomissingeli) { 618 myprintln "+ Missing ELI overlay flag: ${getDescription(j)}" 619 } 620 } 610 621 } 611 622 myprintln "*** Mismatching shapes: ***" … … 936 947 && e.get("properties").getBoolean("best")) ? "eli-best" : null 937 948 } 949 static Boolean getOverlay(Object e) { 950 if (e instanceof ImageryInfo) return e.isOverlay() 951 return (e.get("properties").containsKey("overlay") 952 && e.get("properties").getBoolean("overlay")) 953 } 938 954 static String getIcon(Object e) { 939 955 if (e instanceof ImageryInfo) return e.getIcon() -
trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java
r13516 r13536 27 27 import org.openstreetmap.gui.jmapviewer.tilesources.TileSourceInfo; 28 28 import org.openstreetmap.josm.data.Bounds; 29 import org.openstreetmap.josm.data.StructUtils; 29 30 import org.openstreetmap.josm.data.StructUtils.StructEntry; 30 31 import org.openstreetmap.josm.io.Capabilities; 31 32 import org.openstreetmap.josm.io.OsmApi; 32 33 import org.openstreetmap.josm.spi.preferences.Config; 34 import org.openstreetmap.josm.spi.preferences.IPreferences; 33 35 import org.openstreetmap.josm.tools.CheckParameterUtil; 34 36 import org.openstreetmap.josm.tools.ImageProvider; … … 199 201 */ 200 202 private boolean bestMarked; 203 /** 204 * marked as overlay 205 * @since 13536 206 */ 207 private boolean overlay; 208 /** 209 * list of old IDs, only for loading, not handled anywhere else 210 * @since 13536 211 */ 212 private Collection<String> oldIds; 201 213 /** mirrors of different type for this entry */ 202 214 private List<ImageryInfo> mirrors; … … 245 257 @StructEntry boolean bestMarked; 246 258 @StructEntry boolean modTileFeatures; 259 @StructEntry boolean overlay; 247 260 // TODO: disabled until change of layers is implemented 248 261 // @StructEntry String default_layers; … … 271 284 date = i.date; 272 285 bestMarked = i.bestMarked; 286 overlay = i.overlay; 273 287 logo_image = i.attributionImage; 274 288 logo_url = i.attributionImageURL; … … 439 453 date = e.date; 440 454 bestMarked = e.bestMarked; 455 overlay = e.overlay; 441 456 termsOfUseText = e.terms_of_use_text; 442 457 termsOfUseURL = e.terms_of_use_url; … … 494 509 this.date = i.date; 495 510 this.bestMarked = i.bestMarked; 511 this.overlay = i.overlay; 496 512 // do not copy field {@code mirrors} 497 513 this.icon = i.icon; … … 526 542 Objects.equals(this.modTileFeatures, other.modTileFeatures) && 527 543 Objects.equals(this.bestMarked, other.bestMarked) && 544 Objects.equals(this.overlay, other.overlay) && 528 545 Objects.equals(this.isGeoreferenceValid, other.isGeoreferenceValid) && 529 546 Objects.equals(this.cookies, other.cookies) && … … 901 918 902 919 /** 920 * Return the sorted list of activated Imagery IDs 921 * @since 13536 922 */ 923 static public Collection<String> getActiveIds() { 924 ArrayList<String> ids = new ArrayList<String>(); 925 IPreferences pref = Config.getPref(); 926 if (pref != null) { 927 List<ImageryPreferenceEntry> entries = StructUtils.getListOfStructs( 928 pref, "imagery.entries", null, ImageryPreferenceEntry.class); 929 if (entries != null) { 930 for (ImageryPreferenceEntry prefEntry : entries) { 931 if(prefEntry.id != null && prefEntry.id.length() != 0) 932 ids.add(prefEntry.id); 933 } 934 Collections.sort(ids); 935 } 936 } 937 return ids; 938 } 939 940 /** 903 941 * Returns a tool tip text for display. 904 942 * @return The text … … 917 955 html = true; 918 956 } 957 if (overlay) { 958 res.append("<br>").append(tr("This imagery is an overlay.")); 959 html = true; 960 } 919 961 String desc = getDescription(); 920 962 if (desc != null && !desc.isEmpty()) { … … 1215 1257 1216 1258 /** 1259 * Returns the overlay indication. 1260 * @return <code>true</code> if it is and overlay. 1261 * @since 13536 1262 */ 1263 public boolean isOverlay() { 1264 return overlay; 1265 } 1266 1267 /** 1217 1268 * Sets an indicator that in other editors it is marked as best imagery 1218 1269 * @param bestMarked <code>true</code> if it is marked as best in other editors. … … 1221 1272 public void setBestMarked(boolean bestMarked) { 1222 1273 this.bestMarked = bestMarked; 1274 } 1275 1276 /** 1277 * Sets overlay indication 1278 * @param overlay <code>true</code> if it is an overlay. 1279 * @since 13536 1280 */ 1281 public void setOverlay(boolean overlay) { 1282 this.overlay = overlay; 1283 } 1284 1285 /** 1286 * Adds an old Id. 1287 * 1288 * @param id the Id to be added 1289 * @since 13536 1290 */ 1291 public void addOldId(String id) { 1292 if (oldIds == null) { 1293 oldIds = new ArrayList<>(); 1294 } 1295 oldIds.add(id); 1296 } 1297 1298 /** 1299 * Get old Ids. 1300 * 1301 * @return collection of ids 1302 * @since 13536 1303 */ 1304 public Collection<String> getOldIds() { 1305 return oldIds; 1223 1306 } 1224 1307 -
trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java
r12851 r13536 50 50 51 51 private static final String[] DEFAULT_LAYER_SITES = { 52 Main.getJOSMWebsite()+"/maps "52 Main.getJOSMWebsite()+"/maps%<?ids=>" 53 53 }; 54 54 … … 224 224 } 225 225 idMap.put(i.getId(), i); 226 Collection<String> old = i.getOldIds(); 227 if(old != null) { 228 for (String id : old) { 229 if (idMap.containsKey(id)) { 230 Logging.error("Old Id ''{0}'' is not unique - used by ''{1}'' and ''{2}''!", 231 i.getId(), i.getName(), idMap.get(i.getId()).getName()); 232 } else { 233 idMap.put(id, i); 234 } 235 } 236 } 226 237 } 227 238 } -
trunk/src/org/openstreetmap/josm/io/CachedFile.java
r13204 r13536 75 75 protected File cacheFile; 76 76 protected boolean initialized; 77 protected String parameter; 77 78 78 79 public static final long DEFAULT_MAXTIME = -1L; … … 173 174 } 174 175 176 /** 177 * Sets additional URL parameter (used e.g. for maps) 178 * @param parameter the URL parameter 179 * @since 13536 180 */ 181 public void setParam(String parameter) { 182 this.parameter = parameter; 183 } 184 175 185 public String getName() { 186 if(parameter != null) 187 return name.replaceAll("%<(.*)>", ""); 176 188 return name; 177 189 } … … 284 296 } 285 297 if (cacheFile == null) 286 throw new IOException("Unable to get cache file for "+ name);298 throw new IOException("Unable to get cache file for "+getName()); 287 299 return cacheFile; 288 300 } … … 298 310 * @param extension the extension of the file we're looking for 299 311 * @param namepart the name part 300 * @return The zip entry path of the matching file. Nullif this cached file312 * @return The zip entry path of the matching file. <code>null</code> if this cached file 301 313 * doesn't represent a zip file or if there was no matching 302 314 * file in the ZIP file. … … 312 324 * @param extension the extension of the file we're looking for 313 325 * @param namepart the name part 314 * @return InputStream to the matching file. Nullif this cached file326 * @return InputStream to the matching file. <code>null</code> if this cached file 315 327 * doesn't represent a zip file or if there was no matching 316 328 * file in the ZIP file. … … 380 392 url = new URL(name); 381 393 if (!"file".equals(url.getProtocol())) { 382 String prefKey = getPrefKey(url, destDir );394 String prefKey = getPrefKey(url, destDir, null); 383 395 List<String> localPath = new ArrayList<>(Config.getPref().getList(prefKey)); 384 396 if (localPath.size() == 2) { … … 403 415 * @return Preference key 404 416 */ 405 private static String getPrefKey(URL url, String destDir ) {417 private static String getPrefKey(URL url, String destDir, String parameter) { 406 418 StringBuilder prefKey = new StringBuilder("mirror."); 407 419 if (destDir != null) { 408 420 prefKey.append(destDir).append('.'); 409 421 } 410 prefKey.append(url.toString()); 422 if (parameter != null) { 423 prefKey.append(url.toString().replaceAll("%<(.*)>", "")); 424 } else { 425 prefKey.append(url.toString()); 426 } 411 427 return prefKey.toString().replaceAll("=", "_"); 412 428 } 413 429 414 430 private File checkLocal(URL url) throws IOException { 415 String prefKey = getPrefKey(url, destDir );431 String prefKey = getPrefKey(url, destDir, parameter); 416 432 String urlStr = url.toExternalForm(); 433 if (parameter != null) 434 urlStr = urlStr.replaceAll("%<(.*)>", ""); 417 435 long age = 0L; 418 436 long maxAgeMillis = maxAge; … … 460 478 } 461 479 480 if(parameter != null) { 481 String u = url.toExternalForm(); 482 String uc; 483 if("".equals(parameter)) { 484 uc = u.replaceAll("%<(.*)>", ""); 485 } else { 486 uc = u.replaceAll("%<(.*)>", "$1"+parameter); 487 } 488 if(!uc.equals(u)) 489 url = new URL(uc); 490 } 491 462 492 String a = urlStr.replaceAll("[^A-Za-z0-9_.-]", "_"); 463 493 String localPath = "mirror_" + a; -
trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java
r13272 r13536 85 85 try { 86 86 cachedFile = new CachedFile(source); 87 cachedFile.setParam(Utils.join(",", ImageryInfo.getActiveIds())); 87 88 cachedFile.setFastFail(fastFail); 88 89 try (BufferedReader in = cachedFile … … 168 169 entry.setBestMarked(true); 169 170 } 171 String overlay = atts.getValue("overlay"); 172 if (TRUE.equals(overlay)) { 173 entry.setOverlay(true); 174 } 170 175 } 171 176 break; … … 174 179 "type", 175 180 "url", 181 "id", 176 182 MIN_ZOOM, 177 183 MAX_ZOOM, … … 189 195 "name", 190 196 "id", 197 "oldid", 191 198 "type", 192 199 "description", … … 328 335 } 329 336 break; 337 case "id": 338 mirrorEntry.setId(accumulator.toString()); 339 break; 330 340 case "url": 331 341 mirrorEntry.setUrl(accumulator.toString()); … … 379 389 case "id": 380 390 entry.setId(accumulator.toString()); 391 break; 392 case "oldid": 393 entry.addOldId(accumulator.toString()); 381 394 break; 382 395 case "type":
Note:
See TracChangeset
for help on using the changeset viewer.