Changeset 16200 in josm for trunk/src


Ignore:
Timestamp:
2020-03-24T07:37:08+01:00 (4 years ago)
Author:
GerdP
Message:

see #18863 split ways: false positive warnings about missing members
Solution for the problem case given in the unit test looks OK.
Ticket mentiones two problems, so I am not sure if both are fixed now.

File:
1 edited

Legend:

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

    r15943 r16200  
    501501                                direction = Direction.IRRELEVANT;
    502502                            } else {
     503                                boolean previousWayMemberMissing = true;
     504                                boolean nextWayMemberMissing = true;
     505
    503506                                // For ordered relations, looking beyond the nearest neighbour members is not required,
    504507                                // and can even cause the wrong direction to be guessed (with closed loops).
    505508                                if (ir - 1 >= 0 && relationMembers.get(ir - 1).isWay()) {
    506509                                    Way w = relationMembers.get(ir - 1).getWay();
    507                                     if (w.lastNode() == way.firstNode() || w.firstNode() == way.firstNode()) {
    508                                         direction = Direction.FORWARDS;
    509                                     } else if (w.firstNode() == way.lastNode() || w.lastNode() == way.lastNode()) {
    510                                         direction = Direction.BACKWARDS;
     510                                    if (!w.isIncomplete()) {
     511                                        previousWayMemberMissing = false;
     512                                        if (w.lastNode() == way.firstNode() || w.firstNode() == way.firstNode()) {
     513                                            direction = Direction.FORWARDS;
     514                                        } else if (w.firstNode() == way.lastNode() || w.lastNode() == way.lastNode()) {
     515                                            direction = Direction.BACKWARDS;
     516                                        }
    511517                                    }
     518                                } else {
     519                                    previousWayMemberMissing = false;
    512520                                }
    513521                                if (ir + 1 < relationMembers.size() && relationMembers.get(ir + 1).isWay()) {
    514522                                    Way w = relationMembers.get(ir + 1).getWay();
    515                                     if (w.lastNode() == way.firstNode() || w.firstNode() == way.firstNode()) {
    516                                         direction = Direction.BACKWARDS;
    517                                     } else if (w.firstNode() == way.lastNode() || w.lastNode() == way.lastNode()) {
    518                                         direction = Direction.FORWARDS;
     523                                    if (!w.isIncomplete()) {
     524                                        nextWayMemberMissing = false;
     525                                        if (w.lastNode() == way.firstNode() || w.firstNode() == way.firstNode()) {
     526                                            direction = Direction.BACKWARDS;
     527                                        } else if (w.firstNode() == way.lastNode() || w.lastNode() == way.lastNode()) {
     528                                            direction = Direction.FORWARDS;
     529                                        }
    519530                                    }
     531                                } else {
     532                                    nextWayMemberMissing = false;
     533                                }
     534
     535                                if (direction == Direction.UNKNOWN
     536                                        && !previousWayMemberMissing
     537                                        && !nextWayMemberMissing) {
     538                                    // If both the next and previous way member in the relation are already known at
     539                                    // this point, and they are not connected to this one, then we can safely
     540                                    // assume that the direction doesn't matter. Downloading any more members
     541                                    // won't help in any case.
     542                                    direction = Direction.IRRELEVANT;
    520543                                }
    521544                            }
Note: See TracChangeset for help on using the changeset viewer.