Hi can anyone help?
I am trying to find a query that can work out the distance in miles and Km between two points using longitude and latitude using MySQL 4.1.10a...
I have the data but not a very mathamatical mind.
Any help would be greatly appreciated!
Rgds Ian
Distance between to points (londitude and latitude)
Moderator: General Moderators
- icarpenter
- Forum Commoner
- Posts: 84
- Joined: Mon Mar 07, 2005 8:12 am
- Location: Kent, England
- icarpenter
- Forum Commoner
- Posts: 84
- Joined: Mon Mar 07, 2005 8:12 am
- Location: Kent, England
I found the soloution by using the following...
$lat1 = 'latitude value 1';
$lon1 = 'longitude value 1';
$earths_radius = '3956';
SELECT lat, lon,
acos(sin($lat1*3.14/180.0)*sin(lat*3.14/180.0)+
cos($lat1*3.14/180.0)*cos(lat*3.14/180.0)*
cos((lon*3.14/180.0)-($lon1*3.14/180.0)))*($earths_radius) as distance
FROM table
$lat1 = 'latitude value 1';
$lon1 = 'longitude value 1';
$earths_radius = '3956';
SELECT lat, lon,
acos(sin($lat1*3.14/180.0)*sin(lat*3.14/180.0)+
cos($lat1*3.14/180.0)*cos(lat*3.14/180.0)*
cos((lon*3.14/180.0)-($lon1*3.14/180.0)))*($earths_radius) as distance
FROM table