Hi Vurfem,
Leaving out the code to connect to shapefiles etc. which it looks like
you've got under control, here's one way to do it (others will suggest
much better ways I'm sure !)...
FeatureSource<SimpleFeatureType, SimpleFeature> parcelSrc = ... //
from parcels shapefile
FeatureSource<SimpleFeatureType, SimpleFeature> buildingSrc = ... //
from buildings shapefile
FeatureCollection<SimpleFeatureType, SimpleFeature> buildingColl =
buildingSrc.getFeatures();
WKTWriter wktWriter = new WKTWriter();
FeatureIterator<SimpleFeature> iter = buildingColl.features();
try {
while (iter.hasNext()) {
SimpleFeature building = iter.next();
Geometry geom = (Geometry) building.getDefaultGeometry();
String filterStr = "CONTAINS(the_geom, " + wktWriter.write(geom) + ")";
Filter filter = CQL.toFilter(filterStr);
FeatureCollection<SimpleFeatureType, SimpleFeature> parcelColl
= parcelSrc.getFeatures(filter);
if (!parcelColl.isEmpty()) {
FeatureIterator<SimpleFeature> parcelIter =
parcelColl.features();
try {
while (parcelIter.hasNext()) {
// ... get whatever data for the parcel
that contains the building
}
} finally {
parcelIter.close();
}
}
}
} finally {
iter.close();
}
}
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.
http://p.sf.net/sfu/bobj-july_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users