Package org.opengis.filter.expression

Examples of org.opengis.filter.expression.Function


        try {
            FilterFunction_abs_4 abs_4 = (FilterFunction_abs_4) ff.function("abs_4", org.opengis.filter.expression.Expression.NIL);
            assertEquals("Name is, ", "abs_4", abs_4.getName());
            assertEquals("Number of arguments, ", 1, abs_4.getFunctionName().getArgumentCount());

            Function abs_4Function = ff.function("abs_4", literal_1);
            assertEquals("abs_4 of (1.0):", (double) Math.abs(1.0),
                    ((Double) abs_4Function.evaluate(null)).doubleValue(), 0.00001);
           
            abs_4Function = ff.function("abs_4", literal_m1);
            assertEquals("abs_4 of (-1.0):", (double) Math.abs(-1.0),
                    ((Double) abs_4Function.evaluate(null)).doubleValue(), 0.00001);
           
            abs_4Function = ff.function("abs_4", literal_2);
            assertEquals("abs_4 of (2.0):", (double) Math.abs(2.0),
                    ((Double) abs_4Function.evaluate(null)).doubleValue(), 0.00001);
           
            abs_4Function = ff.function("abs_4", literal_m2);
            assertEquals("abs_4 of (-2.0):", (double) Math.abs(-2.0),
                    ((Double) abs_4Function.evaluate(null)).doubleValue(), 0.00001);
           
            abs_4Function = ff.function("abs_4", literal_pi);
            assertEquals("abs_4 of (3.141592653589793):", (double) Math
                    .abs(3.141592653589793), ((Double) abs_4Function
                    .evaluate(null)).doubleValue(), 0.00001);
           
            abs_4Function = ff.function("abs_4", literal_05pi);
            assertEquals("abs_4 of (1.5707963267948966):", (double) Math
                    .abs(1.5707963267948966), ((Double) abs_4Function
                    .evaluate(null)).doubleValue(), 0.00001);
        } catch (FactoryRegistryException e) {
            e.printStackTrace();
            fail("Unexpected exception: " + e.getMessage());
        }
View Full Code Here


        g = new WKTReader().read("POINT(0 0)");
    }
   
    @Test
    public void setCRSObject() {
        Function f = ff.function("setCRS", ff.literal(g), ff.literal(DefaultGeographicCRS.WGS84));
        Geometry sg = (Geometry) f.evaluate(null);
        assertEquals(DefaultGeographicCRS.WGS84, sg.getUserData());
    }
View Full Code Here

        assertEquals(DefaultGeographicCRS.WGS84, sg.getUserData());
    }
   
    @Test
    public void setCRSCode() throws Exception {
        Function f = ff.function("setCRS", ff.literal(g), ff.literal("EPSG:4326"));
        Geometry sg = (Geometry) f.evaluate(null);
        assertEquals(CRS.decode("EPSG:4326"), sg.getUserData());
    }
View Full Code Here

        assertEquals(CRS.decode("EPSG:4326"), sg.getUserData());
    }
   
    @Test
    public void setCRSWkt() {
        Function f = ff.function("setCRS", ff.literal(g), ff.literal(DefaultGeographicCRS.WGS84.toWKT()));
        Geometry sg = (Geometry) f.evaluate(null);
        assertTrue(CRS.equalsIgnoreMetadata(DefaultGeographicCRS.WGS84, sg.getUserData()));
    }
