Ignore:
Timestamp:
2012-11-24T23:13:00+01:00 (11 years ago)
Author:
simon04
Message:

fix #8188 - oneway:*=* not warning, if way direction changed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java

    r4390 r5599  
    7171    }
    7272
    73     private static PrefixSuffixSwitcher[] prefixSuffixSwitchers =
     73    private static final PrefixSuffixSwitcher[] prefixSuffixSwitchers =
    7474        new PrefixSuffixSwitcher[] {
    7575        new PrefixSuffixSwitcher("left", "right"),
     
    8181    };
    8282
    83     private static ArrayList<String> reversibleTags = new ArrayList<String>(
    84             Arrays.asList(new String[] {"oneway", "incline", "direction"}));
    85 
     83    /**
     84     * Tests whether way can be reversed without semantic change, i.e., whether tags have to be changed.
     85     * Looks for keys like oneway, oneway:bicycle, cycleway:right:oneway, left/right.
     86     * @param way
     87     * @return false if tags should be changed to keep semantic, true otherwise.
     88     */
    8689    public static boolean isReversible(Way way) {
    8790        for (String key : way.keySet()) {
    88             if (reversibleTags.contains(key)) return false;
     91            for (String k : Arrays.asList("oneway", "incline", "direction")) {
     92                if (key.startsWith(k) || key.endsWith(k)) {
     93                    return false;
     94                }
     95            }
    8996            for (PrefixSuffixSwitcher prefixSuffixSwitcher : prefixSuffixSwitchers) {
    90                 if (!key.equals(prefixSuffixSwitcher.apply(key))) return false;
    91             }
    92         }
    93 
     97                if (!key.equals(prefixSuffixSwitcher.apply(key))) {
     98                    return false;
     99                }
     100            }
     101        }
    94102        return true;
    95103    }
     
    126134            String newValue = value;
    127135
    128             if (key.equals("oneway")) {
     136            if (key.startsWith("oneway") || key.endsWith("oneway")) {
    129137                if (OsmUtils.isReversed(value)) {
    130138                    newValue = OsmUtils.trueval;
     
    132140                    newValue = OsmUtils.reverseval;
    133141                }
    134             } else if (key.equals("incline") || key.equals("direction")) {
     142            } else if (key.startsWith("incline") || key.endsWith("incline")
     143                    || key.startsWith("direction") || key.endsWith("direction")) {
    135144                PrefixSuffixSwitcher switcher = new PrefixSuffixSwitcher("up", "down");
    136145                newValue = switcher.apply(value);
Note: See TracChangeset for help on using the changeset viewer.