Ticket #19714: 19714v1_(WIP).patch

File 19714v1_(WIP).patch, 3.1 KB (added by gaben, 6 years ago)

Ignore directional ways which have two_sided=yes tag

  • src/org/openstreetmap/josm/actions/corrector/ReverseWayNoTagCorrector.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    5252     */
    5353    public static TagCollection getDirectionalTags(Tagged way) {
    5454        final TagCollection collection = new TagCollection();
     55
     56        // TODO: uncomment the next line if needed
     57        //final Tag cityWall = new Tag("barrier", "city_wall");
     58
    5559        for (Map.Entry<String, String> entry : way.getKeys().entrySet()) {
    5660            final Tag tag = new Tag(entry.getKey(), entry.getValue());
    5761            final boolean isDirectional = DIRECTIONAL_TAGS.contains(tag) || tag.isDirectionKey();
    5862            if (isDirectional) {
    5963                final boolean cannotBeCorrected = ReverseWayTagCorrector.getTagCorrections(tag).isEmpty();
    60                 if (cannotBeCorrected) {
     64
     65                // TODO: delete the inline comment if you want to restrict two_sided for city_wall only
     66                if (cannotBeCorrected && !(/*tag.equals(cityWall) && */way.isKeyTrue("two_sided"))) {
     67                    // two_sided=yes is a special (documented) barrier=city_wall attribute, see #197140
    6168                    collection.add(tag);
    6269                }
    6370            }
  • test/unit/org/openstreetmap/josm/actions/corrector/ReverseWayNoTagCorrectorTest.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    66import org.junit.Rule;
    77import org.junit.Test;
    88import org.openstreetmap.josm.data.osm.Tag;
     9import org.openstreetmap.josm.data.osm.Tagged;
     10import org.openstreetmap.josm.data.osm.Way;
    911import org.openstreetmap.josm.testutils.JOSMTestRules;
    1012
    1113import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    3335        assertEquals(0, ReverseWayNoTagCorrector.getDirectionalTags(new Tag("aerialway", "station")).size());
    3436        assertEquals(0, ReverseWayNoTagCorrector.getDirectionalTags(new Tag("incline", "up")).size());
    3537        assertEquals(0, ReverseWayNoTagCorrector.getDirectionalTags(new Tag("oneway", "yes")).size());
     38        assertEquals(1, ReverseWayNoTagCorrector.getDirectionalTags(new Tag("barrier", "kerb")).size());
     39        assertEquals(1, ReverseWayNoTagCorrector.getDirectionalTags(new Tag("barrier", "city_wall")).size());
     40
     41        final Tagged twoSidedCityWall = new Way();
     42        twoSidedCityWall.put("barrier", "city_wall");
     43        twoSidedCityWall.put("two_sided", "yes");
     44        assertEquals(0, ReverseWayNoTagCorrector.getDirectionalTags(twoSidedCityWall).size());
    3645    }
    3746}