use of org.geotools.filter.LiteralExpressionImpl 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.geotools.filter.LiteralExpressionImpl in project ddf by codice.
the class CswRecordMapperFilterVisitor method visit.
@Override
public Object visit(PropertyIsLessThan filter, Object extraData) {
Expression expr1 = visit(filter.getExpression1(), extraData);
Expression expr2 = visit(filter.getExpression2(), expr1);
// work around since solr provider doesn't support lessthan on temporal (DDF-311)
if (isTemporalQuery(expr1, expr2)) {
return getFactory(extraData).before(expr1, expr2);
} 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).less(expr1, expr2);
}
use of org.geotools.filter.LiteralExpressionImpl in project ddf by codice.
the class CswRecordMapperFilterVisitor method convertGeometryExpressionToEpsg4326.
private static void convertGeometryExpressionToEpsg4326(Expression expression) {
if (expression instanceof LiteralExpressionImpl) {
LiteralExpressionImpl literalExpression = (LiteralExpressionImpl) expression;
Object valueObj = literalExpression.getValue();
if (valueObj instanceof Geometry) {
Geometry geometry = (Geometry) valueObj;
Object userDataObj = geometry.getUserData();
if (userDataObj instanceof CoordinateReferenceSystem) {
CoordinateReferenceSystem sourceCRS = (CoordinateReferenceSystem) userDataObj;
Geometry convertedGeometry = null;
try {
convertedGeometry = GeospatialUtil.transformToEPSG4326LonLatFormat(geometry, sourceCRS);
literalExpression.setValue(convertedGeometry);
} catch (GeoFormatException e) {
LOGGER.trace("Unable to convert geometry to EPSG:4326 format", e);
}
}
}
}
}
use of org.geotools.filter.LiteralExpressionImpl 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.geotools.filter.LiteralExpressionImpl in project ddf by codice.
the class CswRecordMapperFilterVisitor method visit.
@Override
public Object visit(PropertyIsNotEqualTo filter, Object extraData) {
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).notEqual(expr1, expr2, filter.isMatchingCase());
}
Aggregations