상속: extends CalculatorAbstract
예제 #1
0
 public function testCalculate()
 {
     $Vincenty = new C\Vincenty();
     $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));
     $metres = $Vincenty->calculate($point1, $point2);
     $this->assertEquals(7307755.5727136, $metres, '', 0.2);
 }
 /**
  * @dataProvider vincentyDataProvider 
  */
 public function testVincentyCalculate($lat1, $long1, $lat2, $long2, $expected_result)
 {
     $Vincenty = new C\Vincenty($this->getObject());
     $point1 = new N\LatLong(new N\Coordinate($lat1), new N\Coordinate($long1));
     $point2 = new N\LatLong(new N\Coordinate($lat2), new N\Coordinate($long2));
     $metres = $Vincenty->calculate($point1, $point2);
     $this->assertEquals($expected_result, $metres, '', 0.2);
 }
예제 #3
0
 /**
  * Calculate the distance between two points. Defaults to Vincenty if
  * no calculator is supplied. If no unit converter is supplied then the
  * formula will return a value in metres.
  * @param D\Calculator\CalculatorInterface $calculator
  * @param D\Calculator\ConverterAbstract $unit_converter
  * @return float
  */
 public function get(D\Calculator\CalculatorAbstract $calculator = null, D\Converter\ConverterAbstract $unit_converter = null)
 {
     if (is_null($calculator)) {
         $calculator = new D\Calculator\Vincenty();
     }
     $distance = $calculator->calculate($this->point1, $this->point2);
     if (!is_null($unit_converter)) {
         $distance = $unit_converter->convert($distance);
     }
     return $distance;
 }
예제 #4
0
 /**
  * @expectedException PHPUnit_Framework_Error
  */
 public function testFailedCalculator()
 {
     $Vincenty = new C\Vincenty();
     $Vincenty->calculate(new stdClass(), new stdClass());
 }