Ignore:
Timestamp:
2015-04-15T23:51:33+02:00 (11 years ago)
Author:
simon04
Message:

see #10217 - Enable rotating icons with MapCSS

The corresponding key is icon-rotation and takes angles in the following forms:
[rad], [rad]rad, [deg]°, [deg]deg, or a cardinal direction
(e.g., northeast, sw).

In addition, the following MapCSS functions are provided:
degree_to_radians, cardinal_to_radians

File:
1 edited

Legend:

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

    r7937 r8199  
    3030import org.openstreetmap.josm.gui.mappaint.Cascade;
    3131import org.openstreetmap.josm.gui.mappaint.Environment;
     32import org.openstreetmap.josm.gui.util.RotationAngle;
    3233import org.openstreetmap.josm.io.XmlWriter;
    3334import org.openstreetmap.josm.tools.ColorHelper;
     
    547548
    548549        /**
     550         * Converts an angle in degrees to radians.
     551         * @param degree the angle in degrees
     552         * @return the angle in radians
     553         * @see Math#toRadians(double)
     554         */
     555        public static double degree_to_radians(double degree) {
     556            return Math.toRadians(degree);
     557        }
     558
     559        /**
     560         * Converts an angle diven in cardinal directions to radians.
     561         * The following values are supported: {@code n}, {@code north}, {@code ne}, {@code northeast},
     562         * {@code e}, {@code east}, {@code se}, {@code southeast}, {@code s}, {@code south},
     563         * {@code sw}, {@code southwest}, {@code w}, {@code west}, {@code nw}, {@code northwest}.
     564         * @param cardinal the angle in cardinal directions.
     565         * @see RotationAngle#parseCardinalRotation(String)
     566         * @return the angle in radians
     567         */
     568        public static Double cardinal_to_radians(String cardinal) {
     569            try {
     570                return RotationAngle.parseCardinalRotation(cardinal);
     571            } catch (IllegalArgumentException ignore) {
     572                return null;
     573            }
     574        }
     575
     576        /**
    549577         * Determines if the objects {@code a} and {@code b} are equal.
    550578         * @param a First object
Note: See TracChangeset for help on using the changeset viewer.