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: [],
mounted () {
this.aiLayer = aiLayer({url: this.$store.state.Settings.settings.phi_url})
if(this.aiLayer) {
this.aiLayer.addTo(this.$parent.mapObject)
}
},
data () {
return {

View File

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

View File

@ -17,23 +17,31 @@
</el-col>
</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-col :span="20" class="file-label">{{ flightgear_directory }}</el-col>
<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-row>
<el-row>
<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>
</el-row>
<el-row>
<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>
</el-row>
@ -123,7 +131,7 @@
import DirectorySelect from './DirectorySelect'
const { ipcRenderer } = require('electron')
const fs = require('fs')
export default {
name: 'settings-panel',
components: { DirectorySelect, FileSelect },
@ -132,7 +140,7 @@
},
data () {
return {
return { ok: true
}
},
methods: {
@ -192,9 +200,25 @@
Traffic_directory: function () {
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 () {
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 () {
return this.$store.state.Settings.settings.airportsDirectory
},
@ -229,4 +253,9 @@
.file-label {
padding: 10px;
}
.invalid {
padding: 10px;
background-color: red;
}
</style>

View File

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

View File

@ -264,5 +264,5 @@ function mapSGPropertyNode(node) {
}));
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 */
const path = require('path');
const fs = require('fs');
const state = {
settings: { flightgearDirectory: '.', testDirectory: '.', email: 'flightgearairports@example.org', name: 'unknown', phi_url: 'http://localhost:8080' },
zoom: 14,
@ -8,41 +11,52 @@ const state = {
}
const mutations = {
'DELETE_INDEXED_DB' () { },
'FLIGHTGEAR_DIRECTORY' (state, flightgearDirectory) {
'DELETE_INDEXED_DB'() { },
'FLIGHTGEAR_DIRECTORY'(state, flightgearDirectory) {
try {
fs.accessSync(flightgearDirectory)
state.settings.flightgearDirectory = flightgearDirectory
state.settings.flightgearDirectory_ai = flightgearDirectory + '/data/AI'
state.settings.flightgearDirectory_traffic = flightgearDirectory + '/data/AI/Traffic'
state.settings.flightgearDirectory_apt = flightgearDirectory + '/data/Airports/apt.dat.gz'
} catch (err) {
try {
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
},
'TEST_DIRECTORY' (state, testDirectory) {
'TEST_DIRECTORY'(state, testDirectory) {
state.settings.testDirectory = testDirectory
},
'ZOOM' (state, zoom) {
'ZOOM'(state, zoom) {
state.zoom = zoom
},
'CENTER' (state, center) {
'CENTER'(state, center) {
state.center = center
},
'BOUNDS' (state, bounds) {
'BOUNDS'(state, bounds) {
state.bounds = bounds
},
'SET_EMAIL' (state, email) {
'SET_EMAIL'(state, email) {
state.settings.email = email
},
'SET_NAME' (state, name) {
'SET_NAME'(state, name) {
state.settings.name = name
},
'SET_PHI_URL' (state, phi_url) {
'SET_PHI_URL'(state, phi_url) {
state.settings.phi_url = phi_url
},
'SET_SCAN_LOGGING' (state, scanLogging) {
'SET_SCAN_LOGGING'(state, scanLogging) {
state.settings.scanLogging = scanLogging
},
'ADD_WIP' (state, airport) {
'ADD_WIP'(state, airport) {
const item = state.wip.find((e) => e.icao === airport.icao)
airport.time = Date.now()
if (item === null || item === undefined) {
@ -52,12 +66,12 @@ const mutations = {
}
state.wip.sort((w1, w2) => w1.time - w2.time)
},
'UPLOAD_WIP' (state, icao) {
'UPLOAD_WIP'(state, icao) {
const item = state.wip.find((e) => e.icao === icao)
item.upload = Date.now()
state.wip.sort((p, p2) => { return p.time - p2.time })
},
'REMOVE_WIP' (state, icao) {
'REMOVE_WIP'(state, icao) {
const item = state.wip.find((e) => e.icao === icao)
const index = state.wip.indexOf(item)
if (index > -1) {
@ -69,21 +83,21 @@ const mutations = {
const plugins = []
const actions = {
async setZoom (context, zoom) {
async setZoom(context, zoom) {
context.commit('ZOOM', zoom)
},
async setCenter (context, center) {
if( center.lat !== context.state.center.lat || center.lng !== context.state.center.lng) {
async setCenter(context, center) {
if (center.lat !== context.state.center.lat || center.lng !== context.state.center.lng) {
context.commit('CENTER', center)
}
},
async setBounds (context, bounds) {
async setBounds(context, bounds) {
context.commit('BOUNDS', bounds)
},
async addWip (context, airport) {
async addWip(context, airport) {
context.commit('ADD_WIP', airport)
},
async removeWip (context, icao) {
async removeWip(context, icao) {
context.commit('REMOVE_WIP', icao)
}
}