예제 #1
0
파일: DistanceTest.php 프로젝트: jlaso/gps
 /**
  * source: www.distace.to/Origin/Destination
  *
  * Paris/Madrid  1.052,69 km   #1 Paris (48.856667,2.350987)  #2 Madrid (40.416691,-3.700345)
  */
 function testParisMadridDistance()
 {
     $distance = Tools::distance(48.856667, 2.350987, 40.416691, -3.700345);
     // Let assume the result it's okay if the error of calculated distance is less than 1/1000  (1km)
     $this->assertLessThan(1.052, abs(1052.69 - $distance));
     // now use the indirect method to calculate distance in the same conditions
     $madrid = new Point(40.416691, -3.700345);
     $paris = new Point(48.856667, 2.350987);
     $this->assertLessThan(1.052, abs(1052.69 - $madrid->distanceTo($paris)));
 }
예제 #2
0
 function testKilometersMilesConversion()
 {
     $this->assertEquals(0.621, Tools::toMiles(1));
 }