Below is the code to calculate distance between two geo points.
public double distance_Haversine(double latVal1,double lonVal1,double latVal2,double lonVal2)
double dist = 0.0;
double deltaLat = Math.toRadians(latVal2 - latVal1);
double deltaLon = Math.toRadians(lonVal2 - lonVal1);
latVal1 = Math.toRadians(latVal1);
latVal2 = Math.toRadians(latVal2);
lonVal1 = Math.toRadians(lonVal1);
lonVal2 = Math.toRadians(lonVal2);
double earthRadius = 6371;
double a = Math.sin(deltaLat/2) * Math.sin(deltaLat/2) +
Math.cos(latVal1) * Math.cos(latVal2) * Math.sin(deltaLon/2) * Math.sin(deltaLon/2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
dist = earthRadius * c;
it works fine in android but when i tried to use it in core j2me through net Beans it is giving me error like function atan2 is not supported.
I had imported all the math libraries however my program failed to compile.
Can some one give me any alternative to calculate distance between two Geo points or any alternative math function to replace atan2??