IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
| 204 | | * Inverts sign of a numeric value. |
| | 204 | * Inverts sign of a numeric value and converts decimal number to use decimal point. |
| | 205 | * Also removes sign from null value. |
| 205 | 206 | * @param value numeric value |
| 206 | 207 | * @return opposite numeric value |
| 207 | 208 | */ |
| 208 | 209 | public static String invertNumber(String value) { |
| 209 | | Pattern pattern = Pattern.compile("^([+-]?)(\\d.*)$", Pattern.CASE_INSENSITIVE); |
| | 210 | Pattern pattern = Pattern.compile("^([+-]?)(\\d*[,.]?\\d*)(.*)$", Pattern.CASE_INSENSITIVE); |
| 210 | 211 | Matcher matcher = pattern.matcher(value); |
| 211 | 212 | if (!matcher.matches()) return value; |
| 212 | 213 | String sign = matcher.group(1); |
| 213 | | String rest = matcher.group(2); |
| | 214 | String number = matcher.group(2); |
| | 215 | String symbol = matcher.group(3); |
| 214 | 216 | sign = "-".equals(sign) ? "" : "-"; |
| 215 | | return sign + rest; |
| | 217 | |
| | 218 | if (!number.isEmpty()) { |
| | 219 | String fixedNum = number.replace(",", "."); |
| | 220 | double parsed = Double.parseDouble(fixedNum); |
| | 221 | if (parsed != 0) { |
| | 222 | return sign + fixedNum + symbol; |
| | 223 | } else { |
| | 224 | return fixedNum + symbol; |
| | 225 | } |
| | 226 | } |
| | 227 | |
| | 228 | return value; |
| 216 | 229 | } |
| 217 | 230 | |
| 218 | 231 | static List<TagCorrection> getTagCorrections(Tagged way) { |
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
|
| 58 | 58 | assertSwitch(new Tag(k, "down"), new Tag(k, "up")); |
| 59 | 59 | assertSwitch(new Tag(k, "something"), new Tag(k, "something")); |
| 60 | 60 | } |
| | 61 | // numbered incline (see #19508) |
| | 62 | assertSwitch(new Tag("incline", "+0%"), new Tag("incline", "0%")); |
| | 63 | assertSwitch(new Tag("incline", ".1%"), new Tag("incline", "-.1%")); |
| | 64 | assertSwitch(new Tag("incline", "-10.0%"), new Tag("incline", "10.0%")); |
| | 65 | assertSwitch(new Tag("incline", "0,6°"), new Tag("incline", "-0.6°")); |
| 61 | 66 | // direction=forward/backward/... |
| 62 | 67 | assertSwitch(new Tag("direction", "forward"), new Tag("direction", "backward")); |
| 63 | 68 | assertSwitch(new Tag("direction", "backward"), new Tag("direction", "forward")); |
| … |
… |
|
| 99 | 104 | } |
| 100 | 105 | |
| 101 | 106 | private void assertSwitch(Tag oldTag, Tag newTag) { |
| 102 | | Assert.assertEquals(ReverseWayTagCorrector.TagSwitcher.apply(oldTag), newTag); |
| | 107 | Assert.assertEquals(newTag, ReverseWayTagCorrector.TagSwitcher.apply(oldTag)); |
| 103 | 108 | } |
| 104 | 109 | |
| 105 | 110 | private Map<OsmPrimitive, List<TagCorrection>> getTagCorrectionsForWay(String middleNodeTags) { |