Changeset 16463 in josm for trunk/src/org/openstreetmap/josm/data/osm/Node.java
- Timestamp:
- 2020-05-19T06:46:41+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/Node.java
r16364 r16463 3 3 4 4 import java.awt.geom.Area; 5 import java.util.Collection;6 5 import java.util.List; 7 6 import java.util.Objects; 8 7 import java.util.Set; 9 import java.util.TreeSet;10 import java.util.function.Predicate;11 8 import java.util.stream.Collectors; 12 9 … … 18 15 import org.openstreetmap.josm.data.projection.Projecting; 19 16 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 20 import org.openstreetmap.josm.tools.CheckParameterUtil;21 17 22 18 /** … … 350 346 } 351 347 352 /**353 * Tests whether {@code this} node is connected to {@code otherNode} via at most {@code hops} nodes354 * matching the {@code predicate} (which may be {@code null} to consider all nodes).355 * @param otherNodes other nodes356 * @param hops number of hops357 * @param predicate predicate to match358 * @return {@code true} if {@code this} node mets the conditions359 * @deprecated Was used by UnconnectedWays test360 */361 @Deprecated362 public boolean isConnectedTo(final Collection<Node> otherNodes, final int hops, Predicate<Node> predicate) {363 CheckParameterUtil.ensureParameterNotNull(otherNodes);364 CheckParameterUtil.ensureThat(!otherNodes.isEmpty(), "otherNodes must not be empty!");365 CheckParameterUtil.ensureThat(hops >= 0, "hops must be non-negative!");366 return hops == 0367 ? isConnectedTo(otherNodes, hops, predicate, null)368 : isConnectedTo(otherNodes, hops, predicate, new TreeSet<>());369 }370 371 @Deprecated372 private boolean isConnectedTo(final Collection<Node> otherNodes, final int hops, Predicate<Node> predicate, Set<Node> visited) {373 if (otherNodes.contains(this)) {374 return true;375 }376 if (hops > 0 && visited != null) {377 visited.add(this);378 for (final Way w : getParentWays()) {379 for (final Node n : w.getNodes()) {380 final boolean containsN = visited.contains(n);381 if (!containsN && (predicate == null || predicate.test(n))382 && n.isConnectedTo(otherNodes, hops - 1, predicate, visited)) {383 return true;384 }385 }386 }387 }388 return false;389 }390 391 348 @Override 392 349 public boolean isOutsideDownloadArea() {
Note:
See TracChangeset
for help on using the changeset viewer.