Ignore:
Timestamp:
2016-09-27T20:47:19+02:00 (8 years ago)
Author:
simon04
Message:

fix #10260 - Warning on reversing ways with direction-dependent nodes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/corrector/ReverseWayTagCorrectorTest.java

    r10945 r11061  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.corrector;
     3
     4import java.util.Collections;
     5import java.util.List;
     6import java.util.Map;
     7import java.util.stream.Stream;
    38
    49import org.junit.Assert;
    510import org.junit.Rule;
    611import org.junit.Test;
     12import org.openstreetmap.josm.data.correction.TagCorrection;
     13import org.openstreetmap.josm.data.osm.Node;
     14import org.openstreetmap.josm.data.osm.OsmPrimitive;
     15import org.openstreetmap.josm.data.osm.OsmUtils;
    716import org.openstreetmap.josm.data.osm.Tag;
     17import org.openstreetmap.josm.data.osm.Way;
    818import org.openstreetmap.josm.testutils.JOSMTestRules;
    919
     
    3949            assertSwitch(new Tag(k, "something"), new Tag(k, "something"));
    4050        }
     51        // direction=forward/backward/...
     52        assertSwitch(new Tag("direction", "forward"), new Tag("direction", "backward"));
     53        assertSwitch(new Tag("direction", "backward"), new Tag("direction", "forward"));
     54        assertSwitch(new Tag("direction", "north"), new Tag("direction", "south"));
     55        assertSwitch(new Tag("direction", "NNE"), new Tag("direction", "SSW"));
     56        assertSwitch(new Tag("direction", "270"), new Tag("direction", "90"));
     57        assertSwitch(new Tag("direction", "135"), new Tag("direction", "315"));
     58        assertSwitch(new Tag("direction", "337"), new Tag("direction", "157"));
    4159        // :left/:right with oneway (see #10977)
    4260        assertSwitch(new Tag("cycleway:left:oneway", "-1"), new Tag("cycleway:right:oneway", "yes"));
     
    99117        Assert.assertEquals(ReverseWayTagCorrector.TagSwitcher.apply(oldTag), newTag);
    100118    }
     119
     120    /**
     121     * Test tag correction on way nodes
     122     */
     123    @Test
     124    public void testSwitchingWayNodes() {
     125        final OsmPrimitive n1 = OsmUtils.createPrimitive("node");
     126        final OsmPrimitive n2 = OsmUtils.createPrimitive("node direction=SSW");
     127        final OsmPrimitive n3 = OsmUtils.createPrimitive("node");
     128        final Way w = new Way();
     129        Stream.of(n1, n2, n3).map(Node.class::cast).forEach(w::addNode);
     130        final Map<OsmPrimitive, List<TagCorrection>> tagCorrections = ReverseWayTagCorrector.getTagCorrectionsMap(w);
     131        Assert.assertEquals(1, tagCorrections.size());
     132        Assert.assertEquals(Collections.singleton(n2),
     133                tagCorrections.keySet());
     134        Assert.assertEquals(Collections.singletonList(new TagCorrection("direction", "SSW", "direction", "NNE")),
     135                tagCorrections.values().iterator().next());
     136    }
    101137}
Note: See TracChangeset for help on using the changeset viewer.