Commit 21c8ce93 authored by Hasith Yoman's avatar Hasith Yoman

calculate lingitude latitude distance

parent 5af6b0d9
......@@ -31,6 +31,16 @@ class StationController extends Controller
}
return response()->json(['respond'=>$respond,'count'=>$queue]);
}
// calculate distance
public function calculateDistance($lat1, $lon1, $lat2, $lon2) {
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$km = $miles * 1.609344;
return round($km,2);
}
// This function for create a new Station with user
public function create_station(Request $req){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment