use of org.opengis.filter.expression.Literal in project ddf by codice.
the class CswRecordMapperFilterVisitor method visit.
@Override
public Object visit(PropertyIsGreaterThanOrEqualTo filter, Object extraData) {
Expression expr1 = visit(filter.getExpression1(), extraData);
Expression expr2 = visit(filter.getExpression2(), expr1);
// work around since Solr Provider doesn't support greaterOrEqual on temporal (DDF-311)
if (isTemporalQuery(expr1, expr2)) {
// also not supported by provider (DDF-311)
//TEquals tEquals = getFactory(extraData).tequals(expr1, expr2);
//After after = getFactory(extraData).after(expr1, expr2);
//return getFactory(extraData).or(tEquals, after);
Object val = null;
Expression other = null;
if (expr2 instanceof Literal) {
val = ((Literal) expr2).getValue();
other = expr1;
} else if (expr1 instanceof Literal) {
val = ((Literal) expr1).getValue();
other = expr2;
}
if (val != null) {
Date orig = (Date) val;
Instant start = new DefaultInstant(new DefaultPosition(orig));
Instant end = new DefaultInstant(new DefaultPosition(new Date()));
DefaultPeriod period = new DefaultPeriod(start, end);
Literal literal = getFactory(extraData).literal(period);
return getFactory(extraData).during(other, literal);
}
} else {
AttributeType type = attributeTypes.get(((PropertyName) filter.getExpression1()).getPropertyName());
LiteralExpressionImpl typedExpression = (LiteralExpressionImpl) filter.getExpression2();
setExpressionType(type, typedExpression);
expr2 = visit((Expression) typedExpression, expr1);
}
return getFactory(extraData).greaterOrEqual(expr1, expr2);
}
use of org.opengis.filter.expression.Literal in project ddf by codice.
the class GeotoolsFilterAdapterImpl method visit.
public Object visit(PropertyIsLessThanOrEqualTo filter, Object delegate) {
ExpressionValues filterValues = getExpressions(filter, delegate);
String propertyName = filterValues.propertyName;
Object literal = filterValues.literal;
// Are property name and literal reversed?
if (filter.getExpression1() instanceof Literal) {
// convert literal <= property to property >= literal
Filter greaterThanOrEqual = FF.greaterOrEqual(FF.property(propertyName), FF.literal(literal));
return greaterThanOrEqual.accept(this, delegate);
}
if (literal instanceof String) {
return ((FilterDelegate<?>) delegate).propertyIsLessThanOrEqualTo(propertyName, (String) literal);
} else if (literal instanceof Date) {
return ((FilterDelegate<?>) delegate).propertyIsLessThanOrEqualTo(propertyName, (Date) literal);
} else if (literal instanceof Integer) {
return ((FilterDelegate<?>) delegate).propertyIsLessThanOrEqualTo(propertyName, ((Integer) literal).intValue());
} else if (literal instanceof Short) {
return ((FilterDelegate<?>) delegate).propertyIsLessThanOrEqualTo(propertyName, ((Short) literal).shortValue());
} else if (literal instanceof Long) {
return ((FilterDelegate<?>) delegate).propertyIsLessThanOrEqualTo(propertyName, ((Long) literal).longValue());
} else if (literal instanceof Float) {
return ((FilterDelegate<?>) delegate).propertyIsLessThanOrEqualTo(propertyName, ((Float) literal).floatValue());
} else if (literal instanceof Double) {
return ((FilterDelegate<?>) delegate).propertyIsLessThanOrEqualTo(propertyName, ((Double) literal).doubleValue());
} else if (literal instanceof Boolean) {
return ((FilterDelegate<?>) delegate).propertyIsLessThanOrEqualTo(propertyName, literal);
} else if (literal instanceof byte[]) {
return ((FilterDelegate<?>) delegate).propertyIsLessThanOrEqualTo(propertyName, literal);
} else {
return ((FilterDelegate<?>) delegate).propertyIsLessThanOrEqualTo(propertyName, literal);
}
}
use of org.opengis.filter.expression.Literal in project ddf by codice.
the class CswRecordMapperFilterVisitor method visit.
@Override
public Object visit(PropertyIsEqualTo filter, Object extraData) {
if (StringUtils.equals(Core.SOURCE_ID, ((PropertyName) filter.getExpression1()).getPropertyName())) {
sourceIds.add((String) ((Literal) filter.getExpression2()).getValue());
return null;
}
AttributeType type = attributeTypes.get(((PropertyName) filter.getExpression1()).getPropertyName());
LiteralExpressionImpl typedExpression = (LiteralExpressionImpl) filter.getExpression2();
setExpressionType(type, typedExpression);
Expression expr1 = visit(filter.getExpression1(), extraData);
Expression expr2 = visit((Expression) typedExpression, expr1);
return getFactory(extraData).equal(expr1, expr2, filter.isMatchingCase());
}
use of org.opengis.filter.expression.Literal in project ddf by codice.
the class CswRecordMapperFilterVisitor method visit.
@Override
public Object visit(PropertyIsLessThanOrEqualTo filter, Object extraData) {
Expression expr1 = visit(filter.getExpression1(), extraData);
Expression expr2 = visit(filter.getExpression2(), expr1);
// work around since solr provider doesn't support lessOrEqual on temporal (DDF-311)
if (isTemporalQuery(expr1, expr2)) {
// work around #1 fails, solr provider doesn't support tEquals either (DDF-311)
//TEquals tEquals = getFactory(extraData).tequals(expr1, expr2);
//Before before = getFactory(extraData).before(expr1, expr2);
//return getFactory(extraData).or(tEquals, before);
Object val = null;
Expression other = null;
if (expr2 instanceof Literal) {
val = ((Literal) expr2).getValue();
other = expr1;
} else if (expr1 instanceof Literal) {
val = ((Literal) expr1).getValue();
other = expr2;
}
if (val != null) {
Date orig = (Date) val;
orig.setTime(orig.getTime() + 1);
Literal literal = getFactory(extraData).literal(orig);
return getFactory(extraData).before(other, literal);
}
} else {
AttributeType type = attributeTypes.get(((PropertyName) filter.getExpression1()).getPropertyName());
LiteralExpressionImpl typedExpression = (LiteralExpressionImpl) filter.getExpression2();
setExpressionType(type, typedExpression);
expr2 = visit((Expression) typedExpression, expr1);
}
return getFactory(extraData).lessOrEqual(expr1, expr2);
}
use of org.opengis.filter.expression.Literal in project ddf by codice.
the class TwitterFilterVisitor method visit.
/**
* Intersects filter maps to a Polygon or BBox Spatial search criteria.
*/
@Override
public Object visit(Intersects filter, Object data) {
LOGGER.trace("ENTERING: Intersects filter");
if (currentNest == null || NestedTypes.AND.equals(currentNest)) {
// The geometric point is wrapped in a <Literal> element, so have to
// get geometry expression as literal and then evaluate it to get
// the geometry.
// Example:
// <ogc:Literal>org.geotools.geometry.jts.spatialschema.geometry.primitive.SurfaceImpl@64a7c45e</ogc:Literal>
Literal literalWrapper = (Literal) filter.getExpression2();
Object geometryExpression = literalWrapper.getValue();
if (geometryExpression instanceof SurfaceImpl) {
SurfaceImpl polygon = (SurfaceImpl) literalWrapper.evaluate(null);
Point point = polygon.getJTSGeometry().getCentroid();
longitude = point.getX();
latitude = point.getY();
radius = point.getBoundary().getLength() * 10;
hasSpatial = true;
filters.add(filter);
} else if (geometryExpression instanceof Polygon) {
Polygon polygon = (Polygon) geometryExpression;
Point centroid = polygon.getCentroid();
longitude = centroid.getX();
latitude = centroid.getY();
radius = polygon.getBoundary().getLength() * 10;
hasSpatial = true;
filters.add(filter);
} else {
LOGGER.warn("Only POLYGON geometry WKT for Intersects filter is supported");
}
} else {
LOGGER.warn(ONLY_AND_MSG);
}
LOGGER.trace("EXITING: Intersects filter");
return super.visit(filter, data);
}
Aggregations