I have two shape files, one of polygons and one of points. I want to find out
1) the id’s of all the points that fall into a polygon
2) the id’s of the points that do not fall in any polygon
3) the id’s of any points that lie outside the bonding box of the polygons file
This is how I got started:
public static Map<FeatureId, Integer>
computeAssetsExposure(SimpleFeatureCollection assetsfc, SimpleFeatureCollection
exposurefc) throws IOException {
Class<?> geomAsset =
assetsfc.getSchema().getGeometryDescriptor().getType().getBinding();
Class<?> geomExposure =
exposurefc.getSchema().getGeometryDescriptor().getType().getBinding();
String geomExposureAttr =
exposurefc.getSchema().getGeometryDescriptor().getLocalName();
if (geomExposure.equals(Polygon.class) ||
geomExposure.equals(MultiPolygon.class))
{
CommonLogger.getInstance().logInfo(ExposureCalculator.class, "Unsupported
configuration");
return null;
}
// Points that fall in a polygon
Filter orFilter = null;
try (SimpleFeatureIterator eIt = exposurefc.features()) {
boolean start = true;
while (eIt.hasNext()) {
SimpleFeature expFeature = eIt.next();
Geometry expGeom = (Geometry) expFeature.getDefaultGeometry();
String expr = "INTERSECTS(" + geomExposureAttr + ", " + expGeom.toText() + ")";
if (start)
{
orFilter = CQL.toFilter(expr);
start = false;
} else {
orFilter = Filters.or(CommonFactoryFinder.getFilterFactory2(), orFilter,
CQL.toFilter(expr));
}
}
}
SimpleFeatureCollection exposedAssets = assetsfc.subCollection(orFilter);
??????
}
To get the Ids I think I could use an IdCollectorFilterVisitor.ID_COLLECTOR,
but I can’t figure out how to use it.
Once I’ve found out the points that are in a polygon, is there a quick way to
find out the id’s of the remaining ones? Or do I have to build Filters.and(…)
with the individual filters being DISJOINT filters?
How do I find out if there are any points that lie outside the extent of the
polygon shapefile?
Many thanx!
Gaby
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users