Changeset 16018 in josm for trunk/scripts
- Timestamp:
- 2020-03-03T22:49:50+01:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/TagInfoExtract.java
r16006 r16018 24 24 import java.util.Optional; 25 25 import java.util.Set; 26 import java.util.regex.Matcher; 27 import java.util.regex.Pattern; 26 28 import java.util.stream.Collectors; 27 29 … … 206 208 */ 207 209 private String findImageUrl(String path) { 208 final Path f = baseDir.resolve(" images").resolve(path);210 final Path f = baseDir.resolve("resources").resolve("images").resolve(path); 209 211 if (Files.exists(f)) { 210 212 return "https://josm.openstreetmap.de/export/" + josmSvnRevision + "/josm/trunk/resources/images/" + path; … … 379 381 */ 380 382 private abstract class Checker { 383 private final Pattern reservedChars = Pattern.compile("[<>:\"|\\?\\*]"); 384 381 385 Checker(Tag tag) { 382 386 this.tag = tag; … … 417 421 renderer.getSettings(false); 418 422 element.paintPrimitive(osm, MapPaintSettings.INSTANCE, renderer, false, false, false); 419 final String imageName = type + "_" + tag+ ".png";423 final String imageName = type + "_" + normalize(tag.toString()) + ".png"; 420 424 try (OutputStream out = Files.newOutputStream(options.imageDir.resolve(imageName))) { 421 425 ImageIO.write(img, "png", out); … … 425 429 final String baseUrl = options.imageUrlPrefix != null ? options.imageUrlPrefix : options.imageDir.toString(); 426 430 return baseUrl + "/" + imageName; 431 } 432 433 /** 434 * Normalizes tag so that it can used as a filename on all platforms, including Windows. 435 * @param tag OSM tag, that can contain illegal path characters 436 * @return OSM tag with all illegal path characters replaced by underscore ('_') 437 */ 438 String normalize(String tag) { 439 Matcher m = reservedChars.matcher(tag); 440 return m.find() ? m.replaceAll("_") : tag; 427 441 } 428 442
Note:
See TracChangeset
for help on using the changeset viewer.