public static Coordinate [ ] getFurthestCoordinate ( Coordinate base , Coordinate [ ] coords ) { double distanceMax = Double . MIN_VALUE ; Coordinate farCoordinate = null ; for ( Coordinate coord : coords ) { double distance = coord . distance ( base ) ; if ( distance > distanceMax ) { distanceMax = distance ; farCoordinate = coord ; } } if ( farCoordinate != null ) { return new Coordinate [ ] { base , farCoordinate } ; } else { return null ; } }
Find the furthest coordinate in a geometry from a base coordinate