View Full Code Here

        try {
            FilterFunction_abs_3 abs_3 = (FilterFunction_abs_3) ff.function("abs_3", org.opengis.filter.expression.Expression.NIL);
            assertEquals("Name is, ", "abs_3", abs_3.getName());
            assertEquals("Number of arguments, ", 1, abs_3.getFunctionName().getArgumentCount());

            Function abs_3Function = ff.function("abs_3", literal_1);
            assertEquals("abs_3 of (1.0):", (float) Math.abs(1.0),
                    ((Float) abs_3Function.evaluate(null)).floatValue(), 0.00001);
           
            abs_3Function = ff.function("abs_3", literal_m1);
            assertEquals("abs_3 of (-1.0):", (float) Math.abs(-1.0),
                    ((Float) abs_3Function.evaluate(null)).floatValue(), 0.00001);
           
            abs_3Function = ff.function("abs_3", literal_2);
            assertEquals("abs_3 of (2.0):", (float) Math.abs(2.0),
                    ((Float) abs_3Function.evaluate(null)).floatValue(), 0.00001);
           
            abs_3Function = ff.function("abs_3", literal_m2);
            assertEquals("abs_3 of (-2.0):", (float) Math.abs(-2.0),
                    ((Float) abs_3Function.evaluate(null)).floatValue(), 0.00001);
           
            abs_3Function = ff.function("abs_3", literal_pi);
            assertEquals("abs_3 of (3.141592653589793):", (float) Math
                    .abs(3.141592653589793), ((Float) abs_3Function
                    .evaluate(null)).floatValue(), 0.00001);
           
            abs_3Function = ff.function("abs_3", literal_05pi);
            assertEquals("abs_3 of (1.5707963267948966):", (float) Math
                    .abs(1.5707963267948966), ((Float) abs_3Function
                    .evaluate(null)).floatValue(), 0.00001);
        } catch (FactoryRegistryException e) {
            e.printStackTrace();
            fail("Unexpected exception: " + e.getMessage());
        }
View Full Code Here

        try {
            FilterFunction_abs_2 abs_2 = (FilterFunction_abs_2) ff.function("abs_2", org.opengis.filter.expression.Expression.NIL);
            assertEquals("Name is, ", "abs_2", abs_2.getName());
            assertEquals("Number of arguments, ", 1, abs_2.getFunctionName().getArgumentCount());

            Function abs_2Function = ff.function("abs_2", literal_1);
            assertEquals("abs_2 of (1.0):", (long) Math.abs(1.0),
                    ((Long) abs_2Function.evaluate(null)).longValue(), 0.00001);
           
            abs_2Function = ff.function("abs_2", literal_m1);
            assertEquals("abs_2 of (-1.0):", (long) Math.abs(-1.0),
                    ((Long) abs_2Function.evaluate(null)).longValue(), 0.00001);
           
            abs_2Function = ff.function("abs_2", literal_2);
            assertEquals("abs_2 of (2.0):", (long) Math.abs(2.0),
                    ((Long) abs_2Function.evaluate(null)).longValue(), 0.00001);
           
            abs_2Function = ff.function("abs_2", literal_m2);
            assertEquals("abs_2 of (-2.0):", (long) Math.abs(-2.0),
                    ((Long) abs_2Function.evaluate(null)).longValue(), 0.00001);
           
            abs_2Function = ff.function("abs_2", literal_pi);
            assertEquals("abs_2 of (3.141592653589793):", (long) Math
                    .abs(3.141592653589793), ((Long) abs_2Function
                    .evaluate(null)).longValue(), 0.00001);
           
            abs_2Function = ff.function("abs_2", literal_05pi);
            assertEquals("abs_2 of (1.5707963267948966):", (long) Math
                    .abs(1.5707963267948966), ((Long) abs_2Function
                    .evaluate(null)).longValue(), 0.00001);
        } catch (FactoryRegistryException e) {
            e.printStackTrace();
            fail("Unexpected exception: " + e.getMessage());
        }
