- Timestamp:
- 2020-03-10T22:43:23+01:00 (5 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/resources/data/boundaries.osm
r15819 r16109 21388 21388 <nd ref='-7116' /> 21389 21389 <tag k='ISO3166-1:alpha2' v='BH' /> 21390 <tag k='ldml:nu:ar' v='arab' /> 21390 21391 <tag k='name:en' v='Bahrain' /> 21391 21392 </way> … … 26617 26618 <nd ref='-9548' /> 26618 26619 <tag k='ISO3166-1:alpha2' v='EG' /> 26620 <tag k='ldml:nu:ar' v='arab' /> 26619 26621 <tag k='name:en' v='Egypt, Arab Rep.' /> 26620 26622 </way> … … 30198 30200 <nd ref='-9490' /> 30199 30201 <tag k='ISO3166-1:alpha2' v='IQ' /> 30202 <tag k='ldml:nu:ar' v='arab' /> 30200 30203 <tag k='name:en' v='Iraq' /> 30201 30204 </way> … … 30448 30451 <nd ref='-9584' /> 30449 30452 <tag k='ISO3166-1:alpha2' v='JO' /> 30453 <tag k='ldml:nu:ar' v='arab' /> 30450 30454 <tag k='name:en' v='Jordan' /> 30451 30455 </way> … … 31299 31303 <nd ref='-9888' /> 31300 31304 <tag k='ISO3166-1:alpha2' v='KH' /> 31305 <tag k='ldml:nu:km' v='khmr' /> 31301 31306 <tag k='name:en' v='Cambodia' /> 31302 31307 </way> … … 31458 31463 <nd ref='-9928' /> 31459 31464 <tag k='ISO3166-1:alpha2' v='KW' /> 31465 <tag k='ldml:nu:ar' v='arab' /> 31460 31466 <tag k='name:en' v='Kuwait' /> 31461 31467 </way> … … 31864 31870 <nd ref='-11224' /> 31865 31871 <tag k='ISO3166-1:alpha2' v='LB' /> 31872 <tag k='ldml:nu:ar' v='arab' /> 31866 31873 <tag k='name:en' v='Lebanon' /> 31867 31874 </way> … … 36221 36228 <nd ref='-11040' /> 36222 36229 <tag k='ISO3166-1:alpha2' v='QA' /> 36230 <tag k='ldml:nu:ar' v='arab' /> 36223 36231 <tag k='name:en' v='Qatar' /> 36224 36232 </way> … … 36680 36688 <nd ref='-9512' /> 36681 36689 <tag k='ISO3166-1:alpha2' v='SA' /> 36690 <tag k='ldml:nu:ar' v='arab' /> 36682 36691 <tag k='name:en' v='Saudi Arabia' /> 36683 36692 </way> … … 38157 38166 <nd ref='-11220' /> 38158 38167 <tag k='ISO3166-1:alpha2' v='SY' /> 38168 <tag k='ldml:nu:ar' v='arab' /> 38159 38169 <tag k='name:en' v='Syrian Arab Republic' /> 38160 38170 </way> … … 41300 41310 <nd ref='-11556' /> 41301 41311 <tag k='ISO3166-1:alpha2' v='YE' /> 41312 <tag k='ldml:nu:ar' v='arab' /> 41302 41313 <tag k='name:en' v='Yemen, Rep.' /> 41303 41314 </way> … … 58297 58308 <member type='way' ref='-28920' role='inner' /> 58298 58309 <tag k='ISO3166-1:alpha2' v='AE' /> 58310 <tag k='ldml:nu:ar' v='arab' /> 58299 58311 <tag k='name:en' v='United Arab Emirates' /> 58300 58312 <tag k='type' v='multipolygon' /> … … 58509 58521 <member type='way' ref='-29158' role='outer' /> 58510 58522 <tag k='ISO3166-1:alpha2' v='OM' /> 58523 <tag k='ldml:nu:ar' v='arab' /> 58511 58524 <tag k='name:en' v='Oman' /> 58512 58525 <tag k='type' v='multipolygon' /> -
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 } -
trunk/test/unit/org/openstreetmap/josm/tools/TerritoriesTest.java
r16032 r16109 4 4 import static java.util.Collections.singleton; 5 5 import static org.junit.Assert.assertEquals; 6 import static org.junit.Assert.assertNull; 6 7 import static org.junit.Assert.assertTrue; 7 8 … … 90 91 assertTrue(error, error.contains(": Invalid token=EOF at (line no=3,")); 91 92 } 93 94 /** 95 * Unit test of {@link Territories#getCustomTags} 96 */ 97 @Test 98 public void testGetCustomTags() { 99 assertNull(Territories.getCustomTags(null)); 100 assertNull(Territories.getCustomTags("foo")); 101 assertEquals("arab", Territories.getCustomTags("BH").get("ldml:nu:ar")); 102 } 92 103 }
Note:
See TracChangeset
for help on using the changeset viewer.