我有一个LineString featureSource。对于源中的一个特征,我想通过相同featureSource的startPoint或endPoint获取相交的行。
我尝试了这个只是endPoint:
Filter filter = ff.intersects(ff.literal(featureLastCoordinate), ff.function("endPoint", ff.literal(featureGeom)));
FeatureCollection<SimpleFeatureType, SimpleFeature> intersectedFeatColl = inputSource.getFeatures(filter);
而且:
Filter filter = ff.and(ff.intersects(ff.property(featureGeomPropName), ff.literal(featureLastCoordinate)), ff.function("endPoint", ff.literal(featureGeom)));
我无法找到过滤器的正确表达式。例如:
我想获得黄线的其他线条。
答案 0 :(得分:0)
取决于您对线条接触的确定程度,您可以执行以下操作:
LineString lineString = (LineString) first.getDefaultGeometry();
Point[] points = { lineString.getStartPoint(), lineString.getEndPoint() };
for (Point p : points) {
Filter f = CQL.toFilter("intersects( " + geom + ", " + p + ")");
SimpleFeatureCollection res = featureSource.getFeatures(f);
if (!res.isEmpty()) {
System.out.println("Point " + p + " touches ");
try (SimpleFeatureIterator itr = res.features()) {
while (itr.hasNext()) {
System.out.println(itr.next());
}
}
}
Polygon poly = (Polygon) p.buffer(10);
f = CQL.toFilter("intersects( " + geom + ", " + poly + ")");
res = featureSource.getFeatures(f);
if (!res.isEmpty()) {
System.out.println("Point " + p + " is close to ");
try (SimpleFeatureIterator itr = res.features()) {
while (itr.hasNext()) {
System.out.println(itr.next());
}
}
}
}