src/test/java/de/blau/android/osm/StorageDelegatorTest.java
/**
     * Split way at node with route relation
     */
Split way at node with route relation
Split way at node with route relation
@Test
    public void splitWithRouteRelation2() {
        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);
        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(1, splitResult.size());
        Way newWay = (Way) splitResult.get(0).getElement();
        if (newWay.nodeCount() > w.nodeCount()) {
            splitResult = d.splitAtNode(newWay, newWay.getNodes().get(1));
        } else {
            splitResult = d.splitAtNode(w, w.getNodes().get(1));
        }
        assertNotNull(splitResult);
        assertEquals(1, splitResult.size());
    }
@ Test public void splitWithRouteRelation2 ( ) { 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 ) ; 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 ( 1 , splitResult . size ( ) ) ; Way newWay = ( Way ) splitResult . get ( 0 ) . getElement ( ) ; if ( newWay . nodeCount ( ) > w . nodeCount ( ) ) { splitResult = d . splitAtNode ( newWay , newWay . getNodes ( ) . get ( 1 ) ) ; } else { splitResult = d . splitAtNode ( w , w . getNodes ( ) . get ( 1 ) ) ; } assertNotNull ( splitResult ) ; assertEquals ( 1 , splitResult . size ( ) ) ; }
Split way at node with route relation
Split way at node with route relation
// split again, this should not cause an error as we can determine where to put the split off part