Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using JTS, how to find the nearest point on a polygon's boundary from an outside point?

Tags:

topology

jts

Using JTS, how to find the nearest point on a polygon's boundary from an outside point?

like image 224
user521044 Avatar asked Nov 26 '10 07:11

user521044


1 Answers

Check out the DistanceOp. It returns an array of Coordinates:

Coordinate[] pts = DistanceOp.closestPoints(poly, outsidePoint);

pts[0] will be the point on the first geometry (in this case the polygon) and pts[1] will be on the second geometry (so, the same outside point you just passed in).

like image 74
Eggplant Jeff Avatar answered Sep 19 '22 16:09

Eggplant Jeff