コード例 #1
0
 public function new_item_info()
 {
     $origin = Airport::where('id', Input::get('origin_airport_id'))->first();
     $destination = Airport::where('id', Input::get('destination_airport_id'))->first();
     $distance = great_circle_distance($origin->lat, $origin->lng, $destination->lat, $destination->lng);
     return Response::json(array('flight_duration' => flight_duration(Input::get('speed'), $distance), 'origin_iata_code' => $origin->iata_code, 'distance' => $distance, 'destination_iata_code' => $destination->iata_code));
 }
コード例 #2
0
 public function show($origin_id, $destination_id)
 {
     $origin = $this->airportRepo->getById($origin_id);
     $destination = $this->airportRepo->getById($destination_id);
     $this->routeDemandUtility->setRoute($origin, $destination);
     $distance = great_circle_distance($origin->lat, $origin->lng, $destination->lat, $destination->lng);
     $flights['to'] = $this->timetableRepo->getByRoute($origin, $destination);
     $flights['return'] = $this->timetableRepo->getByRoute($destination, $origin);
     $data = array('origin' => $origin, 'destination' => $destination, 'year' => round($this->routeDemandUtility->getPaxPerYear()), 'week' => round($this->routeDemandUtility->getPaxPerWeek()), 'distance' => round($distance), 'flights' => $flights);
     return View::make('routes/show_ajax', $data);
 }
コード例 #3
0
 public function start()
 {
     $timetableItems = $this->timetableRepo->getTimetableItemsBeyondFlightBorad();
     $flights = array();
     foreach ($timetableItems as $item) {
         $newFlight = new \Flight();
         $departure_time = $this->makeDepartureTimestamp($item->departure_day_of_week, $item->departure_hour);
         $arrival_time = clone $departure_time;
         $arrival_time->addSeconds($item->flight_duration);
         $newFlight->fill(['timetable_id' => $item->id, 'airline_id' => $item->airline_id, 'airplane_id' => $item->airplane_id, 'origin_airport_id' => $item->origin_airport_id, 'destination_airport_id' => $item->destination_airport_id, 'departure_time' => $departure_time, 'arrival_time' => $arrival_time, 'distance' => great_circle_distance($item->origin->lat, $item->origin->lng, $item->destination->lat, $item->destination->lng), 'flight_number' => $item->flight_number]);
         array_push($flights, $newFlight);
     }
     $this->addedFlights = count($flights);
     $this->flightRepo->saveMany($flights);
 }
コード例 #4
0
 private function distanceFactor($origin, $destination)
 {
     $distance = great_circle_distance($origin->lat, $origin->lng, $destination->lat, $destination->lng);
     $factor = 0;
     if ($distance > 10) {
         $factor = 0.001;
     }
     if ($distance > 50) {
         $factor = 0.01;
     }
     if ($distance > 100) {
         $factor = 0.2;
     }
     if ($distance > 300) {
         $factor = 0.5;
     }
     if ($distance > 500) {
         $factor = 0.9;
     }
     if ($distance > 700) {
         $factor = 1;
     }
     if ($distance > 1600) {
         $factor = 0.9;
     }
     if ($distance > 2000) {
         $factor = 0.8;
     }
     if ($distance > 2500) {
         $factor = 0.5;
     }
     if ($distance > 3000) {
         $factor = 0.3;
     }
     if ($distance > 4000) {
         $factor = 0.2;
     }
     if ($distance > 6000) {
         $factor = 0.1;
     }
     if ($distance > 9000) {
         $factor = 0.05;
     }
     if ($origin->role == 5 and $destination->role == 5) {
         $factor += 1;
     }
     return $factor;
 }
コード例 #5
0
 /**
  * A basic functional test example.
  *
  * @return void
  */
 public function testDistance()
 {
     $this->assertEquals(1470, great_circle_distance('52.16583252', '20.96722221', '51.47083282', '-0.46055600'));
 }