View Full Code Here

                    org.opengis.filter.expression.Expression.NIL,
                    org.opengis.filter.expression.Expression.NIL);
            assertEquals("Name is, ", "IEEEremainder", IEEEremainder.getName());
            assertEquals("Number of arguments, ", 2, IEEEremainder.getFunctionName().getArgumentCount());

            Function IEEEremainderFunction = ff.function("IEEEremainder", literal_1, literal_m1);
            double good0 = Math.IEEEremainder(1.0, -1.0);
            if (Double.isNaN(good0)) {
                assertTrue("IEEEremainder of (1.0,-1.0):", Double
                        .isNaN(((Double) IEEEremainderFunction.evaluate(null))
                                .doubleValue()));
            } else {
                assertEquals("IEEEremainder of (1.0,-1.0):", (double) Math.IEEEremainder(1.0,
                        -1.0), ((Double) IEEEremainderFunction.evaluate(null))
                        .doubleValue(), 0.00001);
            }
           
            IEEEremainderFunction = ff.function("IEEEremainder", literal_m1, literal_2);
            double good1 = Math.IEEEremainder(-1.0, 2.0);
            if (Double.isNaN(good1)) {
                assertTrue("IEEEremainder of (-1.0,2.0):", Double
                        .isNaN(((Double) IEEEremainderFunction.evaluate(null))
                                .doubleValue()));
            } else {
                assertEquals("IEEEremainder of (-1.0,2.0):", (double) Math.IEEEremainder(-1.0,
                        2.0), ((Double) IEEEremainderFunction.evaluate(null))
                        .doubleValue(), 0.00001);
            }
           
            IEEEremainderFunction = ff.function("IEEEremainder", literal_2, literal_m2);
            double good2 = Math.IEEEremainder(2.0, -2.0);
            if (Double.isNaN(good2)) {
                assertTrue("IEEEremainder of (2.0,-2.0):", Double
                        .isNaN(((Double) IEEEremainderFunction.evaluate(null))
                                .doubleValue()));
            } else {
                assertEquals("IEEEremainder of (2.0,-2.0):", (double) Math.IEEEremainder(2.0,
                        -2.0), ((Double) IEEEremainderFunction.evaluate(null))
                        .doubleValue(), 0.00001);
            }
           
            IEEEremainderFunction = ff.function("IEEEremainder", literal_m2, literal_pi);
            double good3 = Math.IEEEremainder(-2.0, 3.141592653589793);
            if (Double.isNaN(good3)) {
                assertTrue("IEEEremainder of (-2.0,3.141592653589793):", Double
                        .isNaN(((Double) IEEEremainderFunction.evaluate(null))
                                .doubleValue()));
            } else {
                assertEquals("IEEEremainder of (-2.0,3.141592653589793):",
                        (double) Math.IEEEremainder(-2.0, 3.141592653589793),
                        ((Double) IEEEremainderFunction.evaluate(null)).doubleValue(),
                        0.00001);
            }
           
            IEEEremainderFunction = ff.function("IEEEremainder", literal_pi, literal_05pi);
            double good4 = Math.IEEEremainder(3.141592653589793, 1.5707963267948966);
            if (Double.isNaN(good4)) {
                assertTrue("IEEEremainder of (3.141592653589793,1.5707963267948966):",
                        Double.isNaN(((Double) IEEEremainderFunction.evaluate(null))
                                .doubleValue()));
            } else {
                assertEquals(
                        "IEEEremainder of (3.141592653589793,1.5707963267948966):",
                        (double) Math.IEEEremainder(3.141592653589793,
                                1.5707963267948966), ((Double) IEEEremainderFunction
                                .evaluate(null)).doubleValue(), 0.00001);
            }
           
            IEEEremainderFunction = ff.function("IEEEremainder", literal_05pi, literal_1);
            double good5 = Math.IEEEremainder(1.5707963267948966, 1.0);
            if (Double.isNaN(good5)) {
                assertTrue("IEEEremainder of (1.5707963267948966,1.0):", Double
                        .isNaN(((Double) IEEEremainderFunction.evaluate(null))
                                .doubleValue()));
            } else {
                assertEquals("IEEEremainder of (1.5707963267948966,1.0):",
                        (double) Math.IEEEremainder(1.5707963267948966, 1.0),
                        ((Double) IEEEremainderFunction.evaluate(null)).doubleValue(),
                        0.00001);
            }
        } catch (FactoryRegistryException e) {
            e.printStackTrace();
            fail("Unexpected exception: " + e.getMessage());
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("mincircle", ff.property("geom"));
        SimpleFeatureIterator iter = featureCollection.features();
        while (iter.hasNext()) {
            SimpleFeature feature = iter.next();
            Geometry geom = (Geometry) feature.getDefaultGeometry();
            Geometry circle = new MinimumBoundingCircle(geom).getCircle();
            Object value = exp.evaluate(feature);
            assertTrue(value instanceof Polygon);
            assertTrue(circle.equals((Geometry) value));
        }
        iter.close();

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

            FilterFunction_acos acos = (FilterFunction_acos) ff.function("acos",
                    org.opengis.filter.expression.Expression.NIL);
            assertEquals("Name is, ", "acos", acos.getName());
            assertEquals("Number of arguments, ", 1, acos.getFunctionName().getArgumentCount());

            Function acosFunction = ff.function("acos", literal_1);
            double good0 = Math.acos(1.0);
            if (Double.isNaN(good0)) {
                assertTrue("acos of (1.0):", Double.isNaN(((Double) acosFunction
                        .evaluate(null)).doubleValue()));
            } else {
                assertEquals("acos of (1.0):", (double) Math.acos(1.0),
                        ((Double) acosFunction.evaluate(null)).doubleValue(),
                        0.00001);
            }
           
            acosFunction = ff.function("acos", literal_m1);
            double good1 = Math.acos(-1.0);
            if (Double.isNaN(good1)) {
                assertTrue("acos of (-1.0):", Double.isNaN(((Double) acosFunction
                        .evaluate(null)).doubleValue()));
            } else {
                assertEquals("acos of (-1.0):", (double) Math.acos(-1.0),
                        ((Double) acosFunction.evaluate(null)).doubleValue(),
                        0.00001);
            }
           
            acosFunction = ff.function("acos", literal_2);
            double good2 = Math.acos(2.0);
            if (Double.isNaN(good2)) {
                assertTrue("acos of (2.0):", Double.isNaN(((Double) acosFunction
                        .evaluate(null)).doubleValue()));
            } else {
                assertEquals("acos of (2.0):", (double) Math.acos(2.0),
                        ((Double) acosFunction.evaluate(null)).doubleValue(),
                        0.00001);
            }
           
            acosFunction = ff.function("acos", literal_m2);
            double good3 = Math.acos(-2.0);
            if (Double.isNaN(good3)) {
                assertTrue("acos of (-2.0):", Double.isNaN(((Double) acosFunction
                        .evaluate(null)).doubleValue()));
            } else {
                assertEquals("acos of (-2.0):", (double) Math.acos(-2.0),
                        ((Double) acosFunction.evaluate(null)).doubleValue(),
                        0.00001);
            }
           
            acosFunction = ff.function("acos", literal_pi);
            double good4 = Math.acos(Math.PI);
            if (Double.isNaN(good4)) {
                assertTrue("acos of (3.141592653589793):", Double
                        .isNaN(((Double) acosFunction.evaluate(null))
                                .doubleValue()));
            } else {
                assertEquals("acos of (3.141592653589793):", (double) Math
                        .acos(3.141592653589793), ((Double) acosFunction
                        .evaluate(null)).doubleValue(), 0.00001);
            }
           
            acosFunction = ff.function("acos", literal_05pi);
            double good5 = Math.acos(1.5707963267948966);
            if (Double.isNaN(good5)) {
                assertTrue("acos of (1.5707963267948966):", Double
                        .isNaN(((Double) acosFunction.evaluate(null))
                                .doubleValue()));
            } else {
                assertEquals("acos of (1.5707963267948966):", (double) Math
                        .acos(1.5707963267948966), ((Double) acosFunction
                        .evaluate(null)).doubleValue(), 0.00001);
            }
        } catch (FactoryRegistryException e) {
            e.printStackTrace();
            fail("Unexpected exception: " + e.getMessage());
View Full Code Here

        Feature f = SimpleFeatureBuilder.build(type, new Object[] { "testFeature1", geom1 }, null);
       
        Geometry geom2 = reader.read("LINESTRING(10 0 0, 0 10 10)");
        Literal literal_geom = ff.literal(geom2);

        Function exp = ff.function("disjoint3D", ff.property("geom"), literal_geom);
        Object value = exp.evaluate(f);
        assertTrue(value instanceof Boolean);
        assertTrue(! (Boolean) value);
    }
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.