Changeset 16200 in josm


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.

Location:
trunk
Files:
2 added
2 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                            }
  • trunk/test/unit/org/openstreetmap/josm/command/SplitWayCommandTest.java

    r15943 r16200  
    290290
    291291    /**
    292      * Non-regression test for issue #17400 ( Warn when splitting way in not fully downloaded region)
     292     * Non-regression test for issue #17400 (Warn when splitting way in not fully downloaded region)
    293293     *
    294294     * Bus route 190 gets broken when the split occurs, because the two new way parts are inserted in the relation in
     
    333333        }
    334334    }
     335
     336    /**
     337     * Non-regression test for issue #18863 (Asking for download of missing members when not needed)
     338     *
     339     * A split on node 4518025255 caused the 'download missing members?' dialog to pop up for relation 68745 (CB 2),
     340     * even though the way members next to the split way were already downloaded. This happened because this relation
     341     * does not have its members connected at all.
     342     *
     343     * This split should not trigger any download action at all.
     344     *
     345     * @throws IOException if any I/O error occurs
     346     * @throws IllegalDataException if OSM parsing fails
     347     */
     348    @Test
     349    public void testTicket18863() throws IOException, IllegalDataException {
     350        try (InputStream is = TestUtils.getRegressionDataStream(18863, "data.osm.bz2")) {
     351            DataSet ds = OsmReader.parseDataSet(is, null);
     352
     353            Way splitWay = (Way) ds.getPrimitiveById(290581177L, OsmPrimitiveType.WAY);
     354            Node splitNode = (Node) ds.getPrimitiveById(4518025255L, OsmPrimitiveType.NODE);
     355
     356            final Optional<SplitWayCommand> result = SplitWayCommand.splitWay(
     357                    splitWay,
     358                    SplitWayCommand.buildSplitChunks(splitWay, Collections.singletonList(splitNode)),
     359                    new ArrayList<>(),
     360                    Strategy.keepLongestChunk(),
     361                    // This split requires no additional downloads. If any are needed, this command will fail.
     362                    SplitWayCommand.WhenRelationOrderUncertain.ABORT
     363            );
     364
     365            // Should not result in aborting the split.
     366            assertTrue(result.isPresent());
     367        }
     368    }
    335369}
Note: See TracChangeset for help on using the changeset viewer.