Changeset 15881 in josm for trunk/src


Ignore:
Timestamp:
2020-02-17T21:18:03+01:00 (5 years ago)
Author:
simon04
Message:

fix #15158 - Tag2Link: leading zeros for ref:bag

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Tag2Link.java

    r15861 r15881  
    1010import java.net.URL;
    1111import java.nio.charset.StandardCharsets;
     12import java.util.Collections;
     13import java.util.Map;
     14import java.util.function.UnaryOperator;
    1215import java.util.regex.Matcher;
    1316import java.util.regex.Pattern;
     
    4649    static final MultiMap<String, String> wikidataRules = new MultiMap<>();
    4750
     51    static final Map<String, UnaryOperator<String>> valueFormatter = Collections.singletonMap(
     52            "ref:bag", v -> String.format("%16s", v).replace(' ', '0')
     53    );
     54
    4855    static final String languagePattern = LanguageInfo.getLanguageCodes(null).stream()
    4956            .map(Pattern::quote)
     
    179186
    180187        wikidataRules.getValues(key).forEach(urlFormatter -> {
    181             final String url = urlFormatter.replace("$1", value);
     188            final String formattedValue = valueFormatter.getOrDefault(key, x -> x).apply(value);
     189            final String url = urlFormatter.replace("$1", formattedValue);
    182190            linkConsumer.acceptLink(getLinkName(url, key), url);
    183191        });
Note: See TracChangeset for help on using the changeset viewer.