GeoTools JTS: Snap a Point to a polygon (equivalent to PostGis ST_ClosestPoint)

المشرف العام

Administrator
طاقم الإدارة
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 distanceHow can I achieve my requirement in GeoTools in more "elegant" way?



أكثر...
 
أعلى