Package org.opengis.filter.expression

Examples of org.opengis.filter.expression.Function


    public void testCatenateTwo() {
        Literal l = ff.literal("http://test?param=");
        PropertyName pn = ff.property("intAttribute");
        Expression cat = ExpressionExtractor.catenateExpressions(Arrays.asList(l, pn));
        assertTrue(cat instanceof Function);
        Function f = (Function) cat;
        assertEquals("Concatenate", f.getName());
        assertEquals(l, f.getParameters().get(0));
        assertEquals(pn, f.getParameters().get(1));
    }
View Full Code Here


        Literal l1 = ff.literal("http://test?param=");
        PropertyName pn = ff.property("intAttribute");
        Literal l2 = ff.literal("&param2=foo");
        Expression cat = ExpressionExtractor.catenateExpressions(Arrays.asList(l1, pn, l2));
        assertTrue(cat instanceof Function);
        Function f = (Function) cat;
        assertEquals("Concatenate", f.getName());
        assertEquals(l1, f.getParameters().get(0));
        assertEquals(pn, f.getParameters().get(1));
        assertEquals(l2, f.getParameters().get(2));
    }
View Full Code Here

    protected Expression getValue(String xpathPrefix, Expression node, AttributeMapping mapping) {
        Expression value = null;
        if (node instanceof Function) {
            // function
            Function func = (Function) node;
            Expression exp = getAsXpathExpression(func, mapping);
            if (exp != null) {
                // this function must be an AsXpath
                // return the extracted expression
                value = exp;
View Full Code Here

            if (batch > 0) {
                params.add(ff.literal(batch));
            }
        }

        Function sdo_nn = ff.function("sdo_nn", params.toArray(new Expression[params.size()]));
        PropertyIsEqualTo equalsFilter = ff.equal(sdo_nn, ff.literal(true), false);
        Query query = new Query(tname("NEIGHBORS"), equalsFilter);
       
        SimpleFeatureCollection features = source.getFeatures(query);
        return features.features();
View Full Code Here

        if (Expression.NIL.equals(fidExpression)) {
            return filter;
        }

        if (fidExpression instanceof Function) {
            Function fe = (Function) fidExpression;
            if ("getID".equalsIgnoreCase(fe.getName())) {
                LOGGER.finest("Fid mapping points to same ID as source");
                return filter;
            }
        }
View Full Code Here

        }

        Expression[] unmapped = new Expression[arguments.size()];
        unmapped = (Expression[]) arguments.toArray(unmapped);

        Function unmappedFunction = ff.function(function.getName(), unmapped);

        return Collections.singletonList(unmappedFunction);
    }
