如何在Java中找到多边形和线串的相交边?

时间:2013-09-03 09:31:46

标签: jts

我在java中使用JTS 我有一个Polygon和一个LineString, 我可以很容易地找到LineString与Polygon相交的坐标。

  Geometry  intersections = polygon.intersection(line);
  for(Coordinate coor : intersections.getCoordinates()){
        System.out.println("Intersects at "+coor);
}

但我需要的是,LineString与Polygon相交的Polygon边缘。 有什么方法或任何方法可以使用线条返回多边形的交叉边缘吗?

1 个答案:

答案 0 :(得分:1)

我猜你可以得到多边形的边界然后执行那个交集。像这样:

Geometry  intersections = polygon.getBoundary().intersection(line);
for(Coordinate coor : intersections.getCoordinates()){
      System.out.println("Intersects at "+coor);
}