Search in sources :

Example 96 with Expression

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

the class SE110toGTTransformer method visit.

/**
 *  Transform a SLD v1.1 interpolate function in GT interpolate function.
 */
public Interpolate visit(final InterpolateType interpolate) {
    if (interpolate == null)
        return null;
    final Literal fallback = filterFactory.literal(interpolate.getFallbackValue());
    final Expression lookup = visitExpression(interpolate.getLookupValue());
    final Method method;
    if (MethodType.COLOR.equals(interpolate.getMethod())) {
        method = Method.COLOR;
    } else {
        method = Method.NUMERIC;
    }
    final Mode mode;
    if (ModeType.COSINE.equals(interpolate.getMode())) {
        mode = Mode.COSINE;
    } else if (ModeType.CUBIC.equals(interpolate.getMode())) {
        mode = Mode.CUBIC;
    } else {
        mode = Mode.LINEAR;
    }
    final List<InterpolationPoint> values = new ArrayList<InterpolationPoint>();
    for (final InterpolationPointType ip : interpolate.getInterpolationPoint()) {
        values.add(styleFactory.interpolationPoint(ip.getData(), visitExpression(ip.getValue())));
    }
    return styleFactory.interpolateFunction(lookup, values, method, mode, fallback);
}
Also used : InterpolationPoint(org.geotoolkit.style.function.InterpolationPoint) Expression(org.opengis.filter.Expression) Literal(org.opengis.filter.Literal) Mode(org.geotoolkit.style.function.Mode) InterpolationPointType(org.geotoolkit.se.xml.v110.InterpolationPointType) ArrayList(java.util.ArrayList) Method(org.geotoolkit.style.function.Method) ContrastMethod(org.opengis.style.ContrastMethod)

Example 97 with Expression

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

the class ExpressionReadingTest method testPropertyName1.

@Test
public void testPropertyName1() throws CQLException {
    final String cql = "geom";
    final Expression obj = CQL.parseExpression(cql);
    assertTrue(obj instanceof ValueReference);
    final ValueReference expression = (ValueReference) obj;
    assertEquals("geom", expression.getXPath());
}
Also used : Expression(org.opengis.filter.Expression) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString) ValueReference(org.opengis.filter.ValueReference) Test(org.junit.Test)

Example 98 with Expression

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

the class ExpressionReadingTest method testGeometryEnvelopeEmpty.

@Test
public void testGeometryEnvelopeEmpty() throws CQLException {
    final String cql = "ENVELOPE EMPTY";
    final Expression obj = CQL.parseExpression(cql);
    assertTrue(obj instanceof Literal);
    final Literal expression = (Literal) obj;
    final Geometry geom = (Geometry) expression.getValue();
    assertTrue(geom instanceof Polygon);
    assertTrue(geom.isEmpty());
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) Expression(org.opengis.filter.Expression) Literal(org.opengis.filter.Literal) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString) Polygon(org.locationtech.jts.geom.Polygon) MultiPolygon(org.locationtech.jts.geom.MultiPolygon) Test(org.junit.Test)

Example 99 with Expression

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

the class ExpressionReadingTest method testGeometryMPolygonEmpty.

@Test
public void testGeometryMPolygonEmpty() throws CQLException {
    final String cql = "MULTIPOLYGON EMPTY";
    final Expression obj = CQL.parseExpression(cql);
    assertTrue(obj instanceof Literal);
    final Literal expression = (Literal) obj;
    final Geometry geom = (Geometry) expression.getValue();
    assertTrue(geom instanceof MultiPolygon);
    assertTrue(geom.isEmpty());
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) Expression(org.opengis.filter.Expression) MultiPolygon(org.locationtech.jts.geom.MultiPolygon) Literal(org.opengis.filter.Literal) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString) Test(org.junit.Test)

Example 100 with Expression

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

the class ExpressionReadingTest method testGeometryMPolygon.

@Test
public void testGeometryMPolygon() throws CQLException {
    final String cql = "MULTIPOLYGON(" + "((10 20, 30 40, 50 60, 10 20), (70 80, 90 100, 110 120, 70 80))," + "((11 21, 31 41, 51 61, 11 21), (71 81, 91 101, 111 121, 71 81))" + ")";
    final Expression obj = CQL.parseExpression(cql);
    assertTrue(obj instanceof Literal);
    final Literal expression = (Literal) obj;
    final Polygon geom1 = GF.createPolygon(GF.createLinearRing(new Coordinate[] { new Coordinate(10, 20), new Coordinate(30, 40), new Coordinate(50, 60), new Coordinate(10, 20) }), new LinearRing[] { GF.createLinearRing(new Coordinate[] { new Coordinate(70, 80), new Coordinate(90, 100), new Coordinate(110, 120), new Coordinate(70, 80) }) });
    final Polygon geom2 = GF.createPolygon(GF.createLinearRing(new Coordinate[] { new Coordinate(11, 21), new Coordinate(31, 41), new Coordinate(51, 61), new Coordinate(11, 21) }), new LinearRing[] { GF.createLinearRing(new Coordinate[] { new Coordinate(71, 81), new Coordinate(91, 101), new Coordinate(111, 121), new Coordinate(71, 81) }) });
    final Geometry geom = GF.createMultiPolygon(new Polygon[] { geom1, geom2 });
    assertTrue(geom.equals((Geometry) expression.getValue()));
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) Expression(org.opengis.filter.Expression) Coordinate(org.locationtech.jts.geom.Coordinate) Literal(org.opengis.filter.Literal) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString) Polygon(org.locationtech.jts.geom.Polygon) MultiPolygon(org.locationtech.jts.geom.MultiPolygon) Test(org.junit.Test)

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