Package org.opengis.filter.expression

Examples of org.opengis.filter.expression.Function


    /**
     * Test ToLineString with non EPSG SRS.
     */
    public void testToLineStringCustomSRS() {
        String customSRS = "#borehole.GA.1";
        Function function = ff.function("toLineString", ff.literal(customSRS), pointOne, pointTwo);
        Object value = function.evaluate(feature);
        assertTrue(value instanceof LineString);
        LineString linestring = (LineString) value;
        assertEquals(linestring.getDimension(), 1);
        // 1D SRS should be created
        CoordinateReferenceSystem crs = (CoordinateReferenceSystem) linestring.getUserData();
View Full Code Here


    @Test
    /**
     * Test ToLineString with null parameters.
     */
    public void testToLineStringNullParams() {
        Function function = ff.function("toLineString", null, null);
        try {
            function.evaluate(feature);
            fail();
        } catch (IllegalArgumentException e) {
            String msg = "Invalid parameters for toLineString function: [null, null]. Usage: toLineString(srsName, point 1, point 2)";
            assertEquals(msg, e.getMessage());
        }
View Full Code Here

    @Test
    /**
     * Test ToLineString with invalid parameters.
     */
    public void testToLineStringInvalidParams() {
        Function function = ff.function("toLineString", ff.literal("#GA.borehole.100"), Literal.NIL, ff.literal("something"));
        try {
            function.evaluate(feature);
            fail();
        } catch (IllegalArgumentException e) {
            String msg = "Error converting the parameters for toLineString function: [#GA.borehole.100, Expression.NIL, something]. Usage: toLineString(srsName, point 1, point 2)";
            assertEquals(msg, e.getMessage());
            assertTrue(e.getCause() instanceof NumberFormatException);
View Full Code Here

        }
    }
   
    @Test
    public void testConstantFunction() {
        Function cos = ff.function("cos", ff.literal(Math.toRadians(Math.PI)));
        Symbolizer ls = sb.createLineSymbolizer(sb.createStroke(sb.colorExpression(Color.BLACK), cos));
        Rule r = sb.createRule(new Symbolizer[] { ls });
        MetaBufferEstimator rbe = new MetaBufferEstimator();

        // cos(pi) == 1
View Full Code Here

    }

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

        Function function = (Function) parse();

        assertEquals("min", function.getName());
        assertEquals(2, function.getParameters().size());
    }
View Full Code Here

        return factory.function(name, args);
    }

    public Object getProperty(Object object, QName name)
        throws Exception {
        Function function = (Function) object;

        //<xsd:element maxOccurs="unbounded" minOccurs="0" ref="ogc:expression"/>
        if ("expression".equals(name.getLocalPart())) {
            return function.getParameters();
        }

        //<xsd:attribute name="name" type="xsd:string" use="required"/>
        if ("name".equals(name.getLocalPart())) {
            return function.getName();
        }

        return null;
    }
View Full Code Here

    public void testVocabFunction() {
        URL file = getClass().getResource("/test-data/minoc_lithology_mapping.properties");
        assertNotNull(file);
       
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
        Function function = ff.function("Vocab", ff.literal("1LIST"), ff.literal(DataUtilities
                .urlToFile(file).getPath()));

        Object value = function.evaluate(null);
        assertEquals(
                "urn:cgi:classifier:CGI:SimpleLithology:2008:calcareous_carbonate_sedimentary_rock",
                value);
    }
View Full Code Here

    }

    @Test
    public void testNoVocabFunction() {
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
        Function function = ff.function("Vocab", ff.literal("a"), ff.literal("urn:1234"));

        try {
            function.evaluate(null);
            fail("Should not be able to get this far");
        } catch (Throwable expected) {

        }
    }
View Full Code Here

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

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

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

            Function expFunction = ff.function("exp", literal_1);
            double good0 = Math.exp(1.0);
            if (Double.isNaN(good0)) {
                assertTrue("exp of (1.0):", Double.isNaN(((Double) expFunction
                        .evaluate(null)).doubleValue()));
            } else {
                assertEquals("exp of (1.0):", (double) Math.exp(1.0),
                        ((Double) expFunction.evaluate(null)).doubleValue(),
                        0.00001);
            }
           
            expFunction = ff.function("exp", literal_m1);
            double good1 = Math.exp(-1.0);
            if (Double.isNaN(good1)) {
                assertTrue("exp of (-1.0):", Double.isNaN(((Double) expFunction
                        .evaluate(null)).doubleValue()));
            } else {
                assertEquals("exp of (-1.0):", (double) Math.exp(-1.0),
                        ((Double) expFunction.evaluate(null)).doubleValue(),
                        0.00001);
            }
           
            expFunction = ff.function("exp", literal_2);
            double good2 = Math.exp(2.0);
            if (Double.isNaN(good2)) {
                assertTrue("exp of (2.0):", Double.isNaN(((Double) expFunction
                        .evaluate(null)).doubleValue()));
            } else {
                assertEquals("exp of (2.0):", (double) Math.exp(2.0),
                        ((Double) expFunction.evaluate(null)).doubleValue(),
                        0.00001);
            }
           
            expFunction = ff.function("exp", literal_m2);
            double good3 = Math.exp(-2.0);
            if (Double.isNaN(good3)) {
                assertTrue("exp of (-2.0):", Double.isNaN(((Double) expFunction
                        .evaluate(null)).doubleValue()));
            } else {
                assertEquals("exp of (-2.0):", (double) Math.exp(-2.0),
                        ((Double) expFunction.evaluate(null)).doubleValue(),
                        0.00001);
            }
           
            expFunction = ff.function("exp", literal_pi);
            double good4 = Math.exp(Math.PI);
            if (Double.isNaN(good4)) {
                assertTrue("exp of (3.141592653589793):", Double
                        .isNaN(((Double) expFunction.evaluate(null))
                                .doubleValue()));
            } else {
                assertEquals("exp of (3.141592653589793):", (double) Math
                        .exp(3.141592653589793), ((Double) expFunction
                        .evaluate(null)).doubleValue(), 0.00001);
            }
           
            expFunction = ff.function("exp", literal_05pi);
            double good5 = Math.exp(1.5707963267948966);
            if (Double.isNaN(good5)) {
                assertTrue("exp of (1.5707963267948966):", Double
                        .isNaN(((Double) expFunction.evaluate(null))
                                .doubleValue()));
            } else {
                assertEquals("exp of (1.5707963267948966):", (double) Math
                        .exp(1.5707963267948966), ((Double) expFunction
                        .evaluate(null)).doubleValue(), 0.00001);
            }
        } catch (FactoryRegistryException e) {
            e.printStackTrace();
            fail("Unexpected exception: " + e.getMessage());
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.