Changeset 18539 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2022-08-16T15:50:52+02:00 (2 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/SplitWayCommand.java
r17375 r18539 488 488 if (way.lastNode() == way.firstNode()) { 489 489 // Self-closing way. 490 direction = Direction.IRRELEVANT; 490 direction = direction.merge(Direction.IRRELEVANT); 491 491 } else { 492 492 // For ordered relations, looking beyond the nearest neighbour members is not required, … … 498 498 else { 499 499 if (w.lastNode() == way.firstNode() || w.firstNode() == way.firstNode()) { 500 direction = Direction.FORWARDS; 500 direction = direction.merge(Direction.FORWARDS); 501 501 } else if (w.firstNode() == way.lastNode() || w.lastNode() == way.lastNode()) { 502 direction = Direction.BACKWARDS; 502 direction = direction.merge(Direction.BACKWARDS); 503 503 } 504 504 } … … 510 510 else { 511 511 if (w.lastNode() == way.firstNode() || w.firstNode() == way.firstNode()) { 512 direction = Direction.BACKWARDS; 512 direction = direction.merge(Direction.BACKWARDS); 513 513 } else if (w.firstNode() == way.lastNode() || w.lastNode() == way.lastNode()) { 514 direction = Direction.FORWARDS; 514 direction = direction.merge(Direction.FORWARDS); 515 515 } 516 516 } … … 529 529 Way w = r.getMember(ir - k).getWay(); 530 530 if (w.lastNode() == way.firstNode() || w.firstNode() == way.firstNode()) { 531 direction = Direction.FORWARDS; 531 direction = direction.merge(Direction.FORWARDS); 532 532 } else if (w.firstNode() == way.lastNode() || w.lastNode() == way.lastNode()) { 533 direction = Direction.BACKWARDS; 533 direction = direction.merge(Direction.BACKWARDS); 534 534 } 535 535 break; … … 538 538 Way w = r.getMember(ir + k).getWay(); 539 539 if (w.lastNode() == way.firstNode() || w.firstNode() == way.firstNode()) { 540 direction = Direction.BACKWARDS; 540 direction = direction.merge(Direction.BACKWARDS); 541 541 } else if (w.firstNode() == way.lastNode() || w.lastNode() == way.lastNode()) { 542 direction = Direction.FORWARDS; 542 direction = direction.merge(Direction.FORWARDS); 543 543 } 544 544 break; … … 952 952 BACKWARDS, 953 953 UNKNOWN, 954 IRRELEVANT 954 IRRELEVANT; 955 956 /** 957 * Merge directions (this helps avoid overriding {@link #FORWARDS} with {@link #BACKWARDS}). 958 * @param other The other direction to merge. {@link #UNKNOWN} will be overridden. 959 * @return The merged direction 960 */ 961 Direction merge(Direction other) { 962 if (this == other) { 963 return this; 964 } 965 if (this == IRRELEVANT || other == IRRELEVANT || 966 (this == FORWARDS && other == BACKWARDS) || 967 (other == FORWARDS && this == BACKWARDS)) { 968 return IRRELEVANT; 969 } 970 if (this == UNKNOWN) { 971 return other; 972 } 973 if (other == UNKNOWN) { 974 return this; 975 } 976 return UNKNOWN; 977 } 955 978 } 956 979 -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r18468 r18539 531 531 */ 532 532 public void addPrimitiveRecursive(OsmPrimitive primitive) { 533 Stream<OsmPrimitive> children; 533 534 if (primitive instanceof Way) { 534 ((Way) primitive).getNodes(). forEach(n -> addPrimitiveRecursive(n));535 children = ((Way) primitive).getNodes().stream().map(OsmPrimitive.class::cast); 535 536 } else if (primitive instanceof Relation) { 536 ((Relation) primitive).getMembers().forEach(m -> addPrimitiveRecursive(m.getMember())); 537 } 537 children = ((Relation) primitive).getMembers().stream().map(RelationMember::getMember); 538 } else { 539 children = Stream.empty(); 540 } 541 // Relations may have the same member multiple times. 542 children.filter(p -> !Objects.equals(this, p.getDataSet())).forEach(this::addPrimitiveRecursive); 538 543 addPrimitive(primitive); 539 544 }
Note:
See TracChangeset
for help on using the changeset viewer.