Because of a wrong algorithm.
function encludean_method($lat1,$lon1,$lat2,$lon2)
{
$x1 = doubleval($lat1);
$y1 = doubleval($lon1);
$x2 = doubleval($lat2);
$y2 = doubleval($lon2);
$x = doubleval( pow($x2 - $x1, 2.0));
$y = doubleval( pow($y2 - $y1, 2.0));
$distance = doubleval(sqrt($x + $y));
return ($distance);
}
Note: (x12 - x22) < (x1 - x2)2.
That's why your code gave x = float(0.00093541820670495)
and y = float(-0.11753762299304)
. So, sqrt(x + y)
is too close to zero.
But if you are trying to get the distance between that point over the Earth surface, you should use another formula - the one you are using is applicable for Cartesian coordinate system only.
Notice, that latitude and longitude are measured in degrees. So the number you get is a bit misterious =)
So, after googling a bit, i've noticed some interesting services and formulas. Here's the code you are possibly trying to invoke:
function encludean_method($lat1, $lon1, $lat2, $lon2)
{
$R = 6372.8; // km
$lat1 = deg2rad($lat1);
$lat2 = deg2rad($lat2);
$lon1 = deg2rad($lon1);
$lon2 = deg2rad($lon2);
$a = (cos($lat2) * cos($lon2)) - (cos($lat1) * cos($lon1));
$b = (cos($lat2) * sin($lon2)) - (cos($lat1) * sin($lon1));
$c = sin($lat2) - sin($lat1);
$ch = sqrt(pow($a, 2.0) + pow($b, 2.0) + pow($c, 2.0));
$phi = 2.0 * asin($ch / 2.0);
return $R * $phi;
}
Now, encludean_method(1.5745, 103.6200, 1.5748, 103.6195)
returns 0.0648375378577
value, which is possibly the distance you are searching for; measured in kilometers.
Here's the example and one more (based on this answer). And here is the service i used to verify that code.
Hope this will help you! =)