Package org.opengis.filter.expression

Examples of org.opengis.filter.expression.Function


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

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


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

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

    public void testStrReplace() {
        Literal foo = ff.literal("foo");
        Literal o = ff.literal("o");
        Literal bar = ff.literal("bar");
       
        Function f = ff.function("strReplace", new Expression[]{foo,o,bar,ff.literal(true)});
        String s = (String) f.evaluate(null,String.class);
        assertEquals( "fbarbar", s );
       
        f = ff.function("strReplace", new Expression[]{foo,o,bar,ff.literal(false)});
        s = (String) f.evaluate(null,String.class);
        assertEquals( "fbaro", s );
    }
View Full Code Here

        }       
      
        Feature f = SimpleFeatureBuilder.build(type, new Object[] { "testFeature1", gf.createPoint(new Coordinate(10, 20, 30)) }, null);
        Literal literal_geom = ff.literal(gf.createPoint(new Coordinate(10, 30, 40)));

        Function exp = ff.function("distance3D", ff.property("geom"), literal_geom);
        Object value = exp.evaluate(f);
        assertTrue(value instanceof Double);
        assertEquals(14.142135623730951, (Double) value, 0.00001);
    }
View Full Code Here

        Expression[] arguments = new Expression[mapping.length + 2];
        arguments[0] = propertyName;
        for( int i=0; i<mapping.length;i++){
            arguments[i+1] = mapping[i];
        }
        Function function = filterFactory.function("Categorize", arguments );
        ColorMapImpl colorMap = new ColorMapImpl( function );
       
        return colorMap;
    }
View Full Code Here

        Expression[] arguments = new Expression[mapping.length + 2];
        arguments[0] = propertyName;
        for( int i=0; i<mapping.length;i++){
            arguments[i+1] = mapping[i];
        }
        Function function = filterFactory.function("Recode", arguments );
        ColorReplacementImpl colorMap = new ColorReplacementImpl( function );
       
        return colorMap;
    }
View Full Code Here

        resultExpr = CQL.toExpression(cqlExpression);

        Assert.assertNotNull(resultExpr);
        Assert.assertTrue(resultExpr instanceof Function);

        Function function1 = (Function) resultExpr;
        Assert.assertEquals(2, function1.getParameters().size());

        arg1 = (Expression) function1.getParameters().get(0);
        Assert.assertTrue(arg1 instanceof PropertyName);
        Assert.assertEquals("A", ((PropertyName) arg1).getPropertyName());

        arg2 = (Expression) function1.getParameters().get(1);
        Assert.assertTrue(arg2 instanceof PropertyName);
        Assert.assertEquals("B", ((PropertyName) arg2).getPropertyName());

        // compound attribute as argument
        final String arg1Name = "gmd:aa:bb.gmd:cc.gmd:dd";
        final String arg2Name = "gmd:ee:ff.gmd:gg.gmd:hh";

        final String cqlExpression2 = "strConcat(" + arg1Name + ", " + arg2Name + ")";

        resultExpr = CQL.toExpression(cqlExpression2);

        Assert.assertNotNull(resultExpr);
        Assert.assertTrue(resultExpr instanceof Function);

        Function function = (Function) resultExpr;
        Assert.assertEquals(2, function.getParameters().size());

        arg1 = (Expression) function.getParameters().get(0);
        Assert.assertTrue(arg1 instanceof PropertyName);

        final String arg1Expected = arg1Name.replace('.', '/');
        Assert.assertEquals(arg1Expected, ((PropertyName) arg1).getPropertyName());

        arg2 = (Expression) function.getParameters().get(1);
        Assert.assertTrue(arg2 instanceof PropertyName);

        final String arg2Expected = arg2Name.replace('.', '/');
        Assert.assertEquals(arg2Expected, ((PropertyName) arg2).getPropertyName());
View Full Code Here

        cqlExpression = "strConcat(A, strConcat(B, strConcat(C, '.')))";
        expression = CQL.toExpression(cqlExpression);
        Assert.assertNotNull(expression);
        Assert.assertTrue(expression instanceof Function);

        Function function = (Function) expression;
        Assert.assertEquals(2, function.getParameters().size());

        Expression propertyName = (Expression) function.getParameters().get(0);
        Assert.assertTrue(propertyName instanceof PropertyName);
        Assert.assertEquals("A", ((PropertyName) propertyName).getPropertyName());

        Expression arg2 = (Expression) function.getParameters().get(1);
        Assert.assertTrue(arg2 instanceof Function);

        function = (Function) arg2;
        propertyName = (Expression) function.getParameters().get(0);
        Assert.assertTrue(propertyName instanceof PropertyName);
        Assert.assertEquals("B", ((PropertyName) propertyName).getPropertyName());

        arg2 = (Expression) function.getParameters().get(1);
        Assert.assertTrue(arg2 instanceof Function);

        function = (Function) arg2;
        propertyName = (Expression) function.getParameters().get(0);
        Assert.assertTrue(propertyName instanceof PropertyName);
        Assert.assertEquals("C", ((PropertyName) propertyName).getPropertyName());

        arg2 = (Expression) function.getParameters().get(1);
        Assert.assertTrue(arg2 instanceof Literal);
        Assert.assertEquals(".", ((Literal) arg2).getValue());
    }
View Full Code Here

     */
    private void assertFunctionCompositionComplex(final Expression result){

        Assert.assertTrue(result instanceof Function);

        Function function = (Function) result;
        Assert.assertEquals(2, function.getParameters().size());

        // asserts for strConcat(QS, strConcat('/', RT))
        Expression arg1 = (Expression) function.getParameters().get(0);
        Assert.assertTrue(arg1 instanceof Function);

        Function function1 = (Function) arg1;
        Assert.assertEquals(2, function1.getParameters().size());
       
        Expression funcion1Arg1 = function1.getParameters().get(0);
        Assert.assertTrue(funcion1Arg1 instanceof PropertyName);
        Assert.assertEquals("QS", ((PropertyName)funcion1Arg1).getPropertyName() );
       
        Expression arg11 = (Expression) function1.getParameters().get(1);
        Assert.assertTrue(arg11 instanceof Function);
        Function function11 = (Function) arg11;
       
        Expression funcion11Arg1 = (Expression)function11.getParameters().get(0);
        Assert.assertTrue(funcion11Arg1 instanceof Literal);
        Assert.assertEquals("/", ((Literal) funcion11Arg1).getValue());
       
        // asserts for strConcat(strConcat('/', NUMB), strConcat('/', BSUFF)) )"
        Expression arg2 = (Expression) function.getParameters().get(1);
View Full Code Here

        Expression expression = ((PropertyIsEqualTo) result).getExpression2();
        Assert.assertNotNull(expression);
        Assert.assertTrue(expression instanceof Function);

        Function function = (Function) expression;
        Assert.assertEquals(2, function.getParameters().size());

        Expression arg1 = (Expression) function.getParameters().get(0);
        Expression arg2 = (Expression) function.getParameters().get(1);
        Assert.assertTrue(arg1 instanceof PropertyName);
        Assert.assertTrue(arg2 instanceof Literal);

        Assert.assertEquals("B", ((PropertyName) arg1).getPropertyName());
        Assert.assertEquals("testParam", ((Literal) arg2).getValue());
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.