Changeset 16018 in josm


Ignore:
Timestamp:
2020-03-03T22:49:50+01:00 (3 months ago)
Author:
Don-vip
Message:

see #18845 - fix epsg and taginfo goals

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/build.xml

    r16011 r16018  
    10451045            <sysproperty key="java.awt.headless" value="true"/>
    10461046            <classpath>
    1047                 <pathelement path="${base.dir}"/>
     1047                <pathelement path="${base.dir}/resources"/>
    10481048                <pathelement path="${proj-classpath}"/>
    10491049                <pathelement path="${proj-build.dir}"/>
  • trunk/scripts/TagInfoExtract.java

    r16006 r16018  
    2424import java.util.Optional;
    2525import java.util.Set;
     26import java.util.regex.Matcher;
     27import java.util.regex.Pattern;
    2628import java.util.stream.Collectors;
    2729
     
    206208         */
    207209        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);
    209211            if (Files.exists(f)) {
    210212                return "https://josm.openstreetmap.de/export/" + josmSvnRevision + "/josm/trunk/resources/images/" + path;
     
    379381         */
    380382        private abstract class Checker {
     383            private final Pattern reservedChars = Pattern.compile("[<>:\"|\\?\\*]");
     384
    381385            Checker(Tag tag) {
    382386                this.tag = tag;
     
    417421                renderer.getSettings(false);
    418422                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";
    420424                try (OutputStream out = Files.newOutputStream(options.imageDir.resolve(imageName))) {
    421425                    ImageIO.write(img, "png", out);
     
    425429                final String baseUrl = options.imageUrlPrefix != null ? options.imageUrlPrefix : options.imageDir.toString();
    426430                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;
    427441            }
    428442
Note: See TracChangeset for help on using the changeset viewer.