Disable AI Layer

This commit is contained in:
portree_kid 2020-08-25 21:48:48 +02:00
parent 217d3d7a8e
commit 4d5a4f4ff7
6 changed files with 90 additions and 36 deletions

View File

@ -10,7 +10,9 @@
props: [], props: [],
mounted () { mounted () {
this.aiLayer = aiLayer({url: this.$store.state.Settings.settings.phi_url}) this.aiLayer = aiLayer({url: this.$store.state.Settings.settings.phi_url})
if(this.aiLayer) {
this.aiLayer.addTo(this.$parent.mapObject) this.aiLayer.addTo(this.$parent.mapObject)
}
}, },
data () { data () {
return { return {

View File

@ -31,12 +31,19 @@
// Callback for add // Callback for add
readPavement(this.$store.state.Settings.settings.flightgearDirectory_apt, icao, this.read) readPavement(this.$store.state.Settings.settings.flightgearDirectory_apt, icao, this.read)
}, },
// Callback called when pavement read
read (layer) { read (layer) {
this.pavement = layer this.pavement = layer
if (this.pavement) { if (this.pavement) {
this.pavement.on('add', this.onAdd) this.pavement.on('add', this.onAdd)
this.pavement.addTo(this.$parent.mapObject) this.pavement.addTo(this.$parent.mapObject)
this.visible = true this.visible = true
} else {
this.$message({
type: 'Error',
showClose: true,
message: `Couldn't load pavement from ${this.$store.state.Settings.settings.flightgearDirectory_apt}`
})
} }
}, },
onAdd () { onAdd () {

View File

@ -17,23 +17,31 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="22" class="label">Flightgear Directory</el-col> <el-col :span="22" class="label">Flightgear Data Directory</el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="20" class="file-label">{{ flightgear_directory }}</el-col> <el-col :span="20" class="file-label">{{ flightgear_directory }}</el-col>
<el-col :span="4"> <el-col :span="4">
<directory-select @input="flightgearDirectorySelect"></directory-select> <el-popover
placement="top-start"
title="E-Mail"
width="200"
trigger="hover"
content="The FGDATA directory."
>
<directory-select @input="flightgearDirectorySelect" slot="reference"></directory-select>
</el-popover>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="7" class="label">Traffic Directory</el-col> <el-col :span="7" class="label">Traffic Directory</el-col>
<el-col :span="15" class="file-label">{{ Traffic_directory }}</el-col> <el-col :span="15" v-bind:class="{ invalid: !Traffic_directory_ok}">{{ Traffic_directory }}</el-col>
<el-col :span="2"> <el-col :span="2">
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="7" class="label">APT File</el-col> <el-col :span="7" class="label">APT File</el-col>
<el-col :span="15" class="file-label">{{ apt_file }}</el-col> <el-col :span="15" v-bind:class="{invalid: !apt_file_ok}" >{{ apt_file }}</el-col>
<el-col :span="2"> <el-col :span="2">
</el-col> </el-col>
</el-row> </el-row>
@ -123,7 +131,7 @@
import DirectorySelect from './DirectorySelect' import DirectorySelect from './DirectorySelect'
const { ipcRenderer } = require('electron') const { ipcRenderer } = require('electron')
const fs = require('fs')
export default { export default {
name: 'settings-panel', name: 'settings-panel',
components: { DirectorySelect, FileSelect }, components: { DirectorySelect, FileSelect },
@ -132,7 +140,7 @@
}, },
data () { data () {
return { return { ok: true
} }
}, },
methods: { methods: {
@ -192,9 +200,25 @@
Traffic_directory: function () { Traffic_directory: function () {
return this.$store.state.Settings.settings.flightgearDirectory_traffic return this.$store.state.Settings.settings.flightgearDirectory_traffic
}, },
Traffic_directory_ok: function () {
try {
fs.accessSync(this.$store.state.Settings.settings.flightgearDirectory_traffic)
return true
} catch (error) {
return false
}
},
apt_file: function () { apt_file: function () {
return this.$store.state.Settings.settings.flightgearDirectory_apt return this.$store.state.Settings.settings.flightgearDirectory_apt
}, },
apt_file_ok: function () {
try {
fs.accessSync(this.$store.state.Settings.settings.flightgearDirectory_apt)
return true
} catch (error) {
return false
}
},
airports_directory: function () { airports_directory: function () {
return this.$store.state.Settings.settings.airportsDirectory return this.$store.state.Settings.settings.airportsDirectory
}, },
@ -229,4 +253,9 @@
.file-label { .file-label {
padding: 10px; padding: 10px;
} }
.invalid {
padding: 10px;
background-color: red;
}
</style> </style>

View File

@ -12,7 +12,6 @@ You should have received a copy of the GNU General Public License along with FG
/* eslint-disable */ /* eslint-disable */
const lineReader = require('readline'); const lineReader = require('readline');
const zlib = require('zlib'); const zlib = require('zlib');
// const geodesy = require('geodesy');
const LatLonEllipsoidal = require('geodesy/latlon-ellipsoidal-vincenty.js').default; const LatLonEllipsoidal = require('geodesy/latlon-ellipsoidal-vincenty.js').default;
const fs = require('fs'); const fs = require('fs');
@ -269,7 +268,7 @@ function createLineString(currentFeature, layerGroup) {
} }
} }
module.exports.readPavement = function (f, icao, cb) { module.exports.readPavement = function (f, icao, callback) {
console.log(f); console.log(f);
var pavementLayerGroup = L.layerGroup(); var pavementLayerGroup = L.layerGroup();
var currentFeature; var currentFeature;
@ -278,6 +277,7 @@ module.exports.readPavement = function (f, icao, cb) {
if (!fs.existsSync(f)) { if (!fs.existsSync(f)) {
store.default.dispatch('setPavementLoaded', true); store.default.dispatch('setPavementLoaded', true);
callback();
return; return;
} }
try { try {
@ -307,14 +307,16 @@ module.exports.readPavement = function (f, icao, cb) {
store.default.dispatch('setPavementLoaded', true); store.default.dispatch('setPavementLoaded', true);
console.error(err); console.error(err);
lr.close(); lr.close();
callback();
}).on('close', function () { }).on('close', function () {
store.default.dispatch('setPavementLoaded', true); store.default.dispatch('setPavementLoaded', true);
console.log("End"); console.log("End");
cb(pavementLayerGroup); callback(pavementLayerGroup);
}); });
} catch (err) { } catch (err) {
console.error('no access!'); console.error('no access!');
store.default.dispatch('setPavementLoaded', true); store.default.dispatch('setPavementLoaded', true);
callback();
return; return;
} }
} }

View File

@ -264,5 +264,5 @@ function mapSGPropertyNode(node) {
})); }));
export function aiLayer(options) { export function aiLayer(options) {
return new L.AILayer(null, options); return undefined //new L.AILayer(null, options);
} }

