【发布时间】:2018-07-13 10:07:01
【问题描述】:
我是 Geotools 的新手,我创建了两个几何图形(例如两个多边形),我想计算其中一个几何图形的交集区域的百分比。
//First polygon
GeometryFactory geometryFactory1 = JTSFactoryFinder.getGeometryFactory();
Coordinate[] coords1 =
new Coordinate[] {new Coordinate(4, 0), new Coordinate(2, 2),
new Coordinate(4, 4), new Coordinate(6, 2), new Coordinate(4, 0) };
LinearRing ring1 = geometryFactory.createLinearRing( coords );
LinearRing holes[] = null;
Polygon polygon1 = geometryFactory.createPolygon(ring1, holes );
// Second polygon
GeometryFactory geometryFactory2 = JTSFactoryFinder.getGeometryFactory();
Coordinate[] coords2 =
new Coordinate[] {new Coordinate(2, 0), new Coordinate(2, 2),
new Coordinate(1, 1), new Coordinate(4, 2), new Coordinate(2, 0) };
LinearRing ring2 = geometryFactory.createLinearRing( coords );
LinearRing holes[] = null;
Polygon polygon2 = geometryFactory.createPolygon(ring2, holes );
// test if polygon2 is inside polygon1
boolean test = polygon1.contains(polygon2);
有人知道如何计算多边形 1(或圆)内多边形 2 的百分比吗?有什么算法可以计算几何之间的交集面积吗?
【问题讨论】:
标签: java geometry polygon geotools