PHP Classes

PHP Calculate Distance: Find the distance between points using Haversine

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 411 All time: 6,485 This week: 206Up
Version License PHP version Categories
calculate-distance 1Freely Distributable5PHP 5, Geography
Description 

Author

This class can find the distance between two points using the Haversine formula.

It takes the latitude and longitude coordinates of two points and calculates the great-circle distance between two points on the surface of a sphere using the Haversine equation formula.

The distance between the two points is returned in terms of miles.

Picture of Anthony Amolochitis
  Performance   Level  
Name: Anthony Amolochitis <contact>
Classes: 10 packages by
Country: United States United States

Recommendations

Example

<?php

require 'CalculateDistance.php';

$p1 = new GeoPoint(29.762930, -95.233678);
$p2 = new GeoPoint(29.768770, -95.188439);


echo
CalculateDistance::Process($p1, $p2);

echo
'</br>';

echo
CalculateDistance::Process($p2, $p1);


?>


  Files folder image Files (2)  
File Role Description
Plain text file CalculateDistance.php Class Calculate Haversine Distance
Plain text file Example.php Example Usage Example

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:411
This week:0
All time:6,485
This week:206Up