- Timestamp:
- 2016-10-01T22:08:48+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java
r11061 r11069 5 5 6 6 import java.util.ArrayList; 7 import java.util.Arrays;8 7 import java.util.Collection; 9 8 import java.util.HashMap; … … 80 79 }; 81 80 } 82 83 static IStringSwitcher compassCardinal() {84 final List<String> cardinal = Arrays.asList(85 "N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE",86 "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW");87 return key -> {88 final int index = cardinal.indexOf(key);89 if (index >= 0) {90 return cardinal.get((index + cardinal.size() / 2) % cardinal.size());91 }92 return key;93 };94 }95 96 static IStringSwitcher compassDegrees() {97 return key -> {98 if (!key.matches("\\d+")) {99 return key;100 }101 final int i = Integer.parseInt(key);102 if (i < 0 || i > 360) {103 return key;104 }105 return Integer.toString((i + 180) % 360);106 };107 }108 109 static IStringSwitcher compass() {110 return combined(111 IStringSwitcher.compassCardinal(),112 IStringSwitcher.compassDegrees()113 );114 }115 81 } 116 82 … … 188 154 } else if (key.startsWith("direction") || key.endsWith("direction")) { 189 155 newValue = COMBINED_SWITCHERS.apply(value); 190 if (newValue.equals(value)) {191 newValue = IStringSwitcher.compass().apply(value);192 }193 156 } else if (key.endsWith(":forward") || key.endsWith(":backward")) { 194 157 // Change key but not left/right value (fix #8518)
Note:
See TracChangeset
for help on using the changeset viewer.