Changeset 17916 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
r17832 r17916 228 228 FACTORY_MAP.put("rgba", Factory.of(float.class, float.class, float.class, float.class, Functions::rgba)); 229 229 FACTORY_MAP.put("role", Factory.ofEnv(Functions::role)); 230 FACTORY_MAP.put("round", Factory.of(Math:: acos));230 FACTORY_MAP.put("round", Factory.of(Math::round)); 231 231 FACTORY_MAP.put("setting", Factory.ofEnv(String.class, Functions::setting)); 232 232 FACTORY_MAP.put("signum", Factory.of(Math::signum)); -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java
r17619 r17916 425 425 426 426 /** 427 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/19053">Bug #19053</a>. 428 * Mapcss rule with group. 427 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/19053">Bug #19053</a> and 428 * <a href="https://josm.openstreetmap.de/ticket/20957">Bug #20957</a> 429 * - MapCSS rule with group. 430 * - MapCSS functions round, tag, *, / 429 431 * @throws ParseException if a parsing error occurs 430 432 */ … … 434 436 "*[ele][ele =~ /^-?[0-9]+\\.[0-9][0-9][0-9]+$/] {" 435 437 + "throwWarning: tr(\"{0}\",\"{0.tag}\");" 438 + "fixAdd: concat(\"ele=\", round(tag(\"ele\")*100)/100);" 436 439 + "group: tr(\"Unnecessary amount of decimal places\");" + "}"); 437 440 final OsmPrimitive p = OsmUtils.createPrimitive("node ele=12.123456"); 441 new DataSet(p); 438 442 final Collection<TestError> errors = test.getErrorsForPrimitive(p, false); 439 443 assertEquals(1, errors.size()); … … 441 445 assertEquals("3000_ele=12.123456", errors.iterator().next().getIgnoreSubGroup()); 442 446 assertEquals("3000_Unnecessary amount of decimal places", errors.iterator().next().getIgnoreGroup()); 447 Command fix = errors.iterator().next().getFix(); 448 assertNotNull(fix); 449 assertEquals("12.123456", p.get("ele")); 450 fix.executeCommand(); 451 assertEquals("12.12", p.get("ele")); 443 452 } 444 453 -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.java
r17832 r17916 615 615 "null1: tag(x1) + tag(x2);" + 616 616 "null2: 3 + tag(does_not_exist) + 5;" + 617 "rounding: concat(\"ele=\", round(tag(\"ele\")*100)/100);" + 617 618 "}"); 618 619 source.loadStyleSource(); … … 628 629 assertNull(mc.getCascade(null).get("null1")); 629 630 assertEquals(8.0, mc.getCascade(null).get("null2")); 631 assertEquals(8.0, mc.getCascade(null).get("rounding")); 630 632 } 631 633 … … 738 740 assertNull(mc.getCascade(null).get("name")); 739 741 } 742 743 /** 744 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/20957">Bug #20957</a>. 745 */ 746 @Test 747 void testTicket20957() { 748 MapCSSStyleSource source = new MapCSSStyleSource("node {fixAdd: concat(\"ele=\", round(tag(\"ele\")*100)/100)}"); 749 source.loadStyleSource(); 750 MultiCascade mc = new MultiCascade(); 751 source.apply(mc, OsmUtils.createPrimitive("node ele=12.123456"), 20, false); 752 assertEquals("ele=12.12", mc.getCascade(null).get("fixAdd")); 753 } 740 754 }
Note:
See TracChangeset
for help on using the changeset viewer.