Changeset 17759 in josm


Ignore:
Timestamp:
2021-04-12T21:20:34+02:00 (4 years ago)
Author:
simon04
Message:

fix #20751 - Add MapCSS function mod (modulo)

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/resources/data/validator/addresses.mapcss

    r16708 r17759  
    11/* #10232 */
    2 way[addr:interpolation=odd] > node[addr:housenumber][get(split(".", tag("addr:housenumber")/2), 1)=0] {
     2way[addr:interpolation=odd] > node[addr:housenumber][mod(tag("addr:housenumber"),2)=0] {
    33    throwWarning: tr("Even housenumber in odd address interpolation.");
    44}
    5 way[addr:interpolation=even] > node[addr:housenumber][get(split(".", tag("addr:housenumber")/2), 1)=5] {
     5way[addr:interpolation=even] > node[addr:housenumber][mod(tag("addr:housenumber"),2)=1] {
    66    throwWarning: tr("Odd housenumber in even address interpolation.");
    77}
  • trunk/resources/data/validator/combinations.mapcss

    r17481 r17759  
    647647
    648648/* #14125, #14323, #18185 */
    649 way[highway][lanes][!lanes:forward][!lanes:backward][oneway!=yes][oneway!=-1][oneway!=reversible][highway!=motorway][junction!=roundabout][lanes>2][get(split(".", tag(lanes)/2), 1)=5] {
     649way[highway][lanes][!lanes:forward][!lanes:backward][oneway!=yes][oneway!=-1][oneway!=reversible][highway!=motorway][junction!=roundabout][lanes>2][mod(tag(lanes),2)=1] {
    650650  throwWarning: tr("street with odd number of {0}, but without {1} and {2} or {3}", "{1.key}", "{2.key}", "{3.key}", "{4.key}");
    651651  group: tr("missing tag");
     
    667667  assertNoMatch: "way highway=primary turn:lanes=left|right lanes=2";
    668668}
    669 way[highway][!lanes:forward][/^.*:lanes:forward$/][!lanes:backward][!get(split(".", tag(lanes)/2), 1)=5],
    670 way[highway][!lanes:backward][/^.*:lanes:backward$/][!lanes:forward][!get(split(".", tag(lanes)/2), 1)=5] {
     669way[highway][!lanes:forward][/^.*:lanes:forward$/][!lanes:backward][mod(tag(lanes),2)=0],
     670way[highway][!lanes:backward][/^.*:lanes:backward$/][!lanes:forward][mod(tag(lanes),2)=0] {
    671671  throwOther: tr("{0} without {1}", "{2.key}", "{1.key}");
    672672  group: tr("missing tag");
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java

    r17758 r17759  
    190190        FACTORY_MAP.put("lower", Factory.of(String.class, Functions::lower));
    191191        FACTORY_MAP.put("minus", Factory.ofNumberVarArgs(Functions::minus));
     192        FACTORY_MAP.put("mod", Factory.of(float.class, float.class, Functions::mod));
    192193        FACTORY_MAP.put("not", Factory.of(boolean.class, Functions::not));
    193194        FACTORY_MAP.put("not_equal", Factory.of(Object.class, Object.class, Functions::not_equal));
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Functions.java

    r17758 r17759  
    112112
    113113    /**
     114     * Function associated to the math modulo "%" operator.
     115     * @param a first value
     116     * @param b second value
     117     * @return {@code a mod b}, e.g., {@code mod(7, 5) = 2}
     118     */
     119    public static float mod(float a, float b) { // NO_UCD (unused code)
     120        return a % b;
     121    }
     122
     123    /**
    114124     * Creates a list of values, e.g., for the {@code dashes} property.
    115125     * @param ignored The environment (ignored)
Note: See TracChangeset for help on using the changeset viewer.