2017-01-08 96 views
1

我使用JTS拓撲套件從大量點(座標)生成voronoi多邊形。使用VoronoiDiagramBuilder.setClipEnvelope代替矩形的多邊形

VoronoiDiagramBuilder voronoi=new VoronoiDiagramBuilder(); 
voronoi.setTolerance(0.001); 
voronoi.setSites(coordinates); 
voronoi.setClipEnvelope(...); 
Geometry geo =voronoi.getDiagram(new GeometryFactory()); 

方法voronoi.setClipEnvelope只接受矩形(boundingBox的),然而我想所以沒有Voronoi圖生成自定義的多邊形,而不是一個邊界框是比自定義多邊形大。

這可能嗎?使用這個API或者其他組件。

回答

1

最好的(?只)的方式來做到這一點是計算信封Voronoi圖,然後使用類似的東西夾在你的多邊形:在你的答案

Geometry out = geo.intersection(polygon); 
+0

的「多邊形」 ...是我的'自定義'多邊形? –

+1

是的,它是裁剪多邊形 –