View File

@ -1,4 +1,7 @@
/* eslint-disable */ /* eslint-disable */
const path = require('path');
const fs = require('fs');
const state = { const state = {
settings: { flightgearDirectory: '.', testDirectory: '.', email: 'flightgearairports@example.org', name: 'unknown', phi_url: 'http://localhost:8080' }, settings: { flightgearDirectory: '.', testDirectory: '.', email: 'flightgearairports@example.org', name: 'unknown', phi_url: 'http://localhost:8080' },
zoom: 14, zoom: 14,
@ -10,10 +13,21 @@ const state = {
const mutations = { const mutations = {
'DELETE_INDEXED_DB'() { }, 'DELETE_INDEXED_DB'() { },
'FLIGHTGEAR_DIRECTORY'(state, flightgearDirectory) { 'FLIGHTGEAR_DIRECTORY'(state, flightgearDirectory) {
try {
fs.accessSync(flightgearDirectory)
state.settings.flightgearDirectory = flightgearDirectory state.settings.flightgearDirectory = flightgearDirectory
state.settings.flightgearDirectory_ai = flightgearDirectory + '/data/AI' } catch (err) {
state.settings.flightgearDirectory_traffic = flightgearDirectory + '/data/AI/Traffic' try {
state.settings.flightgearDirectory_apt = flightgearDirectory + '/data/Airports/apt.dat.gz' fs.accessSync(flightgearDirectory.replace(/\.App/, ''))
state.settings.flightgearDirectory = flightgearDirectory.replace(/\.App/, '')
} catch (error) {
console.warn(error)
}
}
state.settings.flightgearDirectory_ai = flightgearDirectory + path.sep + 'AI'
state.settings.flightgearDirectory_traffic = path.join(flightgearDirectory, 'AI', 'Traffic');
state.settings.flightgearDirectory_apt = path.join(flightgearDirectory, 'Airports', 'apt.dat.gz');
}, },
'AIPORTS_DIRECTORY'(state, airportsDirectory) { 'AIPORTS_DIRECTORY'(state, airportsDirectory) {
state.settings.airportsDirectory = airportsDirectory state.settings.airportsDirectory = airportsDirectory