stroke dasharray as an expression - STEMLab/geotools GitHub Wiki

Description

Allow SLD stroke-dasharray property to support expressions.

Approach used is similar to how Symbolizer was extended to support PropertyName.

The interface org.opengis.style.Stroke provides a float[] (and is only useful when all the expressions are literals):

package org.opengis.style;
public interface Stroke {
    ...
    @XmlParameter("stroke-dasharray")
    float[] getDashArray();
    ...
}

GeoTools org.geotools.styling.Stroke interface provides access to a List for dash array.

package org.geotools.styling;
public interface Stroke extends org.opengis.style.Stroke {
    /** Shortcut to retrieve dash array in the case where all expressions are literal numbers */
    float[] getDashArray();

    /** Shortcut to define dash array using literal numbers */
    void setDashArray(float[] dashArray);
    
    /** Sequence defining dash array pattern as a series of floats.
     * <p>
     * The first number gives the length in pixels of the dash to draw, the
     * second gives the amount of space to leave, and this pattern repeats.<br>
     * If an odd number of values is given, then the pattern is expanded by
     * repeating it twice to give an even number of values.
     */
    List<Expression> dashArray();
}

References:

Status

Choose one of:

  • Under Discussion
  • In Progress
  • Completed
  • Rejected,
  • Deferred

Voting:

  • Andrea Aime
  • Ben Caradoc-Davies
  • Christian Mueller
  • Ian Turton
  • Justin Deoliveira
  • Jody Garnett +1
  • Simone Giannecchini

Tasks

  1. Update implementation

    • Update Stroke Interface - deprecate float[] references, and add new methods
    • Update StyleFactory - deprecate float[] array method and add Expression method
    • Update StyleBuilder - existing float[] array methods can generate a Literal expression
  2. Verify with test case

    • Add additional methods, existing float[] methods should still work
  3. Update documentation

  4. Release API change in GeoTools 14.0

  5. Remove deprecated code from master after 14-RC is created.

    • StyleBuilder can retain existing float[] methods allowing many clients to remain unmodified
⚠️ **GitHub.com Fallback** ⚠️