diff --git a/app/Database/migrations/2017_12_20_004147_create_navdata_tables.php b/app/Database/migrations/2017_12_20_004147_create_navdata_tables.php index 47be7a08..309d973c 100644 --- a/app/Database/migrations/2017_12_20_004147_create_navdata_tables.php +++ b/app/Database/migrations/2017_12_20_004147_create_navdata_tables.php @@ -25,6 +25,7 @@ class CreateNavdataTables extends Migration $table->float('lon', 7, 4)->default(0.0); $table->string('freq', 7)->nullable(); + $table->primary(['id', 'name']); $table->index('id'); $table->index('name'); }); diff --git a/app/Database/migrations/2017_12_20_005147_create_acars_tables.php b/app/Database/migrations/2017_12_20_005147_create_acars_tables.php index 9f2b1579..7dd87932 100644 --- a/app/Database/migrations/2017_12_20_005147_create_acars_tables.php +++ b/app/Database/migrations/2017_12_20_005147_create_acars_tables.php @@ -13,13 +13,9 @@ class CreateAcarsTables extends Migration */ public function up() { - /** - * See for defs, modify/update based on this - * https://github.com/skiselkov/openfmc/blob/master/airac.h - */ Schema::create('acars', function (Blueprint $table) { $table->bigIncrements('id'); - $table->string('acars_id', 12); + $table->string('pirep_id', 12); $table->string('name', 10)->nullable(); $table->float('lat', 7, 4)->default(0.0); $table->float('lon', 7, 4)->default(0.0); @@ -29,8 +25,8 @@ class CreateAcarsTables extends Migration # polymorphic relation columns. # parent_type can be flight, pirep or acars # once - $table->unsignedBigInteger('parent_id'); - $table->string('parent_type'); + #$table->unsignedBigInteger('parent_id'); + #$table->string('parent_type'); $table->timestamps(); diff --git a/app/Database/seeds/dev.yml b/app/Database/seeds/dev.yml index 89a70729..73b4f429 100644 --- a/app/Database/seeds/dev.yml +++ b/app/Database/seeds/dev.yml @@ -193,7 +193,7 @@ flights: flight_number: 100 dpt_airport_id: KAUS arr_airport_id: KJFK - route: KAUS KJFK + route: KAUS SID TNV J87 IAH J2 LCH J22 MEI J239 ATL J52 AJFEB J14 BYJAC Q60 JAXSN J14 COLIN J61 HUBBS J55 SIE STAR KJFK dpt_time: 6PM CST arr_time: 11PM EST - id: flightid_2 diff --git a/app/Http/Controllers/Frontend/FlightController.php b/app/Http/Controllers/Frontend/FlightController.php index 278e5992..eb172412 100644 --- a/app/Http/Controllers/Frontend/FlightController.php +++ b/app/Http/Controllers/Frontend/FlightController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Frontend; use App\Repositories\AirlineRepository; use App\Repositories\AirportRepository; +use App\Services\GeoService; use Log; use Illuminate\Http\Request; @@ -19,16 +20,21 @@ use Prettus\Repository\Exceptions\RepositoryException; class FlightController extends AppBaseController { - private $airlineRepo, $airportRepo, $flightRepo; + private $airlineRepo, + $airportRepo, + $flightRepo, + $geoSvc; public function __construct( AirlineRepository $airlineRepo, AirportRepository $airportRepo, - FlightRepository $flightRepo + FlightRepository $flightRepo, + GeoService $geoSvc ) { $this->airlineRepo = $airlineRepo; $this->airportRepo = $airportRepo; $this->flightRepo = $flightRepo; + $this->geoSvc = $geoSvc; } public function index(Request $request) @@ -110,13 +116,22 @@ class FlightController extends AppBaseController } } - public function update() - { - - } - + /** + * Show the flight information page + */ public function show($id) { + $flight = $this->flightRepo->find($id); + if (empty($flight)) { + Flash::error('Flight not found!'); + return redirect(route('frontend.dashboard.index')); + } + $coords = $this->geoSvc->flightGeoJson($flight); + + return $this->view('flights.show', [ + 'flight' => $flight, + 'coords' => $coords, + ]); } } diff --git a/app/Http/Controllers/Frontend/PirepController.php b/app/Http/Controllers/Frontend/PirepController.php index c0b13168..957180fb 100644 --- a/app/Http/Controllers/Frontend/PirepController.php +++ b/app/Http/Controllers/Frontend/PirepController.php @@ -120,7 +120,7 @@ class PirepController extends Controller return redirect(route('frontend.pirep.index')); } - $coords = $this->geoSvc->getRouteCoordsGeoJSON($pirep); + $coords = $this->geoSvc->pirepGeoJson($pirep); return $this->view('pireps.show', [ 'pirep' => $pirep, diff --git a/app/Models/Airport.php b/app/Models/Airport.php index 0d38bc0b..56348953 100644 --- a/app/Models/Airport.php +++ b/app/Models/Airport.php @@ -28,7 +28,8 @@ class Airport extends Model ]; protected $casts = [ - + 'lat' => 'float', + 'lon' => 'float', ]; /** diff --git a/app/Models/Flight.php b/app/Models/Flight.php index c0e7742b..d503ba3c 100644 --- a/app/Models/Flight.php +++ b/app/Models/Flight.php @@ -61,11 +61,15 @@ class Flight extends Model /** * Get the flight ident, e.,g JBU1900 - * @param $value */ public function getIdentAttribute() { + $flight_id = $this->airline->code; + $flight_id .= $this->flight_number; + # TODO: Add in code/leg if set + + return $flight_id; } /** diff --git a/app/Models/Navdata.php b/app/Models/Navdata.php index 4aa3faf3..77b287ae 100644 --- a/app/Models/Navdata.php +++ b/app/Models/Navdata.php @@ -20,7 +20,9 @@ class Navdata extends Model ]; public $casts = [ - 'id' => 'string', - 'type' => 'integer', + 'id' => 'string', + 'type' => 'integer', + 'lat' => 'float', + 'lon' => 'float', ]; } diff --git a/app/Repositories/NavdataRepository.php b/app/Repositories/NavdataRepository.php new file mode 100644 index 00000000..0c8e8afb --- /dev/null +++ b/app/Repositories/NavdataRepository.php @@ -0,0 +1,20 @@ +navRepo = $navRepo; + } + + + public function getClosestCoords($coordStart, $all_coords, $measure='flat') + { + $distance = []; + $geotools = new Geotools(); + $start = new Coordinate($coordStart); + + foreach($all_coords as $coords) { + $coord = new Coordinate($coords); + $dist = $geotools->distance()->setFrom($start)->setTo($coord); + + if($measure === 'flat') { + $distance[] = $dist->flat(); + } elseif ($measure === 'greatcircle') { + $distance[] = $dist->greatCircle(); + } + } + + $distance = collect($distance); + $min = $distance->min(); + return $all_coords[ $distance->search($min, true) ]; + } + /** - * Return all of the coordinates, start to finish - * Returned in the GeoJSON format - * https://tools.ietf.org/html/rfc7946 - * - * TODO: Save this data: - * Once a PIREP is accepted, save this returned structure as a - * JSON-encoded string into the raw_data field of the PIREP row - * - * @param \App\Models\Pirep|\App\Models\Flight $model + * @param $dep_icao string ICAO to ignore + * @param $arr_icao string ICAO to ignore + * @param $start_coords array [x, y] + * @param $route string Textual route * @return array */ - public function getRouteCoordsGeoJSON($model): array + public function getCoordsFromRoute($dep_icao, $arr_icao, $start_coords, $route) { - # NOTE!! GeoJSON takes coords in [lon, lat] format!! - $line = new LineString([ - [$model->dpt_airport->lon, $model->dpt_airport->lat], - [$model->arr_airport->lon, $model->arr_airport->lat], + $coords = []; + $split_route = explode(' ', $route); + + $skip = [ + $dep_icao, + $arr_icao, + 'SID', + 'STAR' + ]; + + foreach ($split_route as $route_point) { + + $route_point = trim($route_point); + + if (\in_array($route_point, $skip, true)) { + continue; + } + + try { + Log::info('Looking for ' . $route_point); + + $points = $this->navRepo->findWhere(['id' => $route_point]); + $size = \count($points); + + if($size === 0) { + continue; + } else if($size === 1) { + + $point = $points[0]; + + Log::info('name: ' . $point->id . ' - ' . $point->lat . 'x' . $point->lon); + + $coords[] = [ + $point->lat, + $point->lon, + ]; + + continue; + } + + # Find the point with the shortest distance + Log::info('found ' . $size . ' for '. $route_point); + + $potential_coords = []; + foreach($points as $point) { + #Log::debug('name: ' . $point->id . ' - '.$point->lat .'x'.$point->lon); + $potential_coords[] = [$point->lat, $point->lon]; + } + + # Get the start point and then reverse the lat/lon reference + # If the first point happens to have multiple possibilities, use + # the starting point that was passed in + if(\count($coords) > 0) { + $start_point = $coords[\count($coords) - 1]; + $start_point = [$start_point[0], $start_point[1]]; + } else { + $start_point = $start_coords; + } + + $coords[] = $this->getClosestCoords($start_point, $potential_coords); + + } catch (\Exception $e) { + Log::error($e); + continue; + } + } + + return $coords; + } + + /** + * Return a FeatureCollection GeoJSON object + * @param Flight $flight + * @return array + */ + public function flightGeoJson(Flight $flight): array + { + $coords = []; + $coords[] = [$flight->dpt_airport->lon, $flight->dpt_airport->lat]; + + // TODO: Add markers for the start/end airports + // TODO: Read from the ACARS data table + if($flight->route) { + $route_coords =$this->getCoordsFromRoute( + $flight->dpt_airport->icao, + $flight->arr_airport->icao, + [$flight->dpt_airport->lat, $flight->dpt_airport->lon], + $flight->route); + + // lat, lon needs to be reversed for GeoJSON + foreach($route_coords as $rc) { + $coords[] = [$rc[1], $rc[0]]; + } + } + + $coords[] = [$flight->arr_airport->lon, $flight->arr_airport->lat]; + + $line = new LineString($coords); + + $features = new FeatureCollection([ + new Feature($line, [], 1) ]); + return [ + 'features' => $features, + ]; + } + + /** + * Return a GeoJSON FeatureCollection for a PIREP + * @param Pirep $pirep + * @return array + */ + public function pirepGeoJson(Pirep $pirep) + { + $coords = []; + $coords[] = [$pirep->dpt_airport->lon, $pirep->dpt_airport->lat]; + // TODO: Add markers for the start/end airports // TODO: Read from the ACARS data table - $feature = new Feature($line, [], 1); - $features = new FeatureCollection([$feature]); + $coords[] = [$pirep->arr_airport->lon, $pirep->arr_airport->lat]; + + $line = new LineString($coords); + + $features = new FeatureCollection([ + new Feature($line, [], 1) + ]); return [ 'features' => $features, - //'center' => $center, ]; } diff --git a/composer.json b/composer.json index d20af32c..16ba8b4a 100755 --- a/composer.json +++ b/composer.json @@ -46,7 +46,8 @@ "tivie/php-os-detector": "1.1.0", "santigarcor/laratrust": "5.0.3", "pragmarx/version": "0.2.2", - "nabeel/vacentral": "dev-master" + "nabeel/vacentral": "dev-master", + "jmikola/geojson": "1.0.2" }, "require-dev": { "phpunit/phpunit": "6.4.0", diff --git a/composer.lock b/composer.lock index 8dc2b0b6..17fb4923 100644 --- a/composer.lock +++ b/composer.lock @@ -427,7 +427,7 @@ "Doctrine\\DBAL\\": "lib/" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -750,7 +750,7 @@ "Egulias\\EmailValidator\\": "EmailValidator" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -796,7 +796,7 @@ "Parsedown": "" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -856,7 +856,7 @@ "GuzzleHttp\\": "src/" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -914,7 +914,7 @@ "src/functions_include.php" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -969,7 +969,7 @@ "src/functions_include.php" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -1031,7 +1031,7 @@ "Hashids\\": "src/" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -1138,7 +1138,7 @@ "InfyOm\\AdminLTETemplates\\": "src/" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -1157,7 +1157,7 @@ "laravel", "templates" ], - "time": "2017-11-25 04:43:54" + "time": "2017-11-25T04:43:54+00:00" }, { "name": "infyomlabs/laravel-generator", @@ -1199,7 +1199,7 @@ "src/helpers.php" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -1223,7 +1223,7 @@ "test", "view" ], - "time": "2017-11-25 05:18:22" + "time": "2017-11-25T05:18:22+00:00" }, { "name": "jackiedo/timezonelist", @@ -1249,7 +1249,7 @@ "Jackiedo\\Timezonelist\\": "src/Jackiedo/Timezonelist" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -1360,7 +1360,7 @@ "stubs/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -1406,7 +1406,7 @@ "Traitor\\": "src/" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -1594,7 +1594,7 @@ "Illuminate\\": "src/Illuminate/" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -2017,7 +2017,7 @@ } ], "description": "Bloom filter implementation", - "time": "2017-11-30 17:51:14" + "time": "2017-11-30T17:51:14+00:00" }, { "name": "monolog/monolog", @@ -2123,7 +2123,7 @@ "Cron\\": "src/Cron/" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -2172,7 +2172,7 @@ "src/DeepCopy/deep_copy.php" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -2217,11 +2217,11 @@ "VaCentral\\": "src/" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "time": "2017-12-08 04:00:06" + "time": "2017-12-08T04:00:06+00:00" }, { "name": "nesbot/carbon", @@ -2311,7 +2311,7 @@ "PhpParser\\": "lib/PhpParser" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], @@ -2744,7 +2744,7 @@ ] } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -2897,7 +2897,7 @@ "Prophecy\\": "src/" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -3015,7 +3015,7 @@ "src/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], @@ -3156,7 +3156,7 @@ "src/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], @@ -3237,7 +3237,7 @@ "src/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], @@ -3358,7 +3358,7 @@ "PragmaRX\\Version\\Tests\\": "tests/" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -3379,16 +3379,16 @@ }, { "name": "pragmarx/yaml", - "version": "v0.1.4", + "version": "v0.1.5", "source": { "type": "git", "url": "https://github.com/antonioribeiro/yaml.git", - "reference": "b510623eb5008cc468e00a31259a3c860dd2b267" + "reference": "cc27a84e8d9760d82014596ef155c34c816c4ea5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/antonioribeiro/yaml/zipball/b510623eb5008cc468e00a31259a3c860dd2b267", - "reference": "b510623eb5008cc468e00a31259a3c860dd2b267", + "url": "https://api.github.com/repos/antonioribeiro/yaml/zipball/cc27a84e8d9760d82014596ef155c34c816c4ea5", + "reference": "cc27a84e8d9760d82014596ef155c34c816c4ea5", "shasum": "" }, "require": { @@ -3418,7 +3418,7 @@ "PragmaRX\\Yaml\\Tests\\": "tests/" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -3435,7 +3435,7 @@ "laravel", "yaml" ], - "time": "2017-12-05T20:32:21+00:00" + "time": "2017-12-19T02:25:46+00:00" }, { "name": "prettus/l5-repository", @@ -3481,7 +3481,7 @@ "Prettus\\Repository\\": "src/Prettus/Repository/" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -3950,7 +3950,7 @@ "Laratrust\\": "src/" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -4153,7 +4153,7 @@ "src/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], @@ -4728,7 +4728,7 @@ "src/helpers.php" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -4911,7 +4911,7 @@ "/Tests/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -4960,7 +4960,7 @@ "/Tests/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -5020,7 +5020,7 @@ "/Tests/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -5076,7 +5076,7 @@ "/Tests/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -5139,7 +5139,7 @@ "/Tests/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -5188,7 +5188,7 @@ "/Tests/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -5242,7 +5242,7 @@ "/Tests/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -5330,7 +5330,7 @@ "/Tests/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -5379,7 +5379,7 @@ "/Tests/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -5531,7 +5531,7 @@ "bootstrap.php" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -5588,7 +5588,7 @@ "bootstrap.php" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -5647,7 +5647,7 @@ "Resources/stubs" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -5699,7 +5699,7 @@ "Symfony\\Polyfill\\Util\\": "" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -5754,7 +5754,7 @@ "/Tests/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -5811,7 +5811,7 @@ "/Tests/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -5894,7 +5894,7 @@ "/Tests/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -5978,7 +5978,7 @@ "/Tests/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -6046,7 +6046,7 @@ "/Tests/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -6111,7 +6111,7 @@ "/Tests/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -6173,7 +6173,7 @@ "/Tests/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -6304,7 +6304,7 @@ "Tivie\\OS\\": "src/" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "APACHE 2.0" ], @@ -6525,7 +6525,7 @@ "Webpatser\\Uuid": "src/" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -6654,7 +6654,7 @@ "src/helper.php" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -6711,7 +6711,7 @@ "Zend\\Diactoros\\": "src/" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-2-Clause" ], @@ -6937,7 +6937,7 @@ "Whoops\\": "src/Whoops/" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -7279,7 +7279,7 @@ "/Tests/" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], diff --git a/public/assets/system/js/system.js b/public/assets/system/js/system.js index 28eb487b..998bde24 100644 --- a/public/assets/system/js/system.js +++ b/public/assets/system/js/system.js @@ -74,6 +74,7 @@ const phpvms= (function() { render_elem: 'map', overlay_elem: '', zoom: 5, + geodesic: true, layers: [], set_marker: false, }); @@ -82,26 +83,27 @@ const phpvms= (function() { let map = draw_base_map(opts); - var geodesicLayer = L.geodesic([], { - weight: 7, - opacity: 0.5, - color: '#ff33ee', - steps: 50, - wrap: false, - }).addTo(map); + if(opts.geodesic) { + let geodesicLayer = L.geodesic([], { + weight: 7, + opacity: 0.5, + color: '#ff33ee', + steps: 50, + wrap: false, + }).addTo(map); - geodesicLayer.geoJson(opts.features) - map.fitBounds(geodesicLayer.getBounds()); + geodesicLayer.geoJson(opts.features) + map.fitBounds(geodesicLayer.getBounds()); + } else { + let route = L.geoJSON(opts.features, { + "color": "#ff7800", + "weight": 5, + "opacity": 0.65 + }); - /*let route = L.geoJSON(opts.features, { - "color": "#ff7800", - "weight": 5, - "opacity": 0.65 - });*/ - - //map.setView(opts.center, opts.zoom); - //map.fitBounds(route.getBounds()); - //route.addTo(map) + route.addTo(map); + map.fitBounds(route.getBounds()); + } }, /** diff --git a/resources/views/layouts/default/flights/map.blade.php b/resources/views/layouts/default/flights/map.blade.php new file mode 100644 index 00000000..2e2b5772 --- /dev/null +++ b/resources/views/layouts/default/flights/map.blade.php @@ -0,0 +1,18 @@ +
- {!! $flight->dpt_airport->icao !!} - {!! $flight->dpt_airport->name !!} -
- {!! $flight->arr_airport->icao !!} - {!! $flight->arr_airport->name !!} -
-{!! $flight->alt_airport->icao !!}
-{!! $flight->route !!}
-{!! $flight->notes !!}
-{!! $flight->active !!}
-