Package org.opengis.filter.expression

Examples of org.opengis.filter.expression.Function


    private Expression manageMixed(Expression left, Expression right) {
        if (left == null)
            return right;
        if (right == null)
            return left;
        Function mixed = ff.function("strConcat", new Expression[] { left, right });
        return mixed;
    }
View Full Code Here


    @Test
    public void testCustomLengthExpressions() {
        AttributeTypeBuilder builder = new AttributeTypeBuilder();
        FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
        Function length = ff.function("LengthFunction", new Expression[]{ff.property(".")});
       
        // strict less
        builder.addRestriction(ff.less(length, ff.literal(20)));
        builder.setBinding(String.class);
        AttributeDescriptor attribute = builder.buildDescriptor("attribute");
View Full Code Here

        assertAttributeName(filter, "testString");
    }
   
    public void testDynamicProperty() throws Exception {
        Function func = fac.function("property", fac.function("env", fac.literal("pname")));
        PropertyIsEqualTo filter = fac.equals(func, fac.literal("test"));
        try {
            EnvFunction.setLocalValue("pname", "name");
            assertAttributeName(filter, "name");
        } finally {
View Full Code Here

        store.addFeatures(features);
        SimpleFeatureCollection featureCollection = store.getFeatureSource("polygons").getFeatures();

        // Test the Function
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(GeoTools.getDefaultHints());
        Function exp = ff.function("minrectangle", ff.property("geom"));
        SimpleFeatureIterator iter = featureCollection.features();
        while (iter.hasNext()) {
            SimpleFeature feature = iter.next();
            Geometry geom = (Geometry) feature.getDefaultGeometry();
            Geometry rectangle = new MinimumDiameter(geom).getMinimumRectangle();
            Object value = exp.evaluate(feature);
            assertTrue(value instanceof Polygon);
            assertTrue(rectangle.equals((Geometry) value));
        }
        iter.close();

        // Check for null safeness
        assertNull(exp.evaluate(null));
    }
View Full Code Here

        return suite;
    }

    public void testInstance() {
        Function equInt = ff.function("Jenks", ff.literal(FeatureCollections.newCollection()));
        assertNotNull(equInt);
    }
View Full Code Here

        Function equInt = ff.function("Jenks", ff.literal(FeatureCollections.newCollection()));
        assertNotNull(equInt);
    }

    public void testGetName() {
        Function qInt = ff.function("Jenks", ff.literal(FeatureCollections.newCollection()));
        assertEquals("Jenks", qInt.getName());
    }
View Full Code Here

    // answer (from R) is [15.57,41.2] (41.2,60.66] (60.66,77.29] (77.29,100.1] (100.1,155.3]
    public void testEvaluateRealData() throws Exception {

        Literal classes = ff.literal(5);
        PropertyName exp = ff.property("jenks71");
        Function func = ff.function("Jenks", exp, classes);

        Object value = func.evaluate(jenksCollection);
        assertNotNull(value);
        assertTrue(value instanceof RangedClassifier);
        RangedClassifier ranged = (RangedClassifier) value;
        assertEquals(5, ranged.getSize());
        assertEquals("15.57..41.2", ranged.getTitle(0));
View Full Code Here

    }

    public void testEvaluateWithExpressions() throws Exception {
        Literal classes = ff.literal(2);
        PropertyName exp = ff.property("foo");
        Function func = ff.function("Jenks", exp, classes);

        Object value = func.evaluate(featureCollection);
        assertNotNull(value);
        assertTrue(value instanceof RangedClassifier);
        RangedClassifier ranged = (RangedClassifier) value;

        // the values being quantiled are
View Full Code Here

    public void testFormatDouble() {
        FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
        Literal pattern = ff.literal("#.##");
        Literal number = ff.literal("10.56789");
       
        Function f = ff.function("numberFormat", new Expression[]{pattern, number});
        char ds = new DecimalFormatSymbols().getDecimalSeparator();
        assertEquals("10" + ds + "57", f.evaluate(null , String.class));
    }
View Full Code Here

    public void testFormatInteger() {
        FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
        Literal pattern = ff.literal("###,###");
        Literal number = ff.literal("123456");
       
        Function f = ff.function("numberFormat", new Expression[]{pattern, number});
        char gs = new DecimalFormatSymbols().getGroupingSeparator();
        assertEquals("123" + gs + "456", f.evaluate(null , String.class));
    }
View Full Code Here

TOP

Related Classes of org.opengis.filter.expression.Function

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.