/**
  * Get distance between to positions in kilometers
  *
  * Code from http://www.corecoding.com/getfile.php?file=25
  */
 static function get_distance(midgardmvc_helper_location_spot $from, midgardmvc_helper_location_spot $to, $unit = 'K', $round = true)
 {
     return $from->distance_to($to, $unit, $round);
 }
 public function test_distance()
 {
     // Helsinki-Malmi airport (EFHF)
     $efhf = new midgardmvc_helper_location_spot(60.254558, 25.042828);
     // Helsinki-Vantaa airport (EFHK)
     $efhk = new midgardmvc_helper_location_spot(60.317222, 24.963333);
     // Midgard airport (FYMG)
     $fymg = new midgardmvc_helper_location_spot(-22.083332, 17.366667);
     // There are 8.2 kilometers between the airports
     $distance = $efhf->distance_to($efhk);
     $this->assertEquals($distance, 8.199999999999999);
     // 8.2 kilometers is approximately 4.4 nautical miles
     $distance_nautical = $efhf->distance_to($efhk, 'N');
     $this->assertEquals($distance_nautical, 4.4);
     // There are 9181.6 kilometers from Helsinki to Midgard
     $distance_large = $efhf->distance_to($fymg);
     $this->assertEquals($distance_large, 9181.6);
     $distance_large = $efhf->distance_to($fymg, 'N');
     $this->assertEquals($distance_large, 4954.4);
 }