これを行う最善の方法は、 nのサイズとボロノイ図の多角形の数によって異なります。ただし、基本的には、セットの 1 つを反復処理し、それと相互作用する他のセット内の要素を見つける必要があります。
したがって、nがポリゴンの数よりも少ないと仮定すると、次のようになります。
// features is the collection of Voronoi polygons
// Points is the N points
Expression propertyName = filterFactory.property(features.getSchema()
.getGeometryDescriptor()
.getName());
for (Point p: points) {
Filter filter = filterFactory.contains(propertyName,
filterFactory.literal(p));
SimpleFeatureCollection sub = features.subCollection(filter);
//sub now contains your polygon
//do some processing or save ID
}
nが多角形の数よりも大きい場合 - ループを逆にして、contains の代わりに使用しwithin
て、各多角形のすべてのポイントを検索します。