Changeset 18885 in josm for trunk/src/org
- Timestamp:
- 2023-10-30T20:12:12+01:00 (13 months ago)
- Location:
- trunk/src/org/openstreetmap/josm/data
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
r18881 r18885 77 77 * Then it indicates, whether it is completely hidden or 78 78 * just shown in gray color. 79 * 79 * <p> 80 80 * When the primitive is not disabled, this flag should be 81 81 * unset as well (for efficient access). … … 521 521 @Override 522 522 public void visitKeys(KeyValueVisitor visitor) { 523 String[] keys = this.keys;524 if ( keys != null) {525 for (int i = 0; i < keys.length; i += 2) {526 visitor.visitKeyValue(this, keys[i], keys[i + 1]);523 String[] tKeys = this.keys; 524 if (tKeys != null) { 525 for (int i = 0; i < tKeys.length; i += 2) { 526 visitor.visitKeyValue(this, tKeys[i], tKeys[i + 1]); 527 527 } 528 528 } … … 754 754 @Override 755 755 public final Collection<String> keySet() { 756 String[] keys = this.keys;757 if ( keys == null) {756 String[] tKeys = this.keys; 757 if (tKeys == null) { 758 758 return Collections.emptySet(); 759 759 } 760 if ( keys.length == 2) {761 return Collections.singleton( keys[0]);762 } 763 764 final Set<String> result = new HashSet<>(Utils.hashMapInitialCapacity( keys.length / 2));765 for (int i = 0; i < keys.length; i += 2) {766 result.add( keys[i]);760 if (tKeys.length == 2) { 761 return Collections.singleton(tKeys[0]); 762 } 763 764 final Set<String> result = new HashSet<>(Utils.hashMapInitialCapacity(tKeys.length / 2)); 765 for (int i = 0; i < tKeys.length; i += 2) { 766 result.add(tKeys[i]); 767 767 } 768 768 return result; … … 810 810 */ 811 811 public boolean hasKey(String... keys) { 812 return keys != null && Arrays.stream(keys).anyMatch(this::hasKey); 812 if (keys != null) { 813 for (String key : keys) { 814 if (this.hasKey(key)) { 815 return true; 816 } 817 } 818 } 819 return false; 813 820 } 814 821 -
trunk/src/org/openstreetmap/josm/data/osm/Tagged.java
r18474 r18885 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import java.util.Arrays;5 4 import java.util.Collection; 6 5 import java.util.Map; … … 147 146 */ 148 147 default boolean hasTag(String key, String... values) { 149 return hasTag(key, Arrays.asList(values)); 148 final String actualValue = get(key); 149 for (String value : values) { 150 if (Objects.equals(value, actualValue)) { 151 return true; 152 } 153 } 154 return false; 150 155 } 151 156 … … 182 187 */ 183 188 default boolean hasTagDifferent(String key, String... values) { 184 return hasTagDifferent(key, Arrays.asList(values)); 189 final String actual = get(key); 190 for (String value : values) { 191 if (Objects.equals(actual, value)) { 192 return false; 193 } 194 } 195 return true; 185 196 } 186 197 -
trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java
r18871 r18885 53 53 */ 54 54 public abstract class UnconnectedWays extends Test { 55 private static final String POWER = "power"; 56 private static final String PLATFORM = "platform"; 57 private static final String PLATFORM_EDGE = "platform_edge"; 58 private static final String CONSTRUCTION = "construction"; 55 59 private final int code; 56 60 private final boolean isHighwayTest; … … 102 106 || n.isKeyTrue("noexit") 103 107 || n.hasKey("entrance", "barrier") 104 || n.getParentWays().stream().anyMatch(p -> isBuilding(p) || p.hasTag(RAILWAY, "platform", "platform_edge"));108 || n.getParentWays().stream().anyMatch(p -> isBuilding(p) || p.hasTag(RAILWAY, PLATFORM, PLATFORM_EDGE)); 105 109 } 106 110 } … … 120 124 @Override 121 125 protected boolean isCandidate(OsmPrimitive p) { 122 if (p.hasTag(RAILWAY, "construction") && p.hasKey("construction"))123 return p.hasTagDifferent( "construction", "platform", "platform_edge", "service_station", "station");126 if (p.hasTag(RAILWAY, CONSTRUCTION) && p.hasKey(CONSTRUCTION)) 127 return p.hasTagDifferent(CONSTRUCTION, PLATFORM, PLATFORM_EDGE, "service_station", "station"); 124 128 return p.hasTagDifferent(RAILWAY, "proposed", "planned", "abandoned", "razed", "disused", "no", 125 "platform", "platform_edge", "service_station", "station");129 PLATFORM, PLATFORM_EDGE, "service_station", "station"); 126 130 } 127 131 … … 197 201 @Override 198 202 protected boolean isCandidate(OsmPrimitive p) { 199 return p.hasTag( "power", "line", "minor_line", "cable");203 return p.hasTag(POWER, "line", "minor_line", "cable"); 200 204 } 201 205 202 206 @Override 203 207 protected boolean ignoreUnconnectedEndNode(Node n) { 204 return n.hasTag("power", "terminal") || n.hasTag("location:transition", "yes"); 208 return n.hasTag(POWER, "terminal") || n.hasTag("location:transition", "yes") 209 || n.hasTag("line_management", "transition", "termination"); 205 210 } 206 211 } … … 270 275 return map; 271 276 } 272 if (s.w.hasTag(HIGHWAY, "platform"))277 if (s.w.hasTag(HIGHWAY, PLATFORM)) 273 278 continue; 274 279 for (Node endnode : s.nearbyNodes(mindist)) { 275 280 Way parentWay = getWantedParentWay(endnode); 276 if (parentWay != null && !parentWay.hasTag(HIGHWAY, "platform")281 if (parentWay != null && !parentWay.hasTag(HIGHWAY, PLATFORM) 277 282 && Objects.equals(OsmUtils.getLayer(s.w), OsmUtils.getLayer(parentWay)) 278 283 // to handle intersections of 't' shapes and similar … … 296 301 for (Node endnode : s.nearbyNodes(mindist)) { 297 302 if (!s.isConnectedTo(endnode)) { 298 if (s.w.hasTag( "power")) {303 if (s.w.hasTag(POWER)) { 299 304 boolean badConnection = false; 300 305 Way otherWay = getWantedParentWay(endnode);
Note:
See TracChangeset
for help on using the changeset viewer.