Class UomRescaleStyleVisitor

  • All Implemented Interfaces:
    StyleVisitor

    public class UomRescaleStyleVisitor
    extends DuplicatingStyleVisitor
    Visitor used for rescaling a Style given a map scale (e.g., meters per pixel) and taking into consideration the Unit of Measure (UOM, e.g., SI.METRE, USCustomary.FOOT) of each symbolizer. The resulting Style's Symbolizer sizes will all be given in PIXELS, so that they can be directly used by a renderer that is unaware of units of measure or the current map scale. For example, points with size == 100 meters could be rescaled to 10 pixels for higher levels of zoom and 2 pixels for a lower level of zoom.

    This visitor extends DuplicatingStyleVisitor and as such yields a copy of the original Style. Usage is simply to call the desired visit() method and then call getCopy() to retrieve the result.

    Author:
    milton, Andrea Aime - GeoSolutions
    • Constructor Detail

      • UomRescaleStyleVisitor

        public UomRescaleStyleVisitor​(double mapScale)
        Constructor: requires the current mapScale to inform the window to viewport (world to screen) relation in order to correctly rescaleDashArray sizes according to units of measure given in world units (e.g., SI.METRE, USCustomary.FOOT, etc).
        Parameters:
        mapScale - The specified map scale, given in pixels per meter.
    • Method Detail

      • rescale

        protected Expression rescale​(Expression unscaled,
                                     Unit<Length> uom)
        Used to rescaleDashArray the provided unscaled value.
        Parameters:
        unscaled - the unscaled value.
        uom - the unit of measure that will be used to scale.
        Returns:
        the expression multiplied by the provided scale.
      • rescaleDashArray

        protected List<Expression> rescaleDashArray​(List<Expression> expressions,
                                                    Unit<Length> uom)
        Rescale a list of expressions, can handle null.
      • rescale

        protected String rescale​(String unscaled,
                                 Unit<Length> uom)
        Used to rescaleDashArray the provided unscaled value.
        Parameters:
        unscaled - the unscaled value.
        uom - the unit of measure that will be used to scale.
        Returns:
        the expression multiplied by the provided scale.
      • rescaleStroke

        protected void rescaleStroke​(Stroke stroke,
                                     Unit<Length> uom)
        Used to rescaleDashArray the provided stroke.
        Parameters:
        stroke - the unscaled stroke, which will be modified in-place.
        uom - the unit of measure that will be used to scale.