@@ -0,0 +1,3030 @@
+package com.giannoules.proxstor.nearby;%0A%0Aimport com.giannoules.proxstor.ProxStorDebug;%0Aimport com.giannoules.proxstor.api.Location;%0Aimport static com.tinkerpop.blueprints.Compare.GREATER_THAN_EQUAL;%0Aimport static com.tinkerpop.blueprints.Compare.LESS_THAN_EQUAL;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Apublic class Coordinates %7B%0A%0A    private static double R = 6372797.560856;%0A    %0A    public Double latitude;%0A    public Double longitude;%0A    %0A    public Coordinates() %7B%0A        latitude = null;%0A        longitude = null;%0A    %7D%0A    %0A    public Coordinates(Double latitude, Double longitude) %7B%0A        this.longitude = longitude;%0A        this.latitude = latitude;%0A    %7D%0A    %0A    public Coordinates(Location loc) %7B%0A        this.longitude = loc.getLongitude();%0A        this.latitude = loc.getLatitude();%0A    %7D%0A%0A    /**%0A     * @return the latitude%0A     */%0A    public Double getLatitude() %7B%0A        return latitude;%0A    %7D%0A%0A    /**%0A     * @param latitude the latitude to set%0A     */%0A    public void setLatitude(Double latitude) %7B%0A        this.latitude = latitude;%0A    %7D%0A%0A    /**%0A     * @return the longitude%0A     */%0A    public Double getLongitude() %7B%0A        return longitude;%0A    %7D%0A%0A    /**%0A     * @param longitude the longitude to set%0A     */%0A    public void setLongitude(Double longitude) %7B%0A        this.longitude = longitude;%0A    %7D%0A    %0A    public Double distanceFrom(Coordinates other) %7B%0A      /*%0A       * haversign%0A       * from http://www.codecodex.com/wiki/Calculate_distance_between_two_points_on_a_globe#Java%0A       */%0A      double R = 6372797.560856;%0A      double lat1 = this.latitude;  %0A      double lat2 = other.getLatitude();  %0A      double lon1 = this.longitude;  %0A      double lon2 = other.getLongitude();  %0A      double dLat = Math.toRadians(lat2-lat1);  %0A      double dLon = Math.toRadians(lon2-lon1);  %0A      double a = Math.sin(dLat/2) * Math.sin(dLat/2) +  %0A         Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) *  %0A         Math.sin(dLon/2) * Math.sin(dLon/2);  %0A      double c = 2 * Math.asin(Math.sqrt(a));%0A      double distance = R * c;%0A      %0A      return distance;%0A    %7D%0A    %0A    public List%3CCoordinates%3E boundingBox(Double d) %7B%0A        %0A        List%3CCoordinates%3E coordinates = new ArrayList%3C%3E();%0A        Double lat;%0A        Double lon;%0A        Double bearing;%0A        %0A        // convert distance (d) into hypotenuse of bounding box%0A        d = Math.sqrt(2*(d*d));%0A                       %0A        bearing = Math.toRadians(315);%0A        lat = Math.toDegrees((d/R) * Math.cos(bearing)) + latitude;%0A        lon = Math.toDegrees((d/(R * Math.sin(Math.toRadians(lat)))) * Math.sin(bearing)) + longitude;%0A        coordinates.add(new Coordinates(lat, lon));%0A        %0A        bearing = Math.toRadians(135);%0A        lat = Math.toDegrees((d/R) * Math.cos(bearing)) + latitude;%0A        lon = Math.toDegrees((d/(R * Math.sin(Math.toRadians(lat)))) * Math.sin(bearing)) + longitude;%0A        coordinates.add(new Coordinates(lat, lon));%0A        %0A        return coordinates;     %0A    %7D%0A    %0A%7D%0A

introduce Coordinates