Yea, about that...

Solved :-)

    private double gpsDistance(float current_lat, float current_lng,
float prev_lat, float prev_long) {

        float K = (float) (180/3.14169);

        float a = current_lat / K;
        float b = current_lng / K;
        float c = prev_lat / K;
        float d = prev_long / K;

        float ndsa =
FloatMath.cos(a)*FloatMath.cos(b)*FloatMath.cos(c)*FloatMath.cos(d);
        float ndsb =
FloatMath.cos(a)*FloatMath.sin(b)*FloatMath.cos(c)*FloatMath.sin(d);
        float ndsc = FloatMath.sin(a)*FloatMath.sin(c);
        double myTempResult = Math.acos(ndsa + ndsb + ndsc);



        return myTempResult*6366000;

    }



On 4 September 2011 22:48, Christopher Van Kirk
<[email protected]> wrote:
> It just boggles the mind.
>
> Try floats or doubles.
>
> On 9/5/2011 5:27 AM, Fred Niggle wrote:
>>
>> Many thanks for your reply, but as this is not an iOS list........
>> I've been having trouble deciding on what type of variable should be
>> used when converting the formulea from javascript to android java, and
>> I could really use some pointers.
>>
>> On 4 September 2011 02:08, lbendlin<[email protected]>  wrote:
>>>
>>> in iOS the manual function is faster than the built-in one, but on
>>> Android
>>> the difference is negligible.  here's the Objective-C version
>>>
>>> //spherical distance in meters
>>> - (CGFloat) sphericalDistanceFromLat1:(CGFloat)lat1 Lon1:(CGFloat)lon1
>>> toLat2:(CGFloat)lat2 Lon2:(CGFloat)lon2 {
>>>     return acos(sin(lat1 * 0.0174533) * sin(lat2 * 0.0174533) + cos(lat1
>>> *
>>> 0.0174533) * cos(lat2 * 0.0174533) * cos((lon2-lon1) * 0.0174533)) *
>>> 6371000;
>>> }
>>>
>>> --
>>> 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
>
> --
> 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

-- 
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