Search in sources :

Example 1 with BinaryComparisonOperator

use of org.opengis.filter.BinaryComparisonOperator in project polymap4-core by Polymap4.

the class NumberGradient2FilterEditor method initValues.

protected void initValues() {
    annotation = (NumberRange) prop.info().getAnnotation(NumberRange.class);
    df = NumberFormat.getInstance(Polymap.getSessionLocale());
    df.setMaximumFractionDigits(2);
    df.setMinimumFractionDigits(0);
    List<Mapped<Filter, N>> values = prop.get().values();
    // defaults
    if (values.isEmpty()) {
        minimumValue = annotation.from();
        maximumValue = annotation.to();
        breakpoints = 10;
    } else // from prop
    {
        And first = (And) values.get(0).key();
        BinaryComparisonOperator lessThan = (BinaryComparisonOperator) first.getChildren().get(0);
        propertyName = ((PropertyName) lessThan.getExpression1()).getPropertyName();
        String value = (String) ((Literal) lessThan.getExpression2()).getValue();
        lowerBound = Double.parseDouble(value);
        And last = (And) values.get(values.size() - 1).key();
        BinaryComparisonOperator greaterThan = (BinaryComparisonOperator) last.getChildren().get(0);
        value = (String) ((Literal) greaterThan.getExpression2()).getValue();
        upperBound = Double.parseDouble(value);
        minimumValue = values.get(0).value().doubleValue();
        maximumValue = values.get(values.size() - 1).value().doubleValue();
        breakpoints = values.size() + 1;
    }
}
Also used : Mapped(org.polymap.core.style.model.feature.MappedValues.Mapped) And(org.opengis.filter.And) Literal(org.opengis.filter.expression.Literal) BinaryComparisonOperator(org.opengis.filter.BinaryComparisonOperator)

Example 2 with BinaryComparisonOperator

use of org.opengis.filter.BinaryComparisonOperator in project polymap4-core by Polymap4.

the class AttributeLiteralFilterEditor method initValues.

protected void initValues() {
    if (prop.get().filter() instanceof BinaryComparisonOperator) {
        BinaryComparisonOperator filter = (BinaryComparisonOperator) prop.get().filter();
        opType = filter.getClass();
        propertyName = ((PropertyName) filter.getExpression1()).getPropertyName();
        literal = ((Literal) filter.getExpression2()).getValue();
    } else {
        opType = PropertyIsEqualTo.class;
        literal = "";
    }
}
Also used : BinaryComparisonOperator(org.opengis.filter.BinaryComparisonOperator)

Example 3 with BinaryComparisonOperator

use of org.opengis.filter.BinaryComparisonOperator in project polymap4-core by Polymap4.

the class ColorGradient2FilterEditor method initValues.

protected void initValues() {
    List<Mapped<Filter, java.awt.Color>> values = prop.get().values();
    df = NumberFormat.getInstance(Polymap.getSessionLocale());
    df.setMaximumFractionDigits(2);
    df.setMinimumFractionDigits(0);
    // defaults
    if (values.isEmpty()) {
        minimumValue = Color.LIGHT_GRAY;
        maximumValue = Color.BLACK;
        breakpoints = 10;
    } else // from prop
    {
        And first = (And) values.get(0).key();
        BinaryComparisonOperator lessThan = (BinaryComparisonOperator) first.getChildren().get(0);
        propertyName = ((PropertyName) lessThan.getExpression1()).getPropertyName();
        String value = (String) ((Literal) lessThan.getExpression2()).getValue();
        lowerBound = Double.parseDouble(value);
        And last = (And) values.get(values.size() - 1).key();
        BinaryComparisonOperator greaterThan = (BinaryComparisonOperator) last.getChildren().get(0);
        value = (String) ((Literal) greaterThan.getExpression2()).getValue();
        upperBound = Double.parseDouble(value);
        // minimumValue = values.get( 0 ).value().doubleValue();
        // maximumValue = values.get( values.size() - 1 ).value().doubleValue();
        breakpoints = values.size() + 1;
    }
}
Also used : Mapped(org.polymap.core.style.model.feature.MappedValues.Mapped) And(org.opengis.filter.And) Literal(org.opengis.filter.expression.Literal) BinaryComparisonOperator(org.opengis.filter.BinaryComparisonOperator)

Aggregations

BinaryComparisonOperator (org.opengis.filter.BinaryComparisonOperator)3 And (org.opengis.filter.And)2 Literal (org.opengis.filter.expression.Literal)2 Mapped (org.polymap.core.style.model.feature.MappedValues.Mapped)2