- Timestamp:
- 2012-11-24T23:13:00+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java
r4390 r5599 71 71 } 72 72 73 private static PrefixSuffixSwitcher[] prefixSuffixSwitchers =73 private static final PrefixSuffixSwitcher[] prefixSuffixSwitchers = 74 74 new PrefixSuffixSwitcher[] { 75 75 new PrefixSuffixSwitcher("left", "right"), … … 81 81 }; 82 82 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 */ 86 89 public static boolean isReversible(Way way) { 87 90 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 } 89 96 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 } 94 102 return true; 95 103 } … … 126 134 String newValue = value; 127 135 128 if (key. equals("oneway")) {136 if (key.startsWith("oneway") || key.endsWith("oneway")) { 129 137 if (OsmUtils.isReversed(value)) { 130 138 newValue = OsmUtils.trueval; … … 132 140 newValue = OsmUtils.reverseval; 133 141 } 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")) { 135 144 PrefixSuffixSwitcher switcher = new PrefixSuffixSwitcher("up", "down"); 136 145 newValue = switcher.apply(value);
Note:
See TracChangeset
for help on using the changeset viewer.