Package org.opengis.filter

Examples of org.opengis.filter.FilterFactory2


    public void testReadOutside() throws Exception {
        File f = copyShapefiles("shapes/statepop.shp");
        ShapefileDataStoreFactory fac = new ShapefileDataStoreFactory();
        ShapefileDataStore ds = (ShapefileDataStore) createDataStore(fac, f.toURI().toURL(), true);
        Query q = new Query(ds.getTypeNames()[0]);
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
        q.setFilter(ff.bbox("the_geom", -62, -61, 23, 22, null));
        assertEquals(0, ds.getFeatureSource().getFeatures(q).size());
        ds.dispose();
    }
View Full Code Here


        Map params = new HashMap();
        params.put(ShapefileDataStoreFactory.URLP.key, file.toURI().toURL());
        params.put(ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX.key, new Boolean(true));
        ShapefileDataStore ds = (ShapefileDataStore) fac.createDataStore(params);

        FilterFactory2 ff = (FilterFactory2) CommonFactoryFinder.getFilterFactory(GeoTools
                .getDefaultHints());

        FeatureId featureId = ff.featureId("streams.84");
        Id filter = ff.id(Collections.singleton(featureId));
        SimpleFeatureCollection features = ds.getFeatureSource().getFeatures(filter);

        SimpleFeatureIterator iter = features.features();
        ReferencedEnvelope bounds;
        try {
            bounds = new ReferencedEnvelope(iter.next().getBounds());
        } finally {
            iter.close();
        }

        FeatureId id = featureId;
        filter = ff.id(Collections.singleton(id));

        Query query = new Query(ds.getTypeNames()[0], filter);

        Envelope result = ds.getFeatureSource().getBounds(query);
View Full Code Here

       
        // Ensure painted legend matches image from file
        Assert.assertTrue(imagesIdentical(paintedImage, testImage));
    }
    public void testGraphicLegendRotation() throws Exception {
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
        GeometryFactory gf = JTSFactoryFinder.getGeometryFactory();
       
        // Load image directly from file, for comparison with painter output
        final URL imageURL = TestData.getResource(this, "icon64.png");
        final BufferedImage testImage = ImageIO.read(imageURL);       
        final int width = testImage.getWidth();
        final int height = testImage.getHeight();
       
        // Get graphic legend from style
        final Style style = RendererBaseTest.loadStyle(
                this, "testGraphicLegend.sld");
        final Rule rule = style.featureTypeStyles().get(0).rules().get(0);
        final GraphicLegend legend = (GraphicLegend) rule.getLegend();
       
       
        // Set rotation to 45 degrees
        legend.setRotation( ff.literal(45.0) );
       
        // Paint legend using StyledShapePainter
        final Point point = gf.createPoint(new Coordinate(width / 2, height / 2));
        final LiteShape2 shape = new LiteShape2(point, null, null, false);
       
View Full Code Here

          // wkb type 7, replace GeometryCollection with MultiLineString         
          // code in superclass: GeometryCollection geometry = new GeometryCollection(geometries, factory );
          // For DB2, we must use the following line of code
          MultiLineString ml = gf.createMultiLineString(geometries);
         
          FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
         
          PropertyName p = ff.property(aname("geom"));       
          Literal collect = ff.literal(ml);
       
          DWithin dwithinGeomCo  = ((FilterFactory2) ff).dwithin(p, collect, 5, "meter");
          Query dq = new Query(tname("road"), dwithinGeomCo);
          SimpleFeatureCollection features = dataStore.getFeatureSource(tname("road")).getFeatures(dq);
          assertEquals(0, features.size());
View Full Code Here

        GeometryFactory factory = new GeometryFactory();
        Point point = factory.createPoint(coordinate);
        Geometry[] geometries = {point};
        GeometryCollection geometry = new GeometryCollection(geometries, factory );

        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);

        PropertyName geomName = ff.property(aname("geom"));
        Literal lit = ff.literal(geometry);
       
        DWithin dwithinGeomFilter  = ((FilterFactory2) ff).dwithin(geomName, lit, distance, unit);
        Query query = new Query(tname("road"), dwithinGeomFilter);
        SimpleFeatureCollection features = dataStore.getFeatureSource(tname("road")).getFeatures(query);
        assertEquals(1, features.size());
