From: <sa...@df...> - 2006-11-28 17:15:45
|
Hello, I'm still a bit new to geotools. I want to extract features out of one Featurecollection into a new FeatureCollection. To do this, I use a = bounding box geometry filter. This filter is build like shown in the tutorial. = But the subcollection I get in return is empty. If I build the new FeatureCollection manually, it contains two features. The following code snippet shows what I'm doing: ... FeatureIterator it =3D fc1.features(); FeatureIterator it2 =3D fc2.features(); Feature f =3D null; Feature f2 =3D null; FeatureCollection includes =3D null; =20 while(it.hasNext()){ f =3D it.next(); =20 //build filter Envelope envelope =3D f.getBounds(); //envelope =3D f.getDefaultGeometry().getEnvelopeInternal(); FilterFactory ff =3D = FilterFactoryFinder.createFilterFactory(); Expression bbox; Expression geometry =3D ff.createAttributeExpression( = "the_geom" ); GeometryFilter bboxFilter; try { bbox =3D ff.createBBoxExpression( envelope ); bboxFilter =3D ff.createGeometryFilter(AbstractFilter.GEOMETRY_BBOX); bboxFilter.addLeftGeometry( geometry ); bboxFilter.addRightGeometry( bbox ); } catch (IllegalFilterException e) { throw (RuntimeException) new RuntimeException( = ).initCause( e ); } //build new featureCollection using filter includes =3D fc2.subCollection(bboxFilter); //now the collection is empty System.out.println(includes.size()); //build new featureCollection manually: DefaultFeatureCollections dfc =3D new = DefaultFeatureCollections(); includes =3D dfc.newCollection(); while (it2.hasNext()) { f2 =3D it2.next(); =20 //if(f.getDefaultGeometry().intersects(f2.getDefaultGeometry())){ if(f.getBounds().intersects(f2.getBounds())){ includes.add(f2); } } it2.close(); //now the collection contains two features System.out.println(includes.size()); } it.close(); ... Has someone ideas, why the results differ? Your help would be much appreciated! Regards, Kerstin S=E4lzer |