Unless you are dealing with "extreme" distances I'd say it is safe to
assume that you are simple measuring the distance between two points
in a plane.

Side note: I ran into similar trouble when trying to calculate the
moving speed using GPS and found that the location object had a
.getSpeed() method.

On Sat, Sep 3, 2011 at 2:08 PM, Fred Niggle <[email protected]> wrote:
> Hello,
>
> I'm trying to work out the distance moved between 2 points with GPS 
> coordinates.
>
> I have found the haversine function, but I'm not sure how to convert
> it to run within androids java.
>
> Can anyone help?
>
> JavaScript:
>
> var R = 6371; // km
> var dLat = (lat2-lat1).toRad();
> var dLon = (lon2-lon1).toRad();
> var lat1 = lat1.toRad();
> var lat2 = lat2.toRad();
>
> var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
>        Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2);
> var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
> var d = R * c;
>
> Regards,
> Fred
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Michael Banzon
http://michaelbanzon.com/

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to