Package org.opengis.filter.spatial

Examples of org.opengis.filter.spatial.Within


    public void testWithinFilter() throws Exception {
        FeatureType ft = this.dataStore.getSchema(testData.getTempTableName());

        // Build the filter
        Polygon p = buildPolygon(-9, -9, -8, -8);
        Within filter = ff.within(ff.literal(p), ff.property("SHAPE"));
        runTestWithFilter(ft, filter, false);

        // now build the opposite filter, the polygon contains the shape
        p = buildPolygon(-1, -1, 1, 1);
        filter = ff.within(ff.property("SHAPE"), ff.literal(p));
View Full Code Here


        And f = (And) parse();
        assertNotNull(f);
        assertEquals(2, f.getChildren().size());
       
        Within f1 = (Within) f.getChildren().get(0);
        assertEquals("WKB_GEOM", ((PropertyName)f1.getExpression1()).getPropertyName());
        assertTrue(f1.getExpression2().evaluate(null) instanceof Polygon);
       
        PropertyIsBetween f2 = (PropertyIsBetween) f.getChildren().get(1);
        assertEquals("DEPTH", ((PropertyName)f2.getExpression()).getPropertyName());
        assertEquals(400, f2.getLowerBoundary().evaluate(null, Integer.class).intValue());
        assertEquals(800, f2.getUpperBoundary().evaluate(null, Integer.class).intValue());
View Full Code Here

    }

    public void testWithinParse() throws Exception {
        FilterMockData.within(document, document);

        Within within = (Within) parse();

        assertNotNull(within.getExpression1());
        assertNotNull(within.getExpression2());
    }
View Full Code Here

    }

    public void testWithinParse() throws Exception {
        FilterMockData.within(document, document);

        Within within = (Within) parse();

        assertNotNull(within.getExpression1());
        assertNotNull(within.getExpression2());
    }
View Full Code Here

    }
   
    public void testWithFunctionParse() throws Exception {
      FilterMockData.withinWithFunction(document, document);
       
        Within within = (Within) parse();
       
        assertNotNull(within.getExpression1());
        assertNotNull(within.getExpression2());
       
        assertTrue( within.getExpression2() instanceof Function);
    }
View Full Code Here

        init();
        FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory();
        GeometryFactory gf = new GeometryFactory();
        PackedCoordinateSequenceFactory sf = new PackedCoordinateSequenceFactory();
        Polygon ls = gf.createPolygon(sf.create(new double[] { -185, -98, 185, -98, 185, 98, -185, 98, -185, -98 }, 2));
        Within f = ff.within(ff.property("geo"), ff.literal(ls));
        SimpleFeatureCollection features = featureSource.getFeatures(f);
        assertEquals(11, features.size());
    }
View Full Code Here

        init("not-active");
        FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory();
        GeometryFactory gf = new GeometryFactory();
        PackedCoordinateSequenceFactory sf = new PackedCoordinateSequenceFactory();
        Polygon ls = gf.createPolygon(sf.create(new double[] { 0, 0, 0, 6, 6, 6, 6, 0, 0, 0 }, 2));
        Within f = ff.within(ff.property("geo"), ff.literal(ls));
        SimpleFeatureCollection features = featureSource.getFeatures(f);
        assertEquals(1, features.size());
        SimpleFeatureIterator fsi = features.features();
        assertTrue(fsi.hasNext());
        assertEquals(fsi.next().getID(), "not-active.12");
View Full Code Here

      GeometryFactory gf = new GeometryFactory(new PrecisionModel());
      Polygon geom = gf.createPolygon(gf.createLinearRing(coords), new LinearRing[0]);
        Literal expr2 = new LiteralExpressionImpl(geom );
        PropertyName expr1 = new AttributeExpressionImpl(testSchema, "testGeometry");
       
        Within filter = fac.within(expr1, expr2);

        LOGGER.finer( filter.toString());           
        LOGGER.finer( "contains feature: " + filter.evaluate(testFeature));
        assertTrue(filter.evaluate(testFeature));

        Function function = new GeometryFunction(geom);
        filter = fac.within(expr1, function);
        LOGGER.finer( filter.toString());           
        LOGGER.finer( "contains feature: " + filter.evaluate(testFeature));
        assertTrue(filter.evaluate(testFeature));

        filter = fac.within(expr2, expr1);

        LOGGER.finer( filter.toString());           
        LOGGER.finer( "contains feature: " + filter.evaluate(testFeature));
        assertFalse(filter.evaluate(testFeature));

        coords = new Coordinate[] {
          new Coordinate(2, 2),
          new Coordinate(6, 0),
              new Coordinate(6, 7),
              new Coordinate(0, 7),
              new Coordinate(2, 2)
      };
        expr2 = new LiteralExpressionImpl(gf.createPolygon(gf.createLinearRing(coords), new LinearRing[0]));
        filter = fac.within(expr2, expr1);

        LOGGER.finer( filter.toString());           
        LOGGER.finer( "contains feature: " + filter.evaluate(testFeature));
        assertFalse(filter.evaluate(testFeature));
       
        expr2 = new LiteralExpressionImpl(null);
        filter = fac.within(expr2, expr1);

        LOGGER.finer( filter.toString());           
        LOGGER.finer( "contains feature: " + filter.evaluate(testFeature));
        assertFalse(filter.evaluate(testFeature));

  }
View Full Code Here

        GeometryFactory gf = new GeometryFactory();
        PackedCoordinateSequenceFactory sf = new PackedCoordinateSequenceFactory();
        LinearRing shell = gf.createLinearRing(sf.create(new double[] { 2, -1, 2, 5, 4, 5, 4, -1,
                2, -1 }, 2));
        Polygon polygon = gf.createPolygon(shell, null);
        Within wt = ff.within(ff.property(aname("geom")), ff.literal(polygon));
        FeatureCollection features = dataStore.getFeatureSource(tname("road")).getFeatures(wt);
        checkSingleResult(features, "r2");
    }
View Full Code Here

TOP

Related Classes of org.opengis.filter.spatial.Within

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.