public static Point closestPoint ( Geometry geomA , Geometry geomB ) { if ( geomA == null || geomB == null ) { return null ; } // Return the closest point on geomA. (We would have used index // 1 to return the closest point on geomB.) return geomA . getFactory ( ) . createPoint ( DistanceOp . nearestPoints ( geomA , geomB ) [ 0 ] ) ; }
Returns the 2D point on geometry A that is closest to geometry B .