Package org.opengis.filter

Examples of org.opengis.filter.PropertyIsBetween


            Map hints) throws IOException, OperationNotSupportedException {
            if (!canEncode(element, value, hints)) {
                return;
            }

            PropertyIsBetween lf = (PropertyIsBetween) value;

            output.startElement(element.getNamespace(), element.getName(), null);
            encodeExpr(lf.getExpression(),output,hints);
            elems[1].getType().encode(elems[1], lf.getLowerBoundary(), output, hints); // LowerBoundary
            elems[2].getType().encode(elems[2], lf.getUpperBoundary(), output,
                hints); // UpperBoundary
            output.endElement(element.getNamespace(), element.getName());
        }
View Full Code Here


        assertEquals(((Expression) unrolled.get(0)).toString(), "strConcat([bh.], [BGS_ID])");
    }

    @Test
    public void testBetweenFilter() throws Exception {
        PropertyIsBetween bf = ff.between(ff.property("measurement/result"), ff.literal(1), ff
                .literal(2), MatchAction.ALL);

        PropertyIsBetween unrolled = (PropertyIsBetween) bf.accept(visitor, null);
        assertEquals(MatchAction.ALL, ((PropertyIsBetween) unrolled).getMatchAction());
        Expression att = unrolled.getExpression();
        assertTrue(att instanceof PropertyName);
        String propertyName = ((PropertyName) att).getPropertyName();
        assertEquals("results_value", propertyName);
    }      
View Full Code Here

    private void testLogicFilter(Class<?> filterType) throws Exception {
        BinaryLogicOperator complexLogicFilter;
        PropertyIsGreaterThan resultFilter = ff.greater(ff.property("measurement/result"), ff
                .literal(new Integer(5)));

        PropertyIsBetween determFilter = ff.between(ff
                .property("measurement/determinand_description"), ff
                .literal("determinand_description_1_1"), ff.literal("determinand_description_3_3"));

        if (And.class.equals(filterType)) {
            complexLogicFilter = ff.and(resultFilter, determFilter);
        } else if (Or.class.equals(filterType)) {
            complexLogicFilter = ff.or(resultFilter, determFilter);
        } else {
            throw new IllegalArgumentException();
        }

        Filter unmapped = (Filter) complexLogicFilter.accept(visitor, null);
        assertNotNull(unmapped);
        assertTrue(unmapped instanceof BinaryLogicOperator);
        assertNotSame(complexLogicFilter, unmapped);

        BinaryLogicOperator logicUnmapped = (BinaryLogicOperator) unmapped;

        List children = logicUnmapped.getChildren();
        assertEquals(2, children.size());

        PropertyIsGreaterThan unmappedResult = (PropertyIsGreaterThan) children.get(0);
        PropertyIsBetween unmappedDeterm = (PropertyIsBetween) children.get(1);

        assertEquals("results_value", ((PropertyName) unmappedResult.getExpression1())
                .getPropertyName());

        assertEquals(new Integer(5), ((Literal) unmappedResult.getExpression2()).getValue());

        assertEquals("determinand_description", ((PropertyName) unmappedDeterm.getExpression())
                .getPropertyName());
        assertEquals("determinand_description_1_1", ((Literal) unmappedDeterm.getLowerBoundary())
                .getValue());
        assertEquals("determinand_description_3_3", ((Literal) unmappedDeterm.getUpperBoundary())
                .getValue());
    }
View Full Code Here

        return factory.between(e, l, u);
    }

    public Object getProperty(Object object, QName name)
        throws Exception {
        PropertyIsBetween between = (PropertyIsBetween) object;

        //&lt;xsd:element ref="ogc:expression"/&gt;
        if (OGC.expression.equals(name)) {
            return between.getExpression();
        }

        //&lt;xsd:element name="LowerBoundary" type="ogc:LowerBoundaryType"/&gt;
        if ("LowerBoundary".equals(name.getLocalPart())) {
            return between.getLowerBoundary();
        }

        //&lt;xsd:element name="UpperBoundary" type="ogc:UpperBoundaryType"/&gt;
        if ("UpperBoundary".equals(name.getLocalPart())) {
            return between.getUpperBoundary();
        }

        return null;
    }
