Location vs GeoPoint vs 1E6 vs Charging
<p>I am writing a location based App and want to get some wisdom on sensible API usage.</p>

<p>What I've understood so far is that working with int is more efficient. I'm going to need to store loads of them and do alot of distance calculations.</p>

<p>My app uses a Service that implements LocationListener and I am storing longitude &amp; latitude as int values (micro-degrees) inside an SQL db (via ormlite) calculated thus ::</p>

<pre><code>public static int degreesToMicroDegrees(double degrees){
    return (int)(degrees * 1E6);
}
</code></pre>

<p>Sometimes I need to know when I have returned to a particular 'location' and as such I fetch the int values back out of the db to compare with the latest location update.</p>

<p>Question is, what is the best way to compare 'location' between the int values (where I used to be) and the double values (where I am now) in my latest Location update?</p>

<p>I have searched around for some Math to accomplish the distance calculation and found this ::</p>

<pre><code>public static double distanceBetween(double lat1, double lng1, double lat2, double lng2) {

          double earthRadius = 3958.75; 
          double dLat = Math.toRadians(lat2-lat1); 
          double dLng = Math.toRadians(lng2-lng1); 
          double a = Math.sin(dLat/2) * Math.sin(dLat/2) + 
                   Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * 
                   Math.sin(dLng/2) * Math.sin(dLng/2); 
          double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
          double dist = earthRadius * c; 

          return dist; 
        } 
</code></pre>

<p>I have tried passing my int values in like this :: ((double)myIntValue) / 1E6F
The returned distance values are confusing me. If I walk 100m my app sensibly tells me I've gone about 100m using Location.distanceTo(myLastLocation). But if I use the method above against my stored int values I get the value zero back.</p>

<p>If anyone can explain the E6 format that would be great. </p>

<p>1E6 is the same as 1000000 ? </p>

<p>Additionally I can see there is this GeoPoint class. I am hesitant to use this as I'm not clear if making vast numbers of calculations on GeoPoints is going to be charged for by Google. There seems to be some noise about charges for use of GoogleMaps APIs and I haven't been able to find a clear explanation of how that charging works.</p>

<p>All wisdom gratefully received.</p>
