If the two-coordinate columns are (x1,y1), (x2,y2), then the distance between them:
SQRT ((x1-x2) * (X1-X2) + (y1-y2) * (Y1-Y2))
SQL sort
SELECT * from M_store
ORDER by
SQRT ((121.517759-' longitude ') * (121.517759-' longitude ') + (31.178469-' latitude ') * (31.178469-' latitude '))
PHP Compute Distance
/**
* Find the distance between two known longitude and latitude, in meters
* @param lng1,lng2 Longitude
* @param LAT1,LAT2 Latitude
* @return float distance, Unit meter
* @author www.Alixixi.com
**/
function Getdistance ($lng 1, $lat 1, $lng 2, $lat 2) {
Turn angle into Fox degree
$radLat 1=deg2rad ($lat 1);//deg2rad () function converts an angle to radians
$radLat 2=deg2rad ($lat 2);
$radLng 1=deg2rad ($lng 1);
$radLng 2=deg2rad ($lng 2);
$a = $radLat 1-$radLat 2;
$b = $radLng 1-$radLng 2;
$s =2*asin (sqrt (Pow (sin ($a/2), 2) +cos ($radLat 1) *cos ($radLat 2) *pow (sin ($b/2), 2)) *6378.137*1000;
return $s;
}
Echo getdistance (121.477551,31.270338, 118.782347,32.072796). ' M ';
Calculates the distance between two coordinate points (longitude, latitude) of the Earth SQL function
Go-Calculate the distance between two coordinate points (longitude, latitude) on the earth SQL function--lordbaby--: www.aspbc.comCREATEFUNCTION [dbo]. [Fngetdistance] (@LatBeginREAL,@LngBeginREAL,@LatEndREAL,@LngEndREAL)RETURNSFLOATAsBEGIN-distance (km)DECLARE@DistanceREALDECLARE@EARTH_RADIUSREALSET@EARTH_RADIUS =6378.137DECLARE@RadLatBeginREAL,@RadLatEndREAL,@RadLatDiffREAL,@RadLngDiffREALSET@RadLatBegin =@LatBegin*PI ()/180.0SET@RadLatEnd =@LatEnd*PI ()/180.0SET@RadLatDiff =@RadLatBegin-@RadLatEndSET@RadLngDiff =@LngBegin*PI ()/180.0-@LngEnd*PI ()/180.0SET@Distance =2*asin (SQRT (POWER (SIN (@RadLatDiff/2),2) +cos (@RadLatBegin)*cos ( @RadLatEnd) *power (SIN ( @RadLngDiff/2), 2))) set @Distance = @Distance * @EARTH_RADIUS--set @Distance = Round ( @Distance * 10000)/10000 return @DistanceEND
use: SELECT
* 
from
merchant table name
where
dbo.fngetdistance (121.4625,31.220937,longitude,latitude) < 5
/span>
C # calculates two point GPS coordinate distance
Code highlighting produced by Actipro Codehighlighter (freeware) http://www.codehighlighter.com/-->//<summary>
Calculate the distance from GPS coordinates of two points
</summary>
<param name= "N1" > 1th latitude coordinates </param>
<param name= "E1" > 1th Longitude coordinates </param>
<param name= "n2" > 2nd latitude coordinates </param>
<param name= "E2" > 2nd longitude coordinates </param>
<returns></returns>
public static double Distance (double n1, double e1, double N2, double E2)
{
Double JL_JD = 102834.74258026089786013677476285;
Double jl_wd = 111712.69150641055729984301412873;
Double b = Math.Abs ((e1-e2) * JL_JD);
Double A = Math.Abs ((n1-n2) * jl_wd);
Return Math.sqrt ((A * a + b * b));
}
SQL coordinate distance sort calculation distance (RPM)