title: Calculating distance between two points represented by lat,long upto 15 feet accuracy
body: <p>I have converted the formula into Java provided <a href="http://tumblr.jonthornton.com/post/1419487206/calculate-latitude-longitude-distances-in-mysql-with" rel="nofollow">here</a>. But accuracy is a problem. We are using GPS coordinates. </p>
  
  <p>We are using iPhone provided GPS location that is upto 10 decimal point accuracy.</p>
  
  <pre><code>/*
   * Latitude and Longitude are in Degree
   * Unit Of Measure : 1 = Feet,2 = Kilometer,3 = Miles
   */
  //TODO 3 Change Unit of Measure and DISTANCE_IN_FEET constants to Enum
  public static Double calculateDistance(double latitudeA,double longitudeA,double latitudeB,double longitudeB,short unitOfMeasure){
  
      Double distance;
  
      distance = DISTANCE_IN_FEET * 
                 Math.acos(       
  
                                 Math.cos(Math.toRadians(latitudeA)) * Math.cos(Math.toRadians(latitudeB)) 
                             *
                                 Math.cos(Math.toRadians(longitudeB) - Math.toRadians(longitudeA))
                             +
                                 Math.sin(Math.toRadians(latitudeA))
                             *
                                 Math.sin(Math.toRadians(latitudeB))
  
                         );
  
      return distance;
  
  }
  </code></pre>
  
  <p>FYI : public static final int DISTANCE_IN_FEET = 20924640;</p>
  
  <p>And then I use Math.round(distance); to convert to long.</p>
  
  <p>For actual 25 feet, I am getting 7 feet output.</p>