CoordinatesUtils { 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; } } private  CoordinatesUtils(); static double interpolate(Coordinate firstCoordinate, Coordinate lastCoordinate, Coordinate toBeInterpolated); static boolean contains(Coordinate[] coords, Coordinate coord); static boolean contains2D(Coordinate[] coords, Coordinate coord); static boolean contains3D(Coordinate[] coords, Coordinate coord); static double[] zMinMax(final Coordinate[] cs); static Coordinate[] getFurthestCoordinate(Coordinate base, Coordinate[] coords); static double length3D(CoordinateSequence pts); static double length3D(Geometry geom); static double length3D(LineString lineString); static double length3D(Polygon polygon);  }
@Test public void testFindFurthestPoint() throws Exception { Geometry geom = wKTReader.read("LINESTRING(0 1, 20 8, 20 0)"); Coordinate expectedCoord = new Coordinate(20, 8); Coordinate[] coords = CoordinatesUtils.getFurthestCoordinate(new Coordinate(0, 0), geom.getCoordinates()); double expectedDistance = new Coordinate(0, 0).distance(expectedCoord); assertEquals(expectedDistance, coords[0].distance(coords[1]), 10E-9); }