Changeset 18664 in josm for trunk/src


Ignore:
Timestamp:
2023-02-15T18:22:07+01:00 (14 months ago)
Author:
taylor.smock
Message:

Fix #22704: Add parent_way_angle mapcss function (patch by Woazboat)

Location:
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java

    r17916 r18664  
    217217        FACTORY_MAP.put("parent_tag", Factory.ofEnv(String.class, Functions::parent_tag));
    218218        FACTORY_MAP.put("parent_tags", Factory.ofEnv(String.class, Functions::parent_tags));
     219        FACTORY_MAP.put("parent_way_angle", Factory.ofEnv(Functions::parent_way_angle));
    219220        FACTORY_MAP.put("plus", Factory.ofNumberVarArgs(0.0, DoubleUnaryOperator.identity(), Functions::plus));
    220221        FACTORY_MAP.put("print", Factory.of(Object.class, Functions::print));
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Functions.java

    r18489 r18664  
    4242import org.openstreetmap.josm.tools.Territories;
    4343import org.openstreetmap.josm.tools.Utils;
     44import org.openstreetmap.josm.tools.RotationAngle.WayDirectionRotationAngle;
    4445
    4546/**
     
    479480
    480481    /**
     482     * Get the rotation angle of the preceding parent way segment at the node location.
     483     * If there is no preceding parent way segment, the following way segment is used instead.
     484     * Requires a parent way object matched via
     485     * <a href="https://josm.openstreetmap.de/wiki/Help/Styles/MapCSSImplementation#LinkSelector">child selector</a>.
     486     *
     487     * @param env the environment
     488     * @return the rotation angle of the parent way segment at the node in radians,
     489     * otherwise null if there is no matching parent way or the object is not a node
     490     * @since 18664
     491     */
     492    public static Double parent_way_angle(final Environment env) {
     493        if (env.osm instanceof Node && env.parent instanceof Way) {
     494            return WayDirectionRotationAngle.getRotationAngleForNodeOnWay((Node) env.osm, (Way) env.parent);
     495        }
     496        return null;
     497    }
     498
     499    /**
    481500     * Gets the value of the key {@code key} from the object's child.
    482501     * @param env the environment
Note: See TracChangeset for help on using the changeset viewer.