View Full Code Here

    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();

    @Test
    public void testBetween() {
        PropertyIsBetween between = ff.between(ff.property("a"), ff.property("b"), ff.property("c"));
        NullHandlingVisitor visitor = new NullHandlingVisitor();
        Filter result = (Filter) between.accept(visitor, null);
        assertTrue(result instanceof And);
        Filter expected = ff.and(Arrays.asList(between, propertyNotNull("a"), propertyNotNull("b"), propertyNotNull("c")));
        assertEquals(expected, result);
       
        between = ff.between(ff.property("a"), ff.property("b"), ff.literal(10));
        result = (Filter) between.accept(visitor, null);
        assertTrue(result instanceof And);
        expected = ff.and(Arrays.asList(between, propertyNotNull("a"), propertyNotNull("b")));
        assertEquals(expected, result);
       
        between = ff.between(ff.property("a"), ff.literal(5), ff.literal(10));
        result = (Filter) between.accept(visitor, null);
        assertTrue(result instanceof And);
        expected = ff.and(Arrays.asList(between, propertyNotNull("a")));
        assertEquals(expected, result);
       
        between = ff.between(ff.literal(7), ff.literal(5), ff.literal(10));
        result = (Filter) between.accept(visitor, null);
        assertEquals(between, result);
    }
View Full Code Here

        tb.nillable(true);
        tb.add("c", String.class);
        tb.setName("test");
        SimpleFeatureType schema = tb.buildFeatureType();
       
        PropertyIsBetween between = ff.between(ff.property("a"), ff.property("b"), ff.property("c"));
        NullHandlingVisitor visitor = new NullHandlingVisitor(schema);
        Filter result = (Filter) between.accept(visitor, null);
        assertTrue(result instanceof And);
        Filter expected = ff.and(Arrays.asList(between, propertyNotNull("a"), propertyNotNull("c")));
        assertEquals(expected, result);
    }
View Full Code Here

        assertEquals(expected, result);
    }
   
    @Test
    public void testSimplifyRedundant() {
        PropertyIsBetween between = ff.between(ff.property("a"), ff.property("b"), ff.property("c"));
        PropertyIsEqualTo equal = ff.equal(ff.property("a"), ff.property("b"), false);
        And and = ff.and(between, equal);
       
        NullHandlingVisitor nh = new NullHandlingVisitor();
        Filter nhResult = (Filter) and.accept(nh, null);
View Full Code Here

       
        Within f1 = (Within) f.getChildren().get(0);
        assertEquals("WKB_GEOM", ((PropertyName)f1.getExpression1()).getPropertyName());
        assertTrue(f1.getExpression2().evaluate(null) instanceof Polygon);
       
        PropertyIsBetween f2 = (PropertyIsBetween) f.getChildren().get(1);
        assertEquals("DEPTH", ((PropertyName)f2.getExpression()).getPropertyName());
        assertEquals(400, f2.getLowerBoundary().evaluate(null, Integer.class).intValue());
        assertEquals(800, f2.getUpperBoundary().evaluate(null, Integer.class).intValue());
    }
View Full Code Here

    }

    public void testParse() throws Exception {
        FilterMockData.propertyIsBetween(document, document);

        PropertyIsBetween between = (PropertyIsBetween) parse();

        assertTrue(between.getExpression() instanceof PropertyName);
        assertTrue(between.getLowerBoundary() instanceof Literal);
        assertTrue(between.getUpperBoundary() instanceof Literal);
    }
View Full Code Here

            org.opengis.filter.expression.Expression inf = this.resultStack
                    .popExpression();
            org.opengis.filter.expression.Expression expr = this.resultStack
                    .popExpression();

            PropertyIsBetween filter = filterFactory.between(expr, inf, sup);

            return filter;
        } catch (IllegalFilterException ife) {
            throw new CQLException("Exception building CompareFilter: "+ ife.getMessage(), this.cqlSource);
        }
View Full Code Here

TOP

Related Classes of org.opengis.filter.PropertyIsBetween

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.