Search in sources :

Example 31 with LiteralExpressionImpl

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());
}
Also used : Expression(org.opengis.filter.expression.Expression) AttributeType(ddf.catalog.data.AttributeType) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) Literal(org.opengis.filter.expression.Literal)

Example 32 with LiteralExpressionImpl

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);
}
Also used : Expression(org.opengis.filter.expression.Expression) AttributeType(ddf.catalog.data.AttributeType) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl)

Example 33 with LiteralExpressionImpl

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);
                }
            }
        }
    }
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) GeoFormatException(org.codice.ddf.libs.geo.GeoFormatException) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem)

Example 34 with LiteralExpressionImpl

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);
}
Also used : Expression(org.opengis.filter.expression.Expression) AttributeType(ddf.catalog.data.AttributeType) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) Literal(org.opengis.filter.expression.Literal) Date(java.util.Date)

Example 35 with LiteralExpressionImpl

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());
}
Also used : Expression(org.opengis.filter.expression.Expression) AttributeType(ddf.catalog.data.AttributeType) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl)

Aggregations

LiteralExpressionImpl (org.geotools.filter.LiteralExpressionImpl)58 Expression (org.opengis.filter.expression.Expression)33 AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)20 AttributeType (ddf.catalog.data.AttributeType)7 MathExpressionImpl (org.geotools.filter.MathExpressionImpl)7 FunctionExpressionImpl (org.geotools.filter.FunctionExpressionImpl)6 MarkImpl (org.geotools.styling.MarkImpl)6 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)5 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 ConstantExpression (org.geotools.filter.ConstantExpression)4 IsEqualsToImpl (org.geotools.filter.IsEqualsToImpl)4 Literal (org.opengis.filter.expression.Literal)4 XMLFieldLiteralString (com.sldeditor.common.xml.ui.XMLFieldLiteralString)3 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)3 Color (java.awt.Color)3 Geometry (org.locationtech.jts.geom.Geometry)3 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)2 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)2 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)2