Changeset 13065 in josm


Ignore:
Timestamp:
2017-11-01T13:58:59+01:00 (3 weeks ago)
Author:
Don-vip
Message:

fix #12347 - Split way breaks destination_sign relations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/SplitWayCommand.java

    r12901 r13065  
    443443
    444444    static OsmPrimitive findVia(Relation r, String type) {
    445         for (RelationMember rmv : r.getMembers()) {
    446             if (("restriction".equals(type) && "via".equals(rmv.getRole()))
    447              || ("destination_sign".equals(type) && rmv.hasRole("sign", "intersection"))) {
    448                 return rmv.getMember();
    449             }
    450         }
    451         return null;
     445        switch (type) {
     446        case "restriction":
     447            return findRelationMember(r, "via").orElse(null);
     448        case "destination_sign":
     449            // Prefer intersection over sign, see #12347
     450            return findRelationMember(r, "intersection").orElse(findRelationMember(r, "sign").orElse(null));
     451        default:
     452            return null;
     453        }
     454    }
     455
     456    static Optional<OsmPrimitive> findRelationMember(Relation r, String role) {
     457        return r.getMembers().stream().filter(rmv -> role.equals(rmv.getRole()))
     458                .map(RelationMember::getMember).findAny();
    452459    }
    453460
Note: See TracChangeset for help on using the changeset viewer.