src/test/java/de/blau/android/osm/StorageDelegatorTest.java
/**
     * Split way at node with incomplete route relation
     */
Split way at node with incomplete route relation
Split way at node with incomplete route relation
@Test
    public void splitWithIncompleteRouteRelation() {
        StorageDelegator d = new StorageDelegator();
        Way w = DelegatorUtil.addWayToStorage(d, false);
        Way temp = (Way) d.getOsmElement(Way.NAME, w.getOsmId());
        assertNotNull(temp);
        Node n = w.getNodes().get(2);
        Relation r = w.getParentRelations().get(0);
        r.addMemberBefore(r.getMember(w), new RelationMember(Way.NAME, 12345, ""));
        r.addMemberAfter(r.getMember(w), new RelationMember(Way.NAME, 12346, ""));
        Map<String, String> routeTag = new HashMap<>();
        routeTag.put(Tags.KEY_TYPE, Tags.VALUE_ROUTE);
        r.setTags(routeTag);
        List<Result> splitResult = d.splitAtNode(w, n);
        assertNotNull(splitResult);
        assertEquals(2, splitResult.size());
        Result relationResult = splitResult.get(1);
        assertEquals(r, relationResult.getElement());
        assertTrue(relationResult.getIssues().contains(SplitIssue.SPLIT_ROUTE_ORDERING));
        Way newWay = (Way) splitResult.get(0).getElement();
        assertEquals(n, w.getLastNode());
        assertEquals(n, newWay.getFirstNode());
        assertEquals(2, newWay.nodeCount());
    }
@ Test public void splitWithIncompleteRouteRelation ( ) { StorageDelegator d = new StorageDelegator ( ) ; Way w = DelegatorUtil . addWayToStorage ( d , false ) ; Way temp = ( Way ) d . getOsmElement ( Way . NAME , w . getOsmId ( ) ) ; assertNotNull ( temp ) ; Node n = w . getNodes ( ) . get ( 2 ) ; Relation r = w . getParentRelations ( ) . get ( 0 ) ; r . addMemberBefore ( r . getMember ( w ) , new RelationMember ( Way . NAME , 12345 , "" ) ) ; r . addMemberAfter ( r . getMember ( w ) , new RelationMember ( Way . NAME , 12346 , "" ) ) ; Map < String , String > routeTag = new HashMap < > ( ) ; routeTag . put ( Tags . KEY_TYPE , Tags . VALUE_ROUTE ) ; r . setTags ( routeTag ) ; List < Result > splitResult = d . splitAtNode ( w , n ) ; assertNotNull ( splitResult ) ; assertEquals ( 2 , splitResult . size ( ) ) ; Result relationResult = splitResult . get ( 1 ) ; assertEquals ( r , relationResult . getElement ( ) ) ; assertTrue ( relationResult . getIssues ( ) . contains ( SplitIssue . SPLIT_ROUTE_ORDERING ) ) ; Way newWay = ( Way ) splitResult . get ( 0 ) . getElement ( ) ; assertEquals ( n , w . getLastNode ( ) ) ; assertEquals ( n , newWay . getFirstNode ( ) ) ; assertEquals ( 2 , newWay . nodeCount ( ) ) ; }
Split way at node with incomplete route relation
Split way at node with incomplete route relation
// add dummy members before and after the way we are splitting