|
i have latitudes and longitudes i want to calculate distance between those latlongs and also how to retrieve existed latlongs from database like sql in c#
|
|
|
|
|
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Edit your question and provide better information.
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
Well, if your database doesn't support geo types, you could always store them as floats. To get the difference, use the Haversine[^] formula.
|
|
|
|
|
How about some codez:
public double HaversineDistance(Location location) {
double R = 6371;
double dLat = (location.Latitude - Latitude).ToRadians();
double dLon = (location.Longitude - Longitude).ToRadians();
double a = Math.Pow(Math.Sin(dLat / 2), 2) +
Math.Cos(Latitude.ToRadians()) * Math.Cos(location.Latitude.ToRadians()) *
Math.Pow(Math.Sin(dLon / 2), 2);
double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
double d = R * c;
return d;
}
|
|
|
|
|
naveen 2012 wrote: calculate distance between those latlongs
"Great circle" distance? Or "rectilinear" distance? Or "digging a hole to China" distance?
P.S. I forgot about the "Dalek Dave Pub Crawl Distance".
|
|
|
|