Nav data import fixed - thanks Kevin S!

This commit is contained in:
Nabeel Shahzad 2018-08-23 09:27:54 -05:00
parent e77488c66a
commit 543026da18

View File

@ -16,7 +16,7 @@ class NavdataImport extends Command
protected $description = ''; protected $description = '';
/** /**
* @return mixed|void * @return void
* @throws \League\Geotools\Exception\InvalidArgumentException * @throws \League\Geotools\Exception\InvalidArgumentException
*/ */
public function handle() public function handle()
@ -31,9 +31,10 @@ class NavdataImport extends Command
/** /**
* Read and parse in the navaid file * Read and parse in the navaid file
* @return void
* @throws \League\Geotools\Exception\InvalidArgumentException * @throws \League\Geotools\Exception\InvalidArgumentException
*/ */
public function read_wp_nav_aid() public function read_wp_nav_aid(): void
{ {
/* /*
* ....,....1....,....2....,....3....,....4....,....5....,....6.. * ....,....1....,....2....,....3....,....4....,....5....,....6..
@ -67,8 +68,7 @@ class NavdataImport extends Command
$file_path = storage_path('/navdata/WPNAVAID.txt'); $file_path = storage_path('/navdata/WPNAVAID.txt');
if (!file_exists($file_path)) { if (!file_exists($file_path)) {
$this->error('WPNAVAID.txt not found in storage/navdata'); $this->error('WPNAVAID.txt not found in storage/navdata');
return;
return false;
} }
$this->info('Importing navaids (WPNAVAID.txt) ...'); $this->info('Importing navaids (WPNAVAID.txt) ...');
@ -130,9 +130,9 @@ class NavdataImport extends Command
} }
/** /**
* * @return void
*/ */
public function read_wp_nav_fix() public function read_wp_nav_fix(): void
{ {
/* /*
* ....,....1....,....2....,...3....,....4....,.... * ....,....1....,....2....,...3....,....4....,....
@ -156,8 +156,7 @@ class NavdataImport extends Command
$file_path = storage_path('/navdata/WPNAVFIX.txt'); $file_path = storage_path('/navdata/WPNAVFIX.txt');
if (!file_exists($file_path)) { if (!file_exists($file_path)) {
$this->error('WPNAVFIX.txt not found in storage/navdata'); $this->error('WPNAVFIX.txt not found in storage/navdata');
return;
return false;
} }
$this->info('Importing navaids (WPNAVFIX.txt) ...'); $this->info('Importing navaids (WPNAVFIX.txt) ...');
@ -173,13 +172,9 @@ class NavdataImport extends Command
'lon' => trim(substr($line, 40, 11)), 'lon' => trim(substr($line, 40, 11)),
]; ];
switch ($navfix['type']) { Navdata::updateOrCreate([
default: 'id' => $navfix['id'], 'name' => $navfix['name']
$navfix['type'] = NavaidType::UNKNOWN; ], $navfix);
break;
}
Navdata::updateOrCreate(['id' => $navfix['id']], $navfix);
$imported++; $imported++;
if ($imported % 100 === 0) { if ($imported % 100 === 0) {