Jump to content

Calculate Distance Between 2 Latitude / Longtitude Values


johnsmith153

Recommended Posts

function distancepcodevalues ($l1, $o1, $l2, $o2)//calculates distance between two lat/long co-ordinates

{

    $l1 = deg2rad ($l1);

    $sinl1 = sin ($l1);

    $l2 = deg2rad ($l2);

    $o1 = deg2rad ($o1);

    $o2 = deg2rad ($o2);

               

    return (7926 - 26 * $sinl1) * asin (min (1, 0.707106781186548 * sqrt ((1 - (sin ($l2) * $sinl1) - cos ($l1) * cos ($l2) * cos ($o2 - $o1)))));

}

 

The above function does the job, but is there any way to do this in a MySQL database search (or do I have to dump all db records and then while through them to apply this function)?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.