IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
|
| 206 | 206 | * @return opposite numeric value |
| 207 | 207 | */ |
| 208 | 208 | public static String invertNumber(String value) { |
| 209 | | Pattern pattern = Pattern.compile("^([+-]?)(\\d.*)$", Pattern.CASE_INSENSITIVE); |
| | 209 | Pattern pattern = Pattern.compile("^([+-]?)(\\d*[,.]?\\d*)(.*)$", Pattern.CASE_INSENSITIVE); |
| 210 | 210 | Matcher matcher = pattern.matcher(value); |
| 211 | 211 | if (!matcher.matches()) return value; |
| 212 | 212 | String sign = matcher.group(1); |
| 213 | | String rest = matcher.group(2); |
| | 213 | String number = matcher.group(2); |
| | 214 | String symbol = matcher.group(3); |
| 214 | 215 | sign = "-".equals(sign) ? "" : "-"; |
| 215 | | return sign + rest; |
| | 216 | |
| | 217 | if (!number.isEmpty()) { |
| | 218 | String fixedNum = number.replace(",", "."); |
| | 219 | double parsed = Double.parseDouble(sign + fixedNum); |
| | 220 | if (parsed > 0 || parsed < 0) { |
| | 221 | return sign + number + symbol; |
| | 222 | } |
| | 223 | } |
| | 224 | |
| | 225 | return value; |
| 216 | 226 | } |
| 217 | 227 | |
| 218 | 228 | static List<TagCorrection> getTagCorrections(Tagged way) { |
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
|
| 96 | 96 | assertSwitch(new Tag("something", "prefix_down_suffix"), new Tag("something", "prefix_up_suffix")); |
| 97 | 97 | // #8499 |
| 98 | 98 | assertSwitch(new Tag("type", "drawdown"), new Tag("type", "drawdown")); |
| | 99 | // #19508 |
| | 100 | assertSwitch(new Tag("incline", "0%"), new Tag("incline", "0%")); |
| | 101 | assertSwitch(new Tag("incline", "-10%"), new Tag("incline", "10%")); |
| | 102 | assertSwitch(new Tag("incline", "0.6°"), new Tag("incline", "-0.6°")); |
| | 103 | assertSwitch(new Tag("incline", "-10,33°"), new Tag("incline", "10,33°")); |
| 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) { |