IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
|
| 27 | 27 | import org.openstreetmap.josm.data.osm.TagCollection; |
| 28 | 28 | import org.openstreetmap.josm.data.osm.Tagged; |
| 29 | 29 | import org.openstreetmap.josm.data.osm.Way; |
| | 30 | import org.openstreetmap.josm.tools.Logging; |
| 30 | 31 | import org.openstreetmap.josm.tools.UserCancelException; |
| 31 | 32 | |
| 32 | 33 | /** |
| … |
… |
|
| 201 | 202 | } |
| 202 | 203 | |
| 203 | 204 | /** |
| 204 | | * Inverts sign of a numeric value. |
| | 205 | * Inverts sign of a numeric value and converts decimal number to use decimal point. |
| | 206 | * Also removes sign from null value. |
| 205 | 207 | * @param value numeric value |
| 206 | 208 | * @return opposite numeric value |
| 207 | 209 | */ |
| 208 | 210 | public static String invertNumber(String value) { |
| 209 | | Pattern pattern = Pattern.compile("^([+-]?)(\\d.*)$", Pattern.CASE_INSENSITIVE); |
| | 211 | Pattern pattern = Pattern.compile("^([+-]?)(\\d*[,.]?\\d*)(.*)$", Pattern.CASE_INSENSITIVE); |
| 210 | 212 | Matcher matcher = pattern.matcher(value); |
| 211 | 213 | if (!matcher.matches()) return value; |
| 212 | 214 | String sign = matcher.group(1); |
| 213 | | String rest = matcher.group(2); |
| | 215 | String number = matcher.group(2); |
| | 216 | String symbol = matcher.group(3); |
| 214 | 217 | sign = "-".equals(sign) ? "" : "-"; |
| 215 | | return sign + rest; |
| | 218 | |
| | 219 | if (!number.isEmpty()) { |
| | 220 | String fixedNum = number.replace(",", "."); |
| | 221 | try { |
| | 222 | double parsed = Double.parseDouble(fixedNum); |
| | 223 | if (parsed != 0) { |
| | 224 | return sign + fixedNum + symbol; |
| | 225 | } else { |
| | 226 | return fixedNum + symbol; |
| | 227 | } |
| | 228 | } catch (NumberFormatException e) { |
| | 229 | Logging.trace(e); |
| | 230 | return value; |
| | 231 | } |
| | 232 | } |
| | 233 | |
| | 234 | return value; |
| 216 | 235 | } |
| 217 | 236 | |
| 218 | 237 | 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) { |