I'm using GeoTools JTS libraries in Java and I want to find the nearest point inside polygon shape to some single target location. This is exactly what in PostGis ST_ClosestPoint does.
I found this article discussing "Snap a Point to a Line".
So trivial solution will be:
-Dump polygon to lines
-Snap a Point for each above Line
-Calculate the distance between the point and "the snapped" point
-Take the one with minimum distance
How can I achieve my requirement in GeoTools in more "elegant" way?
Actually I'm not sure if the link to snap a point doing exactly what ST_Closest because I don't understand how it's actually extracting the closest point...