portree_kid 2020-08-01 07:23:26 +02:00
parent 2178061b55
commit 0499ee82c2
10 changed files with 213 additions and 32 deletions

View File

@ -58,9 +58,12 @@ You should have received a copy of the GNU General Public License along with FG
const $ = require('jquery'); const $ = require('jquery');
import 'element-ui/lib/theme-chalk/index.css' import 'element-ui/lib/theme-chalk/index.css'
import {removeWip} from '../loaders/groundnet_functions' import {removeWip} from '../loaders/groundnet_functions'
import Vue from 'vue'
import { EventBus } from './event-bus.js';
export default { export default {
name: 'airport', name: 'airport',
components: { },
props: {airport: Object, editing: Boolean}, props: {airport: Object, editing: Boolean},
mounted () { mounted () {
this.$forceUpdate(); this.$forceUpdate();
@ -83,7 +86,14 @@ You should have received a copy of the GNU General Public License along with FG
this.$store.dispatch('removeWip', this.airport.icao); this.$store.dispatch('removeWip', this.airport.icao);
}, },
upload() { upload() {
let airports = this.$store.state.Airports.airports
.filter(a => a.properties.icao.match(this.airport.icao))
if (airports.length > 0) {
this.$store.commit('CENTER', [airports[0].geometry.coordinates[1], airports[0].geometry.coordinates[0]])
}
Vue.set(this.$parent.$parent.$parent, 'uploadVisible', true)
this.$parent.$parent.$parent.$refs.upload.status()
this.$parent.$parent.$parent.$refs.upload.check()
} }
}, },
computed: { computed: {

View File

@ -22,6 +22,8 @@ You should have received a copy of the GNU General Public License along with FG
import L2 from 'leaflet-textpath' import L2 from 'leaflet-textpath'
import Vue from 'vue' import Vue from 'vue'
import { MessageBox } from 'element-ui'; import { MessageBox } from 'element-ui';
import { EventBus } from './event-bus.js';
const turf = require('@turf/turf') const turf = require('@turf/turf')
@ -131,24 +133,12 @@ You should have received a copy of the GNU General Public License along with FG
l.addListeners() l.addListeners()
} }
}) })
/*
this.groundnetLayerGroup.eachLayer(l => {
if (l instanceof L.TaxiwaySegment) {
var decorator = L.polylineDecorator(l, {
pattern: [
// defines a pattern of 10px-wide dashes, repeated every 20px on the line
{offset: 5, repeat: 50, symbol: L.Symbol.arrowHead({pixelSize: 15, pathOptions: {fillOpacity: 1, weight: 0}})}
]
})
decorator.addTo(this.$parent.mapObject)
}
})
*/
console.log(this.groundnetLayerGroup.maxId) console.log(this.groundnetLayerGroup.maxId)
this.groundnetLayerGroup.addTo(this.$parent.mapObject) this.groundnetLayerGroup.addTo(this.$parent.mapObject)
this.icao = icao this.icao = icao
console.log(EventBus)
EventBus.$emit('i-got-clicked', 1);
}, },
visible (feature) { visible (feature) {
let bounds = this.$store.state.Settings.bounds let bounds = this.$store.state.Settings.bounds
@ -644,7 +634,7 @@ You should have received a copy of the GNU General Public License along with FG
if (this.featureLookup===undefined) { if (this.featureLookup===undefined) {
return return
} }
console.log('Edited Parkings : ' + this.$store.state.Parkings.items) console.debug('Edited Parkings : ' + this.$store.state.Parkings.items)
this.$store.state.Parkings.items.forEach( newElement => { this.$store.state.Parkings.items.forEach( newElement => {
console.debug(newElement); console.debug(newElement);
if(this.featureLookup[newElement.index]) { if(this.featureLookup[newElement.index]) {

View File

@ -78,6 +78,64 @@ You should have received a copy of the GNU General Public License along with FG
name: 'flightgear-map', name: 'flightgear-map',
components: { LMap, LTileLayer, LMarker, LCircle, LeafletSidebar, AiLayer, EditBar, ToolBar, EditLayer, PavementLayer, LLayerGroup, LControl, ThresholdLayer, ToolLayer }, components: { LMap, LTileLayer, LMarker, LCircle, LeafletSidebar, AiLayer, EditBar, ToolBar, EditLayer, PavementLayer, LLayerGroup, LControl, ThresholdLayer, ToolLayer },
props: [], props: [],
created () {
this.loadingInstance = null
this.$store.watch(
function (state) {
return state.Loading.groundnetLoaded
},
(newValue, oldValue) => {
// debugger
console.log('groundnetLoaded ' + oldValue + ' => ' + newValue + ' ' + this.groundnetLoaded + ' ' + this.pavementLoaded + ' ' + this.loadingInstance)
if (newValue !== oldValue) {
this.groundnetLoaded = newValue
if (!(this.groundnetLoaded &&
this.pavementLoaded) &&
(this.loadingInstance === null || this.loadingInstance === undefined)) {
this.loadingInstance = Loading.service({ fullscreen: false })
}
if (this.groundnetLoaded &&
this.pavementLoaded &&
this.loadingInstance !== null) {
this.loadingInstance.close()
this.loadingInstance = null
}
}
}
,
{
deep: false,
immediate: true
}
)
this.$store.watch(
function (state) {
return state.Loading.pavementLoaded
},
(newValue, oldValue) => {
console.log('pavementLoaded ' + oldValue + ' => ' + newValue + ' ' + this.groundnetLoaded + ' ' + this.pavementLoaded + ' ' + this.loadingInstance)
if (newValue !== oldValue) {
this.pavementLoaded = newValue
if (!(this.groundnetLoaded &&
this.pavementLoaded) &&
(this.loadingInstance === null || this.loadingInstance === undefined)) {
this.loadingInstance = Loading.service({ fullscreen: false })
}
if (this.groundnetLoaded &&
this.pavementLoaded &&
this.loadingInstance !== null) {
this.loadingInstance.close()
this.loadingInstance = null
}
}
}
,
{
deep: false,
immediate: true
}
)
},
mounted () { mounted () {
this.$store.dispatch('getAirports') this.$store.dispatch('getAirports')
this.$store.subscribe((mutation, state) => { this.$store.subscribe((mutation, state) => {
@ -88,13 +146,10 @@ You should have received a copy of the GNU General Public License along with FG
.filter(feature => this.visible(feature)) .filter(feature => this.visible(feature))
.map(feature => feature.properties.icao) .map(feature => feature.properties.icao)
if (airportsToLoad.length > 0 && airportsToLoad[0] !== this.editingAirport && this.zoom > 12) { if (airportsToLoad.length > 0 && airportsToLoad[0] !== this.editingAirport && this.zoom > 12) {
let loadingInstance = Loading.service({ fullscreen: true })
this.$nextTick(() => { // Loading should be closed asynchronously this.$nextTick(() => { // Loading should be closed asynchronously
this.$refs.pavementLayer.load(airportsToLoad[0]) this.$refs.pavementLayer.load(airportsToLoad[0])
this.$refs.editLayer.load(airportsToLoad[0]) this.$refs.editLayer.load(airportsToLoad[0])
this.$refs.thresholdLayer.load(airportsToLoad[0]) this.$refs.thresholdLayer.load(airportsToLoad[0])
loadingInstance.close()
this.editingAirport = airportsToLoad[0] this.editingAirport = airportsToLoad[0]
}) })
} }
@ -111,6 +166,9 @@ You should have received a copy of the GNU General Public License along with FG
}, },
data () { data () {
return { return {
loadingInstance: Object,
groundnetLoaded: false,
pavementLoaded: false,
url: 'https://a.tile.openstreetmap.de/{z}/{x}/{y}.png', url: 'https://a.tile.openstreetmap.de/{z}/{x}/{y}.png',
attribution: '<A href="https://github.com/Portree-Kid/flightgear-airports" target="_blank">Flightgear Airports ' + require('electron').remote.app.getVersion() + attribution: '<A href="https://github.com/Portree-Kid/flightgear-airports" target="_blank">Flightgear Airports ' + require('electron').remote.app.getVersion() +
'</A> <A href="https://www.electronjs.org/" target="_blank">Electron</A> ' + '</A> <A href="https://www.electronjs.org/" target="_blank">Electron</A> ' +

View File

@ -11,6 +11,7 @@ You should have received a copy of the GNU General Public License along with FG
--> -->
<template> <template>
<div id="sidebar" class="leaflet-sidebar collapsed"> <div id="sidebar" class="leaflet-sidebar collapsed">
<Upload :visible.sync="uploadVisible" ref="upload"></Upload>
<!-- Nav tabs --> <!-- Nav tabs -->
<div class="leaflet-sidebar-tabs"> <div class="leaflet-sidebar-tabs">
<ul role="tablist"> <!-- top aligned tabs --> <ul role="tablist"> <!-- top aligned tabs -->
@ -83,11 +84,12 @@ You should have received a copy of the GNU General Public License along with FG
import RunScan from './RunScan' import RunScan from './RunScan'
import SettingsPanel from './SettingsPanel' import SettingsPanel from './SettingsPanel'
import Search from './Search' import Search from './Search'
import Upload from './Upload'
import WorkInProgress from './WorkInProgress' import WorkInProgress from './WorkInProgress'
export default { export default {
name: 'leaflet-sidebar', name: 'leaflet-sidebar',
components: { Help, AirportEdit, ArcEdit, CheckPanel, NodeEdit, ParkingEdit, ParkingGroupEdit, RunScan, FileSelect, SettingsPanel, Search, WorkInProgress }, components: { Help, AirportEdit, ArcEdit, CheckPanel, NodeEdit, ParkingEdit, ParkingGroupEdit, RunScan, FileSelect, SettingsPanel, Search, Upload, WorkInProgress },
props: [], props: [],
created () { created () {
window.addEventListener('keydown', this.doCommand) window.addEventListener('keydown', this.doCommand)
@ -102,7 +104,7 @@ You should have received a copy of the GNU General Public License along with FG
this.remove() this.remove()
}, },
data () { data () {
return { return { uploadVisible: false
} }
}, },
methods: { methods: {

View File

@ -26,6 +26,31 @@
name: 'upload', name: 'upload',
props: [], props: [],
mounted () { mounted () {
this.$store.watch(
function (state) {
return state.Loading.groundnetLoaded;
},
() => { if(this.$store.state.Loading.groundnetLoaded &&
this.$store.state.Loading.pavementLoaded &&
this.visible) this.check() }
,
{
deep: false
}
);
this.$store.watch(
function (state) {
return state.Loading.pavementLoaded;
},
() => { if(this.$store.state.Loading.groundnetLoaded &&
this.$store.state.Loading.pavementLoaded &&
this.visible) this.check() }
,
{
deep: false
}
);
}, },
data () { data () {
return { return {
@ -44,6 +69,7 @@
}, },
status () { status () {
this.azure = false;
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
var parent = this.$parent; var parent = this.$parent;
@ -151,14 +177,18 @@
}, },
check () { check () {
try { try {
if(!(this.$store.state.Loading.groundnetLoaded &&
this.$store.state.Loading.pavementLoaded)) {
return
}
this.scanning = true this.scanning = true
const winURL = process.env.NODE_ENV === 'development' const winURL = process.env.NODE_ENV === 'development'
? `http://localhost:9080/src/renderer/utils/check.js` ? `http://localhost:9080/src/renderer/utils/check.js`
: `file://${process.resourcesPath}/workers/check.js` : `file://${process.resourcesPath}/workers/check.js`
console.log('make a check worker: ', path.resolve(__dirname, 'check.js')) console.debug('make a check worker: ', path.resolve(__dirname, 'check.js'))
const worker = new Worker(winURL) const worker = new Worker(winURL)
console.log(fileUrl('src/renderer/utils/check.js')) console.debug(fileUrl('src/renderer/utils/check.js'))
worker.checking = this.checking worker.checking = this.checking
worker.max = this.max worker.max = this.max
@ -169,13 +199,13 @@
this.worker = worker this.worker = worker
var groundnet = [] var groundnet = []
if (!this.$parent.$parent.$parent.$refs.editLayer.groundnetLayerGroup) { if (!this.editLayer().groundnetLayerGroup) {
this.message = 'Groundnet not visible' this.message = 'Groundnet not visible'
} }
if (!this.$parent.$parent.$parent.$refs.pavementLayer.pavement) { if (!this.pavementLayer().pavement) {
this.message = 'Pavement not visible' this.message = 'Pavement not visible'
} }
this.$parent.$parent.$parent.$refs.editLayer.groundnetLayerGroup.eachLayer(l => { this.editLayer().groundnetLayerGroup.eachLayer(l => {
console.log(l) console.log(l)
if (l instanceof L.Polyline) { if (l instanceof L.Polyline) {
l._latlngs[0].glueindex = this.begin; l._latlngs[0].glueindex = this.begin;
@ -186,7 +216,7 @@
}) })
var features = groundnet.map(mapper.checkMapper).filter(n => n) var features = groundnet.map(mapper.checkMapper).filter(n => n)
var pavement = [] var pavement = []
this.$parent.$parent.$parent.$refs.pavementLayer.pavement.eachLayer(l => { this.pavementLayer().pavement.eachLayer(l => {
console.log(l) console.log(l)
pavement.push(l) pavement.push(l)
}) })
@ -221,7 +251,21 @@
} catch (err) { } catch (err) {
console.error(err) console.error(err)
} }
} },
editLayer () {
if(this.$parent.$parent.$parent.icao) {
return this.$parent.$parent.$parent.$refs.editLayer
} else {
return this.$parent.$parent.$parent.$parent.$parent.$parent.$refs.editLayer
}
},
pavementLayer () {
if(this.$parent.$parent.$parent.icao) {
return this.$parent.$parent.$parent.$refs.pavementLayer
} else {
return this.$parent.$parent.$parent.$parent.$parent.$parent.$refs.pavementLayer
}
}
}, },
computed: { computed: {
visible: { visible: {
@ -238,7 +282,11 @@
return !this.error?'center':'error' return !this.error?'center':'error'
}, },
title: function () { title: function () {
return `Upload ${this.$parent.$parent.$parent.icao} to groundweb.` if(this.$parent.$parent.$parent.icao !== undefined) {
return `Upload ${this.$parent.$parent.$parent.icao} to groundweb.`
} else if (this.$parent.$parent.$parent.$refs.editLayer !== undefined) {
return `Upload ${this.$parent.$parent.$parent.$refs.editLayer.icao} to groundweb.`
}
}, },
icao: { icao: {
get: function () { get: function () {
@ -253,7 +301,7 @@
results: function () { results: function () {
return this.$store.state.Check.results.filter(a => a.id>=0) return this.$store.state.Check.results.filter(a => a.id>=0)
} }
} },
} }
</script> </script>

View File

@ -0,0 +1,14 @@
/*
Copyright 2020 Keith Paterson
This file is part of FG Airports.
FG Airports is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
FG Airports is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with FG Airports. If not, see http://www.gnu.org/licenses/.
*/
import Vue from 'vue'
export const EventBus = new Vue()

View File

@ -34,6 +34,7 @@ exports.addFeature = function (feature) {
exports.readGroundnetXML = function (fDir, icao, force) { exports.readGroundnetXML = function (fDir, icao, force) {
try { try {
store.default.dispatch('setGroundnetLoaded', false);
var layerGroup = L.layerGroup(); var layerGroup = L.layerGroup();
layerGroup.maxId = 0; layerGroup.maxId = 0;
var f = path.join(fDir, icao[0], icao[1], icao[2], icao + '.groundnet.xml'); var f = path.join(fDir, icao[0], icao[1], icao[2], icao + '.groundnet.xml');
@ -84,7 +85,7 @@ exports.readGroundnetXML = function (fDir, icao, force) {
store.default.dispatch('setFrequencies', frequencies); store.default.dispatch('setFrequencies', frequencies);
var parkingNodes = xml.find('groundnet/parkingList/Parking'); var parkingNodes = xml.find('groundnet/parkingList/Parking');
console.log("Parking Nodes" + parkingNodes.length); console.debug("Parking Nodes length" + parkingNodes.length);
var merged = new Array(); var merged = new Array();
@ -174,6 +175,7 @@ exports.readGroundnetXML = function (fDir, icao, force) {
if (!bidirectional) { if (!bidirectional) {
var beginlatlon = convert(beginNode.attr('lat') + " " + beginNode.attr('lon')); var beginlatlon = convert(beginNode.attr('lat') + " " + beginNode.attr('lon'));
var endlatlon = convert(endNode.attr('lat') + " " + endNode.attr('lon')); var endlatlon = convert(endNode.attr('lat') + " " + endNode.attr('lon'));
var polyline = new L.Polyline([[beginlatlon.decimalLatitude, beginlatlon.decimalLongitude], [endlatlon.decimalLatitude, endlatlon.decimalLongitude]], { attributes: {} }).addTo(layerGroup); var polyline = new L.Polyline([[beginlatlon.decimalLatitude, beginlatlon.decimalLongitude], [endlatlon.decimalLatitude, endlatlon.decimalLongitude]], { attributes: {} }).addTo(layerGroup);
extendTaxiSegment(polyline); extendTaxiSegment(polyline);
polyline.addListeners(); polyline.addListeners();
@ -224,7 +226,7 @@ exports.readGroundnetXML = function (fDir, icao, force) {
} }
} }
}).sort(); }).sort();
store.default.dispatch('setGroundnetLoaded', true);
return layerGroup; return layerGroup;
}); });

View File

@ -16,6 +16,8 @@ const zlib = require('zlib');
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');
const store = require('../store');
const buildRunwayPoly = require('../leaflet/Runway.js'); const buildRunwayPoly = require('../leaflet/Runway.js');
/** /**
@ -271,6 +273,8 @@ module.exports.readPavement = function (f, icao, cb) {
var pavementLayerGroup = L.layerGroup(); var pavementLayerGroup = L.layerGroup();
var currentFeature; var currentFeature;
store.default.dispatch('setPavementLoaded', false);
lineReader.createInterface({ lineReader.createInterface({
input: fs.createReadStream(f).pipe(zlib.createGunzip()) input: fs.createReadStream(f).pipe(zlib.createGunzip())
}).on('line', function (line) { }).on('line', function (line) {
@ -293,9 +297,11 @@ module.exports.readPavement = function (f, icao, cb) {
console.error('Error reading : ' + line + error); console.error('Error reading : ' + line + error);
} }
}).on('error', function (err) { }).on('error', function (err) {
store.default.dispatch('setPavementLoaded', true);
console.error(err); console.error(err);
lr.close(); lr.close();
}).on('close', function () { }).on('close', function () {
store.default.dispatch('setPavementLoaded', true);
console.log("End"); console.log("End");
cb(pavementLayerGroup); cb(pavementLayerGroup);
}); });

View File

@ -0,0 +1,39 @@
/*
Copyright 2020 Keith Paterson
This file is part of FG Airports.
FG Airports is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
FG Airports is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with FG Airports. If not, see http://www.gnu.org/licenses/.
*/
import Vue from 'vue'
const state = { groundnetLoaded: false, pavementLoaded: false }
const mutations = {
SET_GROUNDNET_LOADED (state, loaded) {
Vue.set(state, 'groundnetLoaded', loaded)
},
SET_PAVEMENT_LOADED (state, loaded) {
Vue.set(state, 'pavementLoaded', loaded)
}
}
const actions = {
async setGroundnetLoaded (context, p) {
context.commit('SET_GROUNDNET_LOADED', p)
},
async setPavementLoaded (context, p) {
context.commit('SET_PAVEMENT_LOADED', p)
}
}
export default {
state,
mutations,
actions
}

View File

@ -1,3 +1,15 @@
/*
Copyright 2020 Keith Paterson
This file is part of FG Airports.
FG Airports is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
FG Airports is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with FG Airports. If not, see http://www.gnu.org/licenses/.
*/
import Vue from 'vue' import Vue from 'vue'
const state = { items: [] } const state = { items: [] }