Search in sources :

Example 31 with Expression

use of org.opengis.filter.Expression in project geotoolkit by Geomatys.

the class XMLUtilitiesTest method createRasterSymbolizer.

private static RasterSymbolizer createRasterSymbolizer() {
    String name = "Raster symbolizer name";
    Description desc = STYLE_FACTORY.description("Raster symbolizer title", "Raster symbolizer description");
    Unit uom = Units.METRE;
    String geom = "geom";
    Expression opacity = FILTER_FACTORY.literal(0.5);
    ChannelSelection selection = STYLE_FACTORY.channelSelection(STYLE_FACTORY.selectedChannelType("chanel2", FILTER_FACTORY.literal(1)));
    OverlapBehavior overlap = OverlapBehavior.RANDOM;
    ColorMap colorMap = STYLE_FACTORY.colorMap();
    ContrastEnhancement enchance = STYLE_FACTORY.contrastEnhancement();
    ShadedRelief relief = STYLE_FACTORY.shadedRelief(FILTER_FACTORY.literal(3), true);
    Symbolizer outline = createLineSymbolizer();
    return STYLE_FACTORY.rasterSymbolizer(name, geom, desc, uom, opacity, selection, overlap, colorMap, enchance, relief, outline);
}
Also used : Description(org.opengis.style.Description) ContrastEnhancement(org.opengis.style.ContrastEnhancement) Expression(org.opengis.filter.Expression) ChannelSelection(org.opengis.style.ChannelSelection) ColorMap(org.opengis.style.ColorMap) SimpleInternationalString(org.apache.sis.util.SimpleInternationalString) Unit(javax.measure.Unit) ShadedRelief(org.opengis.style.ShadedRelief) PointSymbolizer(org.opengis.style.PointSymbolizer) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer) LineSymbolizer(org.opengis.style.LineSymbolizer) RasterSymbolizer(org.opengis.style.RasterSymbolizer) TextSymbolizer(org.opengis.style.TextSymbolizer) Symbolizer(org.opengis.style.Symbolizer) OverlapBehavior(org.opengis.style.OverlapBehavior)

Example 32 with Expression

use of org.opengis.filter.Expression in project geotoolkit by Geomatys.

the class XMLUtilitiesTest method createTextSymbolizer.

private static TextSymbolizer createTextSymbolizer() {
    String name = "Text symbolizer name";
    Description desc = STYLE_FACTORY.description("Text symbolizer title", "Text symbolizer description");
    Unit uom = Units.FOOT;
    String geom = "geom";
    Fill fill = STYLE_FACTORY.fill(Color.ORANGE);
    Halo halo = STYLE_FACTORY.halo(Color.PINK, 12);
    PointPlacement placement = STYLE_FACTORY.pointPlacement();
    Font font = STYLE_FACTORY.font();
    Expression label = FILTER_FACTORY.literal("the feature field name");
    return STYLE_FACTORY.textSymbolizer(name, geom, desc, uom, label, font, placement, halo, fill);
}
Also used : Fill(org.opengis.style.Fill) PointPlacement(org.opengis.style.PointPlacement) Description(org.opengis.style.Description) Expression(org.opengis.filter.Expression) SimpleInternationalString(org.apache.sis.util.SimpleInternationalString) Unit(javax.measure.Unit) Halo(org.opengis.style.Halo) Font(org.opengis.style.Font)

Example 33 with Expression

use of org.opengis.filter.Expression in project geotoolkit by Geomatys.

the class JavaScriptFunction method prepare.

private static Expression[] prepare(final Expression jsFunction) {
    final String str = jsFunction.apply(null).toString();
    final List<Expression> properties = new ArrayList<Expression>();
    properties.add(jsFunction);
    String current = null;
    for (int i = 0, n = str.length(); i < n; i++) {
        char c = str.charAt(i);
        if (current != null) {
            if (END_CHARACTERS.contains(c)) {
                if (!current.isEmpty()) {
                    properties.add(new DefaultPropertyName(current));
                }
                current = null;
            } else {
                current += c;
            }
        } else {
            if (c == VAR_CHARACTER) {
                current = "";
            }
        }
    }
    if (current != null && !current.isEmpty()) {
        properties.add(new DefaultPropertyName(current));
    }
    return properties.toArray(new Expression[properties.size()]);
}
Also used : Expression(org.opengis.filter.Expression) ArrayList(java.util.ArrayList) DefaultPropertyName(org.geotoolkit.filter.DefaultPropertyName)

Example 34 with Expression

use of org.opengis.filter.Expression in project geotoolkit by Geomatys.

the class PropertyExistsFunction method equals.

@Override
public boolean equals(final Object obj) {
    if (obj == this) {
        return true;
    }
    if (!(obj instanceof PropertyExistsFunction)) {
        return false;
    }
    PropertyExistsFunction other = (PropertyExistsFunction) obj;
    if (other.getParameters().size() != this.getParameters().size()) {
        return false;
    }
    if (other.getParameters().size() > 0) {
        final String propName = getPropertyName();
        final Expression otherPropNameExpr = (Expression) other.getParameters().get(0);
        final String otherPropName = getPropertyName(otherPropNameExpr);
        return Objects.equals(propName, otherPropName);
    } else {
        return true;
    }
}
Also used : Expression(org.opengis.filter.Expression)

Example 35 with Expression

use of org.opengis.filter.Expression in project geotoolkit by Geomatys.

the class AbstractFunctionFactory method createFunction.

@Override
public Expression createFunction(String name, Literal fallback, Expression... parameters) throws IllegalArgumentException {
    final Class clazz = functions.get(name);
    if (clazz == null) {
        throw new IllegalArgumentException("Unknowed function name : " + name);
    }
    final Constructor construct = clazz.getConstructors()[0];
    final Object[] cstParams = new Object[construct.getParameterTypes().length];
    for (int i = 0; i < cstParams.length && i < parameters.length; i++) {
        cstParams[i] = parameters[i];
    }
    try {
        return (Expression) construct.newInstance(cstParams);
    } catch (InstantiationException | IllegalAccessException | InvocationTargetException ex) {
        throw new IllegalArgumentException("Failed to initialize function wih given parameters : " + name + "  " + ex.getMessage(), ex);
    }
}
Also used : Expression(org.opengis.filter.Expression) Constructor(java.lang.reflect.Constructor) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

Expression (org.opengis.filter.Expression)325 Test (org.junit.Test)112 LineString (org.locationtech.jts.geom.LineString)73 Literal (org.opengis.filter.Literal)65 ArrayList (java.util.ArrayList)47 MultiLineString (org.locationtech.jts.geom.MultiLineString)46 Unit (javax.measure.Unit)45 Description (org.opengis.style.Description)40 Fill (org.opengis.style.Fill)38 GraphicFill (org.opengis.style.GraphicFill)38 Stroke (org.opengis.style.Stroke)35 Geometry (org.locationtech.jts.geom.Geometry)31 Displacement (org.opengis.style.Displacement)29 GraphicStroke (org.opengis.style.GraphicStroke)29 ValueReference (org.opengis.filter.ValueReference)27 JAXBElement (javax.xml.bind.JAXBElement)22 LineSymbolizer (org.opengis.style.LineSymbolizer)22 PointSymbolizer (org.opengis.style.PointSymbolizer)22 PolygonSymbolizer (org.opengis.style.PolygonSymbolizer)22 MutableStyle (org.geotoolkit.style.MutableStyle)21