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);
}
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());
}
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());
}
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());
}
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()));
}
Aggregations