use of org.opengis.filter.expression.Expression in project ddf by codice.
the class TestCswRecordMapperFilterVisitor method testVisitPropertyIsEqualTo.
@Test
public void testVisitPropertyIsEqualTo() {
Expression val = factory.literal("foo");
PropertyIsEqualTo filter = factory.equals(attrExpr, val);
PropertyIsEqualTo duplicate = (PropertyIsEqualTo) visitor.visit(filter, null);
assertThat(duplicate.getExpression1(), is(attrExpr));
assertThat(duplicate.getExpression2(), is(val));
assertThat(duplicate.isMatchingCase(), is(true));
}
use of org.opengis.filter.expression.Expression in project ddf by codice.
the class TestCswRecordMapperFilterVisitor method testVisitPropertyIsLessThanTemporal.
@Test
public void testVisitPropertyIsLessThanTemporal() {
Expression val = factory.literal(new Date());
PropertyIsLessThan filter = factory.less(created, val);
Object obj = visitor.visit(filter, null);
assertThat(obj, instanceOf(Before.class));
Before duplicate = (Before) obj;
assertThat(duplicate.getExpression1(), is(created));
assertThat(duplicate.getExpression2(), is(val));
}
use of org.opengis.filter.expression.Expression in project ddf by codice.
the class TestCswRecordMapperFilterVisitor method testVisitBeyond.
@Test
public void testVisitBeyond() {
GeometryFactory geoFactory = new GeometryFactory();
double val = 30;
Expression pt1 = factory.literal(geoFactory.createPoint(new Coordinate(4, 5)));
Expression pt2 = factory.literal(geoFactory.createPoint(new Coordinate(6, 7)));
Beyond filter = factory.beyond(pt1, pt2, val, "kilometers");
Beyond duplicate = (Beyond) visitor.visit(filter, null);
assertThat(duplicate.getExpression1(), is(pt1));
assertThat(duplicate.getExpression2(), is(pt2));
assertThat(duplicate.getDistanceUnits(), is(UomOgcMapping.METRE.name()));
assertThat(duplicate.getDistance(), is(1000 * val));
}
use of org.opengis.filter.expression.Expression in project ddf by codice.
the class TestCswRecordMapperFilterVisitor method testIntersectsUtm.
@Test
public void testIntersectsUtm() throws FactoryException, TransformException {
double lon = 33.45;
double lat = 25.22;
double easting = 545328.48;
double northing = 2789384.24;
CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:32636");
GeometryFactory geoFactory = new GeometryFactory();
Geometry utmPoint = geoFactory.createPoint(new Coordinate(easting, northing));
utmPoint.setUserData(sourceCRS);
Expression pt1 = factory.literal(geoFactory.createPoint(new Coordinate(1, 2)));
Expression pt2 = factory.literal(utmPoint);
Intersects filter = factory.intersects(pt1, pt2);
visitor.visit(filter, null);
assertThat(pt2, instanceOf(Literal.class));
Literal literalExpression = (Literal) pt2;
assertThat(literalExpression.getValue(), instanceOf(Geometry.class));
Geometry geometry = (Geometry) literalExpression.getValue();
assertThat(geometry.getCoordinates()[0].x, closeTo(lon, .00001));
assertThat(geometry.getCoordinates()[0].y, closeTo(lat, .00001));
}
use of org.opengis.filter.expression.Expression in project ddf by codice.
the class TestCswRecordMapperFilterVisitor method testVisitPropertyIsGreaterThanTemporal.
@Test
public void testVisitPropertyIsGreaterThanTemporal() {
Expression val = factory.literal(new Date(System.currentTimeMillis() - 1000));
Expression test = new AttributeExpressionImpl(new NameImpl(new QName(CswConstants.DUBLIN_CORE_SCHEMA, "TestDate", CswConstants.DUBLIN_CORE_NAMESPACE_PREFIX)));
PropertyIsGreaterThan filter = factory.greater(test, val);
Object obj = visitor.visit(filter, null);
assertThat(obj, instanceOf(During.class));
During duplicate = (During) obj;
assertThat(duplicate.getExpression1(), is(test));
assertThat(duplicate.getExpression2(), is(val));
}
Aggregations