Changeset 11069 in josm for trunk/test


Ignore:
Timestamp:
2016-10-01T22:08:48+02:00 (3 years ago)
Author:
simon04
Message:

fix #10260 - Do not switch (absolute) cardinal directions / degrees

File:
1 edited

Legend:

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

    r11061 r11069  
    5353        assertSwitch(new Tag("direction", "backward"), new Tag("direction", "forward"));
    5454        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"));
    5955        // :left/:right with oneway (see #10977)
    6056        assertSwitch(new Tag("cycleway:left:oneway", "-1"), new Tag("cycleway:right:oneway", "yes"));
     
    118114    }
    119115
     116    private Map<OsmPrimitive, List<TagCorrection>> getTagCorrectionsForWay(String middleNodeTags) {
     117        final OsmPrimitive n1 = OsmUtils.createPrimitive("node");
     118        final OsmPrimitive n2 = OsmUtils.createPrimitive("node " + middleNodeTags);
     119        final OsmPrimitive n3 = OsmUtils.createPrimitive("node");
     120        final Way w = new Way();
     121        Stream.of(n1, n2, n3).map(Node.class::cast).forEach(w::addNode);
     122        return ReverseWayTagCorrector.getTagCorrectionsMap(w);
     123    }
     124
    120125    /**
    121126     * Test tag correction on way nodes
     
    123128    @Test
    124129    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);
     130        final Map<OsmPrimitive, List<TagCorrection>> tagCorrections = getTagCorrectionsForWay("direction=forward");
    131131        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")),
     132        Assert.assertEquals(Collections.singletonList(new TagCorrection("direction", "forward", "direction", "backward")),
    135133                tagCorrections.values().iterator().next());
    136134    }
     135
     136    /**
     137     * Test tag correction on way nodes are not applied for absolute values such as compass cardinal directions
     138     */
     139    @Test
     140    public void testNotSwitchingWayNodes() {
     141        Assert.assertEquals(0, getTagCorrectionsForWay("direction=SSW").size());
     142        Assert.assertEquals(0, getTagCorrectionsForWay("direction=145").size());
     143    }
    137144}
Note: See TracChangeset for help on using the changeset viewer.