- Timestamp:
- 2020-02-23T00:29:51+01:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r15906 r15908 59 59 import org.openstreetmap.josm.command.Command; 60 60 import org.openstreetmap.josm.data.UndoRedoHandler; 61 import org.openstreetmap.josm.data.coor.LatLon; 61 62 import org.openstreetmap.josm.data.osm.AbstractPrimitive; 62 63 import org.openstreetmap.josm.data.osm.DataSelectionListener; … … 370 371 destroyTaginfoNationalActions(); 371 372 if (!newSel.isEmpty()) { 372 Territories.getRegionalTaginfoUrls(373 newSel.iterator().next().getBBox().getCenter()).values().stream().flatMap(List::stream).forEach(374 taginfo -> taginfoNationalActions.add(new TaginfoAction(tagTable, editHelper::getDataKey, editHelper::getDataValues,375 membershipTable, x -> (IRelation<?>) membershipData.getValueAt(x, 0),376 taginfo.getUrl(), String.join("/", taginfo.getIsoCodes())377 + (taginfo.getSuffix() == null ? "" : " (" + taginfo.getSuffix() + ")")))378 );373 final LatLon center = newSel.iterator().next().getBBox().getCenter(); 374 Territories.getRegionalTaginfoUrls(center) 375 .map(taginfo -> new TaginfoAction( 376 tagTable, editHelper::getDataKey, editHelper::getDataValues, 377 membershipTable, x -> (IRelation<?>) membershipData.getValueAt(x, 0), taginfo.getUrl(), 378 String.join("/", taginfo.getIsoCodes()) + (taginfo.getSuffix() == null ? "" : " (" + taginfo.getSuffix() + ")")) 379 ).forEach(taginfoNationalActions::add); 379 380 taginfoNationalActions.stream().map(membershipMenu::add).forEach(membershipMenuTagInfoNatItems::add); 380 381 taginfoNationalActions.stream().map(tagMenu::add).forEach(tagMenuTagInfoNatItems::add); -
trunk/src/org/openstreetmap/josm/tools/Territories.java
r15876 r15908 7 7 import java.io.InputStream; 8 8 import java.util.ArrayList; 9 import java.util.Arrays;10 9 import java.util.Collection; 11 10 import java.util.Collections; 12 11 import java.util.HashMap; 13 import java.util.List;14 12 import java.util.Locale; 15 13 import java.util.Map; 16 14 import java.util.Map.Entry; 17 import java.util.O ptional;15 import java.util.Objects; 18 16 import java.util.Set; 19 17 import java.util.TreeMap; 20 18 import java.util.stream.Collectors; 19 import java.util.stream.Stream; 21 20 22 21 import javax.json.Json; … … 199 198 200 199 /** 201 * Returns a map ofregional taginfo instances for the given location.200 * Returns regional taginfo instances for the given location. 202 201 * @param ll lat/lon where to look. 203 * @return a map ofregional taginfo instances for the given location (code / url)202 * @return regional taginfo instances for the given location (code / url) 204 203 * @since 15876 205 204 */ 206 public static Map<String, List<TaginfoRegionalInstance>> getRegionalTaginfoUrls(LatLon ll) { 207 Map<String, List<TaginfoRegionalInstance>> result = new TreeMap<>(); 208 if (iso3166Cache != null) { 209 for (String code : iso3166Cache.entrySet().parallelStream().distinct() 205 public static Stream<TaginfoRegionalInstance> getRegionalTaginfoUrls(LatLon ll) { 206 if (iso3166Cache == null) { 207 return Stream.empty(); 208 } 209 return iso3166Cache.entrySet().parallelStream().distinct() 210 210 .filter(e -> Boolean.TRUE.equals(e.getValue().get(ll))) 211 211 .map(Entry<String, GeoPropertyIndex<Boolean>>::getKey) 212 .collect(Collectors.toSet())) { 213 for (Map<String, TaginfoRegionalInstance> cache : Arrays.asList(taginfoCache, taginfoGeofabrikCache)) { 214 Optional.ofNullable(cache.get(code)).ifPresent( 215 taginfo -> result.computeIfAbsent(code, c -> new ArrayList<>()).add(taginfo)); 216 } 217 } 218 } 219 return result; 212 .distinct() 213 .flatMap(code -> Stream.of(taginfoCache, taginfoGeofabrikCache).map(cache -> cache.get(code))) 214 .filter(Objects::nonNull); 220 215 } 221 216 }
Note:
See TracChangeset
for help on using the changeset viewer.