GeoUtils { public static double[] getBoxShape( double longitude, double latitude, double distance ) { double[] box = new double[4]; GeodeticCalculator calc = new GeodeticCalculator(); calc.setStartingGeographicPoint( longitude, latitude ); calc.setDirection( 0, distance ); Point2D north = calc.getDestinationGeographicPoint(); calc.setDirection( 90, distance ); Point2D east = calc.getDestinationGeographicPoint(); calc.setDirection( 180, distance ); Point2D south = calc.getDestinationGeographicPoint(); calc.setDirection( -90, distance ); Point2D west = calc.getDestinationGeographicPoint(); box[0] = north.getY(); box[1] = east.getX(); box[2] = south.getY(); box[3] = west.getX(); return box; }  static double[] getBoxShape( double longitude, double latitude, double distance ); static double getDistanceBetweenTwoPoints( Point2D from, Point2D to); static Point getGeoJsonPoint( double longitude, double latitude ); static boolean checkGeoJsonPointValid( double longitude, double latitude ); static boolean checkPointWithMultiPolygon( double longitude, double latitude,
        Geometry geometry ); static String replaceUnsafeSvgText(String svg ); static Geometry getGeometryFromCoordinatesAndType( FeatureType featureType, String coordinates ); static String getCoordinatesFromGeometry( Geometry geometry ); static final int SRID; }
@Test public void testGetBoxShape() { double[] box = getBoxShape( 0, 0, 110574.27 ); Assert.assertEquals( 1d, box[0], DELTA ); Assert.assertEquals( 1d, box[1], DELTA ); Assert.assertEquals( -1d, box[2], DELTA ); Assert.assertEquals( -1d, box[3], DELTA ); box = getBoxShape( -71, -53, 67137.20 ); Assert.assertEquals( -52.4, box[0], DELTA ); Assert.assertEquals( -70d, box[1], DELTA ); Assert.assertEquals( -53.6, box[2], DELTA ); Assert.assertEquals( -72d, box[3], DELTA ); }