예제 #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->info('|-----------------------------|');
     $this->info('|---- PROCESS COORDINATES ----|');
     $this->info('|-----------------------------|');
     $coordinates = Coordinate::notProcessed()->get();
     if (!count($coordinates)) {
         $this->info('No coordinates found to be processed');
         exit;
     }
     $bar = $this->output->createProgressBar(count($coordinates));
     foreach ($coordinates as $coordinate) {
         $stop = DB::select(DB::raw('SELECT *, ROUND(6367 * ACOS(COS(RADIANS(lat)) * COS(RADIANS(:lat)) * COS(RADIANS(:lon) - RADIANS(lon)) + SIN(RADIANS(lat)) * SIN(RADIANS(:lat2))), 3) AS distance FROM stops ORDER BY distance ASC LIMIT 1'), ['lat' => $coordinate->lat, 'lon' => $coordinate->lon, 'lat2' => $coordinate->lat]);
         $coordinate->update(['stop_id' => $stop[0]->id, 'stop_distance' => $stop[0]->distance, 'processed' => 1]);
         $bar->advance();
     }
     $bar->finish();
 }
예제 #2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->info('|-----------------------------|');
     $this->info('|---- RESET COORDINATES ----|');
     $this->info('|-----------------------------|');
     $coordinates = Coordinate::all();
     if (!count($coordinates)) {
         $this->error('No coordinates found to be reset');
         exit;
     }
     $bar = $this->output->createProgressBar(count($coordinates));
     foreach ($coordinates as $coordinate) {
         $coordinate->update(['stop_id' => NULL, 'processed' => 0]);
         $bar->advance();
     }
     $bar->finish();
     $this->info('All coordinates have been reset');
 }