Changeset 16109 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2020-03-10T22:43:23+01:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MainInitialization.java
r15855 r16109 20 20 import org.openstreetmap.josm.data.validation.OsmValidator; 21 21 import org.openstreetmap.josm.gui.layer.ImageryLayer; 22 import org.openstreetmap.josm.gui.layer.Layer;23 22 import org.openstreetmap.josm.gui.layer.TMSLayer; 24 23 import org.openstreetmap.josm.gui.preferences.imagery.ImageryPreference; … … 98 97 // Otherwise they would not have been able to load the layers in the first place because they would have been disabled 99 98 if (MainApplication.isDisplayingMapView()) { 100 for ( Layer l : MainApplication.getLayerManager().getLayersOfType(ImageryLayer.class)) {101 if ( ((ImageryLayer) l).getInfo().isBlacklisted()) {99 for (ImageryLayer l : MainApplication.getLayerManager().getLayersOfType(ImageryLayer.class)) { 100 if (l.getInfo().isBlacklisted()) { 102 101 Logging.info(tr("Removed layer {0} because it is not allowed by the configured API.", l.getName())); 103 102 MainApplication.getLayerManager().removeLayer(l); … … 116 115 }), 117 116 new InitializationTask(tr("Initializing internal traffic data"), RightAndLefthandTraffic::initialize), 117 new InitializationTask(tr("Initializing numbering format"), I18n::initializeNumberingFormat), 118 118 new InitializationTask(tr("Initializing validator"), OsmValidator::initialize), 119 119 new InitializationTask(tr("Initializing presets"), TaggingPresets::initialize), -
trunk/src/org/openstreetmap/josm/tools/I18n.java
r16049 r16109 23 23 import java.util.zip.ZipEntry; 24 24 import java.util.zip.ZipFile; 25 26 import org.openstreetmap.josm.data.osm.TagMap; 25 27 26 28 /** … … 341 343 } 342 344 345 /** 346 * Espaces the special i18n characters <code>'{}</code> with quotes. 347 * @param msg unescaped string 348 * @return escaped string 349 * @since 4477 350 */ 343 351 public static String escape(String msg) { 344 352 if (msg == null) return null; … … 626 634 } 627 635 636 /** 637 * Updates the default locale : overrides the numbering system, if defined in internal boudnaries.xml for the current language/country. 638 * @since 16109 639 */ 640 public static void initializeNumberingFormat() { 641 Locale l = Locale.getDefault(); 642 TagMap tags = Territories.getCustomTags(l.getCountry()); 643 if (tags != null) { 644 String numberingSystem = tags.get("ldml:nu:" + l.getLanguage()); 645 if (numberingSystem != null && !numberingSystem.equals(l.getExtension(Locale.UNICODE_LOCALE_EXTENSION))) { 646 Locale.setDefault(new Locale.Builder() 647 .setLanguage(l.getLanguage()) 648 .setRegion(l.getCountry()) 649 .setVariant(l.getVariant()) 650 .setExtension(Locale.UNICODE_LOCALE_EXTENSION, numberingSystem) 651 .build()); 652 } 653 } 654 } 655 628 656 private static int pluralEval(long n) { 629 657 switch(pluralMode) { -
trunk/src/org/openstreetmap/josm/tools/Territories.java
r15952 r16109 8 8 import java.io.InputStream; 9 9 import java.util.ArrayList; 10 import java.util.Arrays; 10 11 import java.util.Collection; 11 12 import java.util.Collections; … … 33 34 import org.openstreetmap.josm.data.osm.OsmPrimitive; 34 35 import org.openstreetmap.josm.data.osm.Relation; 36 import org.openstreetmap.josm.data.osm.TagMap; 35 37 import org.openstreetmap.josm.data.osm.Way; 36 38 import org.openstreetmap.josm.io.CachedFile; … … 58 60 private static volatile Map<String, TaginfoRegionalInstance> taginfoCache; 59 61 private static volatile Map<String, TaginfoRegionalInstance> taginfoGeofabrikCache; 62 private static volatile Map<String, TagMap> customTagsCache; 63 64 private static final List<String> KNOWN_KEYS = Arrays.asList(ISO3166_1, ISO3166_2, TAGINFO, "type", "name:en", "driving_side", "note"); 60 65 61 66 private Territories() { … … 128 133 iso3166Cache = new HashMap<>(); 129 134 taginfoCache = new TreeMap<>(); 135 customTagsCache = new TreeMap<>(); 130 136 try (CachedFile cf = new CachedFile("resource://data/" + FILENAME); 131 137 InputStream is = cf.getInputStream()) { … … 137 143 String iso2 = osm.get(ISO3166_2); 138 144 if (iso1 != null || iso2 != null) { 145 TagMap tags = osm.getKeys(); 146 KNOWN_KEYS.forEach(tags::remove); 139 147 GeoProperty<Boolean> gp; 140 148 if (osm instanceof Way) { … … 144 152 } 145 153 GeoPropertyIndex<Boolean> gpi = new GeoPropertyIndex<>(gp, 24); 154 addInCache(iso1, gpi, tags); 155 addInCache(iso2, gpi, tags); 146 156 if (iso1 != null) { 147 iso3166Cache.put(iso1, gpi);148 157 String taginfo = osm.get(TAGINFO); 149 158 if (taginfo != null) { … … 151 160 } 152 161 } 153 if (iso2 != null) {154 iso3166Cache.put(iso2, gpi);155 }156 162 } 157 163 } 158 164 } catch (IOException | IllegalDataException ex) { 159 165 throw new JosmRuntimeException(ex); 166 } 167 } 168 169 private static void addInCache(String code, GeoPropertyIndex<Boolean> gpi, TagMap tags) { 170 if (code != null) { 171 iso3166Cache.put(code, gpi); 172 if (!tags.isEmpty()) { 173 customTagsCache.put(code, tags); 174 } 160 175 } 161 176 } … … 216 231 .collect(Collectors.toList()); 217 232 } 233 234 /** 235 * Returns the map of custom tags for a territory with the given ISO3166-1 or ISO3166-2 code. 236 * 237 * @param code the ISO3166-1 or ISO3166-2 code 238 * @return the map of custom tags for a territory with the given ISO3166-1 or ISO3166-2 code, or {@code null} 239 * @since 16109 240 */ 241 public static TagMap getCustomTags(String code) { 242 return code != null ? customTagsCache.get(code) : null; 243 } 218 244 }
Note:
See TracChangeset
for help on using the changeset viewer.