Package org.opengis.filter.expression

Examples of org.opengis.filter.expression.Function


       
        return function;       
    }
    public Function function(String name, Expression arg1, Expression arg2,
            Expression arg3) {
        Function function =
                functionFinder.findFunction( name, Arrays.asList( new Expression[]{ arg1, arg2, arg3 }) );
       
        return function;       
    }
View Full Code Here


        PropertyName property = this.resultStack.popPropertyName();

        org.opengis.filter.expression.Expression[] args = new org.opengis.filter.expression.Expression[1];
        args[0] = filterFactory.literal(property);

        Function function = filterFactory.function("PropertyExists", args);
        Literal literalTrue = filterFactory.literal(Boolean.TRUE);
       
        PropertyIsEqualTo propExistsFilter = filterFactory.equals(function,
                literalTrue);
View Full Code Here

    PropertyName property = this.resultStack.popPropertyName();

    FilterFactory2 ff = (FilterFactory2) filterFactory;
    Expression[] args = new Expression[] { property, geometry, pattern };

    Function function = filterFactory.function("relatePattern", args);

    assert function != null: "a relatePattern function is expected";

    PropertyIsEqualTo filter = ff.equals(function, ff.literal(true));
View Full Code Here

       
        Expression[] args = (Expression[]) argList
                .toArray(new Expression[argList.size()]);

        Function function = null;
        try{
            function = filterFactory.function(functionName, args);

            if (function == null) {
                throw new CQLException("Function not found.", this.cqlSource);
View Full Code Here

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

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

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

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

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

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

        }
    }

    public void testToLowerCase() {
        FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
        Function f = ff.function("strToLowerCase", ff.literal("UPCASE"));
        assertEquals("upcase", f.evaluate(null));
    }
View Full Code Here

        assertEquals("upcase", f.evaluate(null));
    }
   
    public void testToUpperCase() {
        FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
        Function f = ff.function("strToUpperCase", ff.literal("lowcase"));
        assertEquals("LOWCASE", f.evaluate(null));
    }
View Full Code Here

        fail("Exception not thrown");
    }

    public void testModulo() {
        Function function = ff.function(functionName, ff.literal(13), ff.literal(4));

        assertEquals(1, function.evaluate(null));
    }
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.