/**
  * @expectedException PHPUnit_Framework_Error
  */
 public function testFailedGet()
 {
     $point1 = new N\LatLong(new N\Coordinate(80.90000000000001), new N\Coordinate(20.1));
     $point2 = new N\LatLong(new N\Coordinate(20.1), new N\Coordinate(80.90000000000001));
     $Distance = new N\Distance($point1, $point2);
     $metres = $Distance->get(new stdClass(), new stdClass());
 }
示例#2
0
 /**
  * @dataProvider coordValidProvider 
  */
 public function testConstructorWithProvider($coord)
 {
     $point1 = new N\LatLong(new N\Coordinate($coord), new N\Coordinate($coord - 15));
     $point2 = new N\LatLong(new N\Coordinate($coord - 5), new N\Coordinate($coord));
     $Distance = new N\Distance($point1, $point2);
     $metres = $Distance->get();
     $this->assertGreaterThan(20, $metres);
 }
示例#3
0
/**
 * Calculate distance between two points
 *
 * @param float $lat1
 * @param float $long1
 * @param float $lat2
 * @param float $long2
 * @return float	Distance in meters
 */
function get_distance($lat1, $long1, $lat2, $long2, $unit = 'metres')
{
    $point1 = new LatLong(new Coordinate($lat1), new Coordinate($long1));
    $point2 = new LatLong(new Coordinate($lat2), new Coordinate($long2));
    $distance = new Distance($point1, $point2);
    return $distance->get(new GreatCircle());
}