View Full Code Here

    protected JDBCDataStoreAPITestSetup createTestSetup() {
        return new SQLServerSpatialFiltersTestSetup();
    }

    public void testPointDistance() throws IOException, ParseException {
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
        Geometry point = new WKTReader().read("POINT(180000 0)");
        DWithin filter = ff.dwithin(ff.property(aname("geom")), ff.literal(point), 15000, "m");
       
        ContentFeatureCollection fc = dataStore.getFeatureSource(tname("ppoint")).getFeatures(filter);
        assertEquals(1, fc.size());
    }
View Full Code Here

        SimpleFeatureStore roadFromClient2 = (SimpleFeatureStore) store.getFeatureSource("road");
        Transaction transaction2 = new DefaultTransaction("Transaction Used by Client 2");
        roadFromClient2.setTransaction(transaction2);

        FilterFactory2 ff = (FilterFactory2) CommonFactoryFinder.getFilterFactory(null);
        Filter selectFid1 = ff.id(Collections.singleton(ff.featureId("fid1")));

        // Before we edit everything should be the same
        assertEquals("auto before", 5, roadAuto.getFeatures().size());
        assertEquals("client 1 before", 5, roadFromClient1.getFeatures().size());
        assertEquals("client 2 before", 5, roadFromClient2.getFeatures().size());
View Full Code Here

            }
        }, null );
        assertFalse( selection.isEmpty() );
       
        // try with filter and no attributes
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
        String geomName = schema.getGeometryDescriptor().getName().getLocalPart();
       
        query.setFilter( ff.bbox( ff.property(geomName), bounds) );
        features = featureSource.getFeatures( query );
       
        assertNotNull("selection query worked", features );
        assertTrue( "selection non empty", !features.isEmpty() );       
        assertEquals(selection.size(), features.size());
View Full Code Here

                        + "FROM \"schema\".\"road\" "
                        + "WHERE  \"geom\".Filter(geometry::STGeomFromText('POLYGON ((2 -1, 2 5, 4 5, 4 -1, 2 -1))', 4326)) = 1 "
                        + "AND geometry::STGeomFromText('POLYGON ((2 -1, 2 5, 4 5, 4 -1, 2 -1))', 4326).STContains(\"geom\") = 1");

        // the filter for the Query
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
        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);
        Contains cs = ff.contains(ff.literal(polygon), ff.property(aname("geom")));

        SimpleFeatureType roadSchema = dataStore.getSchema("road");
        originalSchema = dataStore.getDatabaseSchema();
        dataStore.setDatabaseSchema("schema");
        dialect.handleSelectHints(sql1, roadSchema, new Query("road", cs));
View Full Code Here

        URL url = shpFile.toURI().toURL();
        ShapefileDataStore ds = new ShapefileDataStore(url);
        SimpleFeatureSource fs = ds.getFeatureSource();
       
        // build a query that extracts no geom but uses a bbox filter
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
        Query q = new Query();
        q.setPropertyNames(new String[] {"STATE_NAME", "PERSONS"});
        ReferencedEnvelope queryBounds = new ReferencedEnvelope(-75.102613, -72.361859, 40.212597,
                41.512517, null);
        q.setFilter(ff.bbox(ff.property(""), queryBounds));
       
        // grab the features
        SimpleFeatureCollection fc = fs.getFeatures(q);
        assertTrue(fc.size() > 0);
        ds.dispose();
View Full Code Here

TOP

Related Classes of org.opengis.filter.FilterFactory2

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.