View Full Code Here

    /**
     * Test toDirectPosition function
     */
    public void testToDirectPosition() throws Exception {
        // 2 points with SRS
        Function function = ff.function("toDirectPosition", ToDirectPositionFunction.SRS_NAME,
                ff.literal("EPSG:4326"), pointOne, pointTwo);
        Object value = function.evaluate(feature);
        assertTrue(value instanceof DirectPosition);
        DirectPosition pos = (DirectPosition) value;
        assertEquals(CRS.toSRS(pos.getCoordinateReferenceSystem()), "EPSG:4326");
        assertEquals(pos.getDimension(), 2);
        assertEquals(pos.getOrdinate(0), 5.0, 0);
        assertEquals(pos.getOrdinate(1), 2.5, 0);

        // 1 point, no SRS
        function = ff.function("toDirectPosition", pointOne);
        value = function.evaluate(feature);
        assertTrue(value instanceof DirectPosition);
        pos = (DirectPosition) value;
        assertNull(pos.getCoordinateReferenceSystem());
        assertEquals(pos.getDimension(), 1);
        assertEquals(pos.getOrdinate(0), 5.0, 0);
        // invalid CRS
        try {
            function = ff.function("toDirectPosition", ToDirectPositionFunction.SRS_NAME,
                    ff.literal("1"), pointOne, pointTwo);
            function.evaluate(feature);
            fail("Shouldn't get this far with invalid SRS name: '1'");
        } catch (Throwable e) {
            LOGGER.info("Testing exception: " + e.toString());
        }
        // too many of points
        try {
            function = ff.function("toDirectPosition", pointOne, pointTwo, pointOne);
            function.evaluate(feature);
            fail("Shouldn't get this far with too many parameters: " + pointOne.toString() + ", "
                    + pointTwo.toString() + ", " + pointOne.toString());
        } catch (Throwable e) {
            LOGGER.info("Testing exception: " + e.toString());
        }
        // no points
        try {
            function = ff.function("toDirectPosition", ToDirectPositionFunction.SRS_NAME,
                    ff.literal("EPSG:WGS84"));
            function.evaluate(feature);
            fail("Shouldn't get this far with too many parameters: " + pointOne.toString() + ", "
                    + pointTwo.toString() + ", " + pointOne.toString());
        } catch (Throwable e) {
            LOGGER.info("Testing exception: " + e.toString());
        }
View Full Code Here

    /**
     * Test toPoint function
     */
    public void testToPoint() throws NoSuchAuthorityCodeException, FactoryException {
        // 2 points with SRS name and gml:id
        Function function = ff.function("toPoint", ToDirectPositionFunction.SRS_NAME,
                ff.literal("EPSG:4283"), pointOne, pointTwo, ff.literal("1"));
        Object value = function.evaluate(feature);
        assertTrue(value instanceof Point);
        Point pt = (Point) value;
        assertEquals(pt.getDimension(), 0);
        assertEquals(pt.getCoordinate().x, 5.0, 0);
        assertEquals(pt.getCoordinate().y, 2.5, 0);
        Map<Object, Object> userData = (Map<Object, Object>) pt.getUserData();
        assertEquals(userData.get("gml:id"), "1");
        assertEquals(userData.get(CoordinateReferenceSystem.class), CRS.decode("EPSG:4283"));

        // 2 points with no SRS name
        function = ff.function("toPoint", pointOne, pointTwo);
        value = function.evaluate(feature);
        assertTrue(value instanceof Point);
        pt = (Point) value;
        assertEquals(pt.getDimension(), 0);
        assertEquals(pt.getCoordinate().x, 5.0, 0);
        assertEquals(pt.getCoordinate().y, 2.5, 0);
        assertNull(pt.getUserData());
        // 1 point
        function = ff.function("toPoint", pointOne);
        try {
            value = function.evaluate(feature);
            fail("Shouldn't get this far with not enough parameters :" + pointOne.toString());
        } catch (Throwable e) {
            LOGGER.info("Testing exception: " + e.toString());
        }
        // 3 points
        function = ff.function("toPoint", ToDirectPositionFunction.SRS_NAME, ff.literal("1"),
                pointOne, pointTwo, pointOne);
        try {
            function.evaluate(feature);
            fail("Shouldn't get this far with too many parameters: " + pointOne.toString() + ", "
                    + pointTwo.toString() + ", " + pointOne.toString());
        } catch (Throwable e) {
            LOGGER.info("Testing exception: " + e.toString());
        }
View Full Code Here

    /**
     * Test toEnvelope function
     */
    public void testToEnvelope() {
        // Option 1 (1D Envelope) : <OCQL>ToEnvelope(minx,maxx)</OCQL>
        Function function = ff.function("toEnvelope", pointOne, pointTwo);
        Object value = function.evaluate(feature);
        assertTrue(value instanceof Envelope);
        Envelope env = (Envelope) value;
        assertEquals(env.getMinX(), env.getMaxX(), 0);
        assertEquals(env.getMinX(), 5.0, 0);
        assertEquals(env.getMinY(), env.getMaxY(), 0);
        assertEquals(env.getMinY(), 2.5, 0);
        // Option 2 (1D Envelope with crsname): <OCQL>ToEnvelope(minx,maxx,crsname)</OCQL>
        function = ff.function("toEnvelope", pointOne, pointTwo, ff.literal("EPSG:4283"));
        value = function.evaluate(feature);
        assertTrue(value instanceof ReferencedEnvelope);
        ReferencedEnvelope refEnv = (ReferencedEnvelope) value;
        assertEquals(refEnv.getMinX(), refEnv.getMaxX(), 0);
        assertEquals(refEnv.getMinX(), 5.0, 0);
        assertEquals(refEnv.getMinY(), refEnv.getMaxY(), 0);
        assertEquals(refEnv.getMinY(), 2.5, 0);
        assertEquals(CRS.toSRS(refEnv.getCoordinateReferenceSystem()), "EPSG:4283");
        // Option 3 (2D Envelope) : <OCQL>ToEnvelope(minx,maxx,miny,maxy)</OCQL>
        function = ff.function("toEnvelope", pointTwo, pointOne, pointTwo, pointOne);
        value = function.evaluate(feature);
        assertTrue(value instanceof Envelope);
        env = (Envelope) value;
        assertEquals(env.getMinX(), 2.5, 0);
        assertEquals(env.getMaxX(), 5.0, 0);
        assertEquals(env.getMinY(), 2.5, 0);
        assertEquals(env.getMaxY(), 5.0, 0);
        assertEquals(CRS.toSRS(refEnv.getCoordinateReferenceSystem()), "EPSG:4283");
        // Option 4 (2D Envelope with crsname): <OCQL>ToEnvelope(minx,maxx,miny,maxy,crsname)</OCQL>
        function = ff.function("toEnvelope", pointTwo, pointOne, pointTwo, pointOne,
                ff.literal("EPSG:4283"));
        value = function.evaluate(feature);
        assertTrue(value instanceof ReferencedEnvelope);
        refEnv = (ReferencedEnvelope) value;
        assertEquals(refEnv.getMinX(), 2.5, 0);
        assertEquals(refEnv.getMaxX(), 5.0, 0);
        assertEquals(refEnv.getMinY(), 2.5, 0);
View Full Code Here

    @Test
    /**
     * Test ToLineString with EPSG SRS.
     */
    public void testToLineStringEPSG() {
        Function function = ff.function("toLineString", ff.literal("EPSG:9902"), 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

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.