code: public static double distance(double p1lat, double p1lon, double p2lat, double p2lon) {
          return RADIUS
                          * Math.acos(makeDoubleInRange(Math.sin(p1lat) * Math.sin(p2lat)
            + Math.cos(p1lat) * Math.cos(p2lat)
            * Math.cos(p2lon - p1lon)));
      }
docs: Calculates the great circle distance between two points (law of cosines).
  
  @param p1lat indicating the first point latitude.
  @param p1lon indicating the first point longitude.
  @param p2lat indicating the second point latitude
  @param p2lon indicating the second point longitude
  @return The 2D great-circle distance between the two given points, in meters.