php a to b latlong dstance

Solutions on MaxInterview for php a to b latlong dstance by the best coders in the world

showing results for - "php a to b latlong dstance"
Lia
31 Nov 2018
1<?php
2
3/*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
4/*::                                                                         :*/
5/*::  This routine calculates the distance between two points (given the     :*/
6/*::  latitude/longitude of those points). It is being used to calculate     :*/
7/*::  the distance between two locations using GeoDataSource(TM) Products    :*/
8/*::                                                                         :*/
9/*::  Definitions:                                                           :*/
10/*::    South latitudes are negative, east longitudes are positive           :*/
11/*::                                                                         :*/
12/*::  Passed to function:                                                    :*/
13/*::    lat1, lon1 = Latitude and Longitude of point 1 (in decimal degrees)  :*/
14/*::    lat2, lon2 = Latitude and Longitude of point 2 (in decimal degrees)  :*/
15/*::    unit = the unit you desire for results                               :*/
16/*::           where: 'M' is statute miles (default)                         :*/
17/*::                  'K' is kilometers                                      :*/
18/*::                  'N' is nautical miles                                  :*/
19/*::  Worldwide cities and other features databases with latitude longitude  :*/
20/*::  are available at https://www.geodatasource.com                          :*/
21/*::                                                                         :*/
22/*::  For enquiries, please contact sales@geodatasource.com                  :*/
23/*::                                                                         :*/
24/*::  Official Web site: https://www.geodatasource.com                        :*/
25/*::                                                                         :*/
26/*::         GeoDataSource.com (C) All Rights Reserved 2018                  :*/
27/*::                                                                         :*/
28/*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
29function distance($lat1, $lon1, $lat2, $lon2, $unit) {
30  if (($lat1 == $lat2) && ($lon1 == $lon2)) {
31    return 0;
32  }
33  else {
34    $theta = $lon1 - $lon2;
35    $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +  cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
36    $dist = acos($dist);
37    $dist = rad2deg($dist);
38    $miles = $dist * 60 * 1.1515;
39    $unit = strtoupper($unit);
40
41    if ($unit == "K") {
42      return ($miles * 1.609344);
43    } else if ($unit == "N") {
44      return ($miles * 0.8684);
45    } else {
46      return $miles;
47    }
48  }
49}
50
51echo distance(32.9697, -96.80322, 29.46786, -98.53506, "M") . " Miles<br>";
52echo distance(32.9697, -96.80322, 29.46786, -98.53506, "K") . " Kilometers<br>";
53echo distance(32.9697, -96.80322, 29.46786, -98.53506, "N") . " Nautical Miles<br>";
54
55?>
queries leading to this page
find km between two places phpcalculate distance between more than two coordinates in phpcalculate distance and time between two locations in phpphp longitcompare get distance with coordinates phpget distance between two time in phpcalculate distance between two coordinates in phpcalculate distance between two gps coordinates formula phpcalculate distance between two cities using phpcalculate distance betweemn 2 points phpphp get distance between two lat longpedometer long lat php php difference betwwen coordenatesget km distance lat and long phpdistance between two locations in phplatitude 2flongitude distance calculator in phpphp get teh distance between 2 coordenates lat lonphp longitude 2b kmphp latitude and longitudehow to find out distance between two places phpphp coordonate distancecalculate distance between two coordinates phphow to calculate the distance between two coordinates of two different places in phpcalculate km distance phphow to calculate distance by longitude and latitude phpcalculate distance between two points in phpcalculate time from kilometer in phpdistance between two points by road in phphow to reduce lat long length in phpcalculate timing and distance between latitude and longitude in phpcalculate no of time between two lat long in phpget distance from points phpphp ditance between to cordinatecalculate radius latitude longitude phpget distance kilometers in phpphp calculate distance between coordinatesfectch near 10 km distance lat and long in phpcalculate arrival time between two latitude and longtitude in phpphp get distance between two coordinatescalculate distance from langitute and latitude phpget radius from latitude and longitude phpphp a to b latlong dstancephp distance between two coordinateslaravel calculate distance between two coordinatescalculate distance between two points latitude longitude phpcalculate distance by latitude and longitude phpphp calculate distance in miles between two gps coordinateshow to get distance between two lat long in php 1 km 2 km etc php calulate distance between two locationsubtract two longitude in php give alphabetphp lat long distance calculatorphp calculate distance between 2 pointsphp function for calculating distance bewteen 2 locationsphp calculate distance between more than two coordinatesfind distance between two points in phpcalculate timing based on distance between latitude and longitude in phpcalculates the distance between two points within 50 km in phpcalculate distance and timing between latitude and longitude in phphow to calculate distance between multiple latitude and longitude in phpfind the exact distance between two locations in phpcoordinates distance finder in phpcalculate arrival time between two latlong in phpfind distance between two coordinates phpget distance between two coordinates in 3bphpphp distance between two lat longpoint to address phphow to check the distance between two sql dates in phpcalculatedistance phpdistance between two points in phpphp use gps coordinates for distance betweencalculate distance between three coordinates in phpphp distance between two coordinatesphp script calculate distance between cities freephp calculate distance between two coordinatesget distance between two lat long phpcalculate distance of postal code longitude and latitude phpfind all latitude and longitude to given latitude and longitude within one 1 km in phpfind all latitude and longitude to given point and distanec and timing in phpcalculate distance between two coordinates in km phpdifference between two latitude and longitude in km phpformula to find distance between two coordinates phphow to calculate the distance between two points using phpphp coordinate distanceget distance between two points phpgetdistance phpphp calculate trip distance given pointssubtract two longitude in phphow to calculate distance between two places in phpcalculate distance from latitude and longitude phpphp calculate distance between multiple coordinatesget distance between two coordinates phphow to calculate distance between two latitude and longitude in phpget distance lat and long phpcalculate distance between two latitude longitude points in phpphp check lat lon distancedistance between points by geolocation phpphp a to b latlong dstance