Search in sources :

Example 1 with FilterNode

use of com.sldeditor.filter.v2.expression.FilterNode in project sldeditor by robward-scisys.

the class ExpressionPanelv2 method addFilter.

/**
 * Adds the filter.
 *
 * @param node the node
 * @return the filter
 */
private Filter addFilter(FilterNode node) {
    Filter filter = node.getFilter();
    FilterConfigInterface filterConfig = node.getFilterConfig();
    if (filter instanceof LogicFilterImpl) {
        List<Filter> filterList = new ArrayList<Filter>();
        createFilterList(node, filterList);
        return filterConfig.createLogicFilter(filterList);
    }
    List<Expression> parameterFilter = new ArrayList<Expression>();
    if (filter instanceof FidFilterImpl) {
        createExpressionParameterList(node, 1, parameterFilter);
    } else if (filter instanceof BinaryTemporalOperator) {
        createExpressionParameterList(node, 2, parameterFilter);
    } else if (filter instanceof PropertyIsBetween) {
        createExpressionParameterList(node, 3, parameterFilter);
    } else if (filter instanceof PropertyIsNull) {
        createExpressionParameterList(node, 1, parameterFilter);
    } else if (filter instanceof PropertyIsLike) {
        createExpressionParameterList(node, 6, parameterFilter);
    } else if (filter instanceof BinarySpatialOperator) {
        createExpressionParameterList(node, 2, parameterFilter);
    } else if (filter instanceof BinaryComparisonAbstract) {
        if (filter instanceof Not) {
            createExpressionParameterList(node, 1, parameterFilter);
        } else if (filter instanceof PropertyIsGreaterThan) {
            createExpressionParameterList(node, 2, parameterFilter);
        } else {
            createExpressionParameterList(node, 3, parameterFilter);
        }
    } else {
        return filter;
    }
    return filterConfig.createFilter(parameterFilter);
}
Also used : PropertyIsLike(org.opengis.filter.PropertyIsLike) ArrayList(java.util.ArrayList) FilterConfigInterface(com.sldeditor.filter.v2.function.FilterConfigInterface) BinaryTemporalOperator(org.opengis.filter.temporal.BinaryTemporalOperator) Not(org.opengis.filter.Not) PropertyIsNull(org.opengis.filter.PropertyIsNull) Filter(org.opengis.filter.Filter) Expression(org.opengis.filter.expression.Expression) LogicFilterImpl(org.geotools.filter.LogicFilterImpl) FidFilterImpl(org.geotools.filter.FidFilterImpl) PropertyIsBetween(org.opengis.filter.PropertyIsBetween) BinaryComparisonAbstract(org.geotools.filter.BinaryComparisonAbstract) BinarySpatialOperator(org.opengis.filter.spatial.BinarySpatialOperator) PropertyIsGreaterThan(org.opengis.filter.PropertyIsGreaterThan)

Example 2 with FilterNode

use of com.sldeditor.filter.v2.expression.FilterNode in project sldeditor by robward-scisys.

the class FilterPanelv2 method addFilter.

/**
 * Adds the filter.
 *
 * @param node the node
 * @return the filter
 */
private Filter addFilter(FilterNode node) {
    Filter filter = node.getFilter();
    FilterConfigInterface filterConfig = node.getFilterConfig();
    if (filter instanceof LogicFilterImpl) {
        List<Filter> filterList = new ArrayList<Filter>();
        createFilterList(node, filterList);
        return filterConfig.createLogicFilter(filterList);
    }
    List<Expression> parameterFilter = new ArrayList<Expression>();
    if (filter instanceof FidFilterImpl) {
        createExpressionParameterList(node, 1, parameterFilter);
    } else if (filter instanceof BinaryTemporalOperator) {
        createExpressionParameterList(node, 2, parameterFilter);
    } else if (filter instanceof PropertyIsBetween) {
        createExpressionParameterList(node, 3, parameterFilter);
    } else if (filter instanceof PropertyIsNull) {
        createExpressionParameterList(node, 1, parameterFilter);
    } else if (filter instanceof PropertyIsLike) {
        createExpressionParameterList(node, 6, parameterFilter);
    } else if (filter instanceof BinarySpatialOperator) {
        createExpressionParameterList(node, 2, parameterFilter);
    } else if (filter instanceof BinaryComparisonAbstract) {
        if (filter instanceof Not) {
            createExpressionParameterList(node, 1, parameterFilter);
        } else if (filter instanceof PropertyIsGreaterThan) {
            createExpressionParameterList(node, 2, parameterFilter);
        } else {
            createExpressionParameterList(node, 3, parameterFilter);
        }
    } else {
        return filter;
    }
    return filterConfig.createFilter(parameterFilter);
}
Also used : PropertyIsLike(org.opengis.filter.PropertyIsLike) ArrayList(java.util.ArrayList) FilterConfigInterface(com.sldeditor.filter.v2.function.FilterConfigInterface) BinaryTemporalOperator(org.opengis.filter.temporal.BinaryTemporalOperator) Not(org.opengis.filter.Not) PropertyIsNull(org.opengis.filter.PropertyIsNull) Filter(org.opengis.filter.Filter) Expression(org.opengis.filter.expression.Expression) LogicFilterImpl(org.geotools.filter.LogicFilterImpl) FidFilterImpl(org.geotools.filter.FidFilterImpl) PropertyIsBetween(org.opengis.filter.PropertyIsBetween) BinaryComparisonAbstract(org.geotools.filter.BinaryComparisonAbstract) BinarySpatialOperator(org.opengis.filter.spatial.BinarySpatialOperator) PropertyIsGreaterThan(org.opengis.filter.PropertyIsGreaterThan)

Example 3 with FilterNode

use of com.sldeditor.filter.v2.expression.FilterNode in project sldeditor by robward-scisys.

the class FilterNodeTest method testSetFilter.

/**
 * Test method for
 * {@link com.sldeditor.filter.v2.expression.FilterNode#setFilter(org.opengis.filter.Filter, com.sldeditor.filter.v2.function.FilterConfigInterface)}.
 */
@Test
public void testSetFilter() {
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    FilterNode node = new FilterNode();
    // BinaryComparisonAbstract
    Filter filter = ff.greaterOrEqual(ff.literal(45), ff.literal(23));
    node.setFilter(filter, null);
    node.addFilter();
    String actual = node.toString();
    String expected = "Filter : " + Localisation.getString(ExpressionPanelv2.class, "FilterNode.filterNotSet");
    assertTrue(actual.compareTo(expected) == 0);
    assertEquals(filter, node.getFilter());
    FilterConfigInterface filterConfig = new IsGreaterThan();
    node.setFilter(filter, filterConfig);
    assertEquals(filterConfig, node.getFilterConfig());
    expected = "Filter : PropertyIsGreaterThan";
    actual = node.toString();
    assertTrue(actual.compareTo(expected) == 0);
    // PropertyIsLike
    filter = ff.like(ff.literal("abc def ghi"), "abc");
    filterConfig = new IsLike();
    node.setFilter(filter, filterConfig);
    expected = "Filter : Like";
    actual = node.toString();
    assertTrue(actual.compareTo(expected) == 0);
    // BinarySpatialOperator
    Hints hints = new Hints(Hints.CRS, DefaultGeographicCRS.WGS84);
    PositionFactory positionFactory = GeometryFactoryFinder.getPositionFactory(hints);
    GeometryFactory geometryFactory = GeometryFactoryFinder.getGeometryFactory(hints);
    PrimitiveFactory primitiveFactory = GeometryFactoryFinder.getPrimitiveFactory(hints);
    AggregateFactory aggregateFactory = GeometryFactoryFinder.getAggregateFactory(hints);
    WKTParser wktParser = new WKTParser(geometryFactory, primitiveFactory, positionFactory, aggregateFactory);
    Geometry geometry = null;
    try {
        geometry = wktParser.parse("POINT( 48.44 -123.37)");
    } catch (ParseException e) {
        e.printStackTrace();
        fail();
    }
    filter = ff.overlaps("property", geometry);
    filterConfig = new Overlaps();
    node.setFilter(filter, filterConfig);
    expected = "Filter : Overlaps";
    actual = node.toString();
    assertTrue(actual.compareTo(expected) == 0);
    // Is Between
    filter = ff.between(ff.literal(25), ff.literal(5), ff.literal(50));
    filterConfig = new IsBetween();
    node.setFilter(filter, filterConfig);
    expected = "Filter : PropertyIsBetween";
    actual = node.toString();
    assertTrue(actual.compareTo(expected) == 0);
    // Is Null
    filter = ff.isNull(ff.literal(12));
    filterConfig = new IsNull();
    node.setFilter(filter, filterConfig);
    expected = "Filter : IsNull";
    actual = node.toString();
    assertTrue(actual.compareTo(expected) == 0);
    // BinaryTemporalOperator
    filter = ff.after(ff.literal(12), ff.literal(312));
    filterConfig = new After();
    node.setFilter(filter, filterConfig);
    expected = "Filter : After";
    actual = node.toString();
    assertTrue(actual.compareTo(expected) == 0);
    // Logic filter
    filter = ff.and(ff.after(ff.literal(12), ff.literal(312)), ff.between(ff.literal(25), ff.literal(5), ff.literal(50)));
    filterConfig = new And();
    node.setFilter(filter, filterConfig);
    expected = "Filter : And";
    actual = node.toString();
    assertTrue(actual.compareTo(expected) == 0);
    node.addFilter();
}
Also used : ExpressionPanelv2(com.sldeditor.filter.v2.expression.ExpressionPanelv2) Overlaps(com.sldeditor.filter.v2.function.geometry.Overlaps) GeometryFactory(org.opengis.geometry.coordinate.GeometryFactory) Hints(org.geotools.factory.Hints) PositionFactory(org.opengis.geometry.PositionFactory) FilterNode(com.sldeditor.filter.v2.expression.FilterNode) IsBetween(com.sldeditor.filter.v2.function.property.IsBetween) FilterConfigInterface(com.sldeditor.filter.v2.function.FilterConfigInterface) IsGreaterThan(com.sldeditor.filter.v2.function.property.IsGreaterThan) WKTParser(org.geotools.geometry.text.WKTParser) IsLike(com.sldeditor.filter.v2.function.misc.IsLike) PrimitiveFactory(org.opengis.geometry.primitive.PrimitiveFactory) FilterFactory(org.opengis.filter.FilterFactory) Geometry(org.opengis.geometry.Geometry) Filter(org.opengis.filter.Filter) And(com.sldeditor.filter.v2.function.logic.And) After(com.sldeditor.filter.v2.function.temporal.After) IsNull(com.sldeditor.filter.v2.function.misc.IsNull) AggregateFactory(org.opengis.geometry.aggregate.AggregateFactory) ParseException(java.text.ParseException) Test(org.junit.Test)

Example 4 with FilterNode

use of com.sldeditor.filter.v2.expression.FilterNode in project sldeditor by robward-scisys.

the class FilterNodeTest method testFilterNode.

/**
 * Test method for {@link com.sldeditor.filter.v2.expression.FilterNode#FilterNode()}. Test
 * method for {@link com.sldeditor.filter.v2.expression.FilterNode#toString()}. Test method for
 * {@link com.sldeditor.filter.v2.expression.FilterNode#getFilter()}. Test method for
 * {@link com.sldeditor.filter.v2.expression.FilterNode#getType()}. Test method for
 * {@link com.sldeditor.filter.v2.expression.FilterNode#setType(java.lang.Class)}.
 */
@Test
public void testFilterNode() {
    FilterNode node = new FilterNode();
    assertNull(node.getFilter());
    assertTrue(node.toString().compareTo(Localisation.getString(ExpressionPanelv2.class, "FilterNode.filterNotSet")) == 0);
    Class<?> type = Double.class;
    node.setType(type);
    assertEquals(type, node.getType());
}
Also used : ExpressionPanelv2(com.sldeditor.filter.v2.expression.ExpressionPanelv2) FilterNode(com.sldeditor.filter.v2.expression.FilterNode) Test(org.junit.Test)

Example 5 with FilterNode

use of com.sldeditor.filter.v2.expression.FilterNode in project sldeditor by robward-scisys.

the class FilterNode method setFilterParameter.

/**
 * Sets the filter.
 *
 * @param childFilter the new filter
 * @param parameter the parameter
 */
private void setFilterParameter(Filter childFilter, FilterNameParameter parameter) {
    FilterNode childNode = new FilterNode();
    childNode.setType(parameter.getDataType());
    FilterConfigInterface filterConfig = FilterManager.getInstance().getFilterConfig(childFilter);
    childNode.setFilter(childFilter, filterConfig);
    this.insert(childNode, this.getChildCount());
}
Also used : FilterConfigInterface(com.sldeditor.filter.v2.function.FilterConfigInterface)

Aggregations

FilterConfigInterface (com.sldeditor.filter.v2.function.FilterConfigInterface)5 ExpressionPanelv2 (com.sldeditor.filter.v2.expression.ExpressionPanelv2)3 FilterNode (com.sldeditor.filter.v2.expression.FilterNode)3 Test (org.junit.Test)3 Filter (org.opengis.filter.Filter)3 ArrayList (java.util.ArrayList)2 BinaryComparisonAbstract (org.geotools.filter.BinaryComparisonAbstract)2 FidFilterImpl (org.geotools.filter.FidFilterImpl)2 LogicFilterImpl (org.geotools.filter.LogicFilterImpl)2 Not (org.opengis.filter.Not)2 PropertyIsBetween (org.opengis.filter.PropertyIsBetween)2 PropertyIsGreaterThan (org.opengis.filter.PropertyIsGreaterThan)2 PropertyIsLike (org.opengis.filter.PropertyIsLike)2 PropertyIsNull (org.opengis.filter.PropertyIsNull)2 Expression (org.opengis.filter.expression.Expression)2 BinarySpatialOperator (org.opengis.filter.spatial.BinarySpatialOperator)2 BinaryTemporalOperator (org.opengis.filter.temporal.BinaryTemporalOperator)2 Overlaps (com.sldeditor.filter.v2.function.geometry.Overlaps)1 And (com.sldeditor.filter.v2.function.logic.And)1 IsLike (com.sldeditor.filter.v2.function.misc.IsLike)1