From 1f6fc221f929fe5744192c642af9c30ff6d46b04 Mon Sep 17 00:00:00 2001 From: portree_kid Date: Wed, 18 Mar 2020 16:48:18 +0100 Subject: [PATCH] Frequency Editing and Upload --- package.json | 5 +- src/renderer/components/AirportEdit.vue | 136 +++------------------- src/renderer/components/EditBar.vue | 10 +- src/renderer/components/Frequency.vue | 109 +++++++++++++++++ src/renderer/components/SettingsPanel.vue | 8 +- src/renderer/components/Upload copy.vue | 80 +++++++++++++ src/renderer/components/Upload.vue | 104 +++++++++++++++++ src/renderer/loaders/groundnet_loader.js | 33 ++++-- src/renderer/loaders/groundnet_writer.js | 34 ++++-- src/renderer/store/modules/Frequencies.js | 42 +++---- src/renderer/store/modules/Settings.js | 6 +- 11 files changed, 391 insertions(+), 176 deletions(-) create mode 100644 src/renderer/components/Frequency.vue create mode 100644 src/renderer/components/Upload copy.vue create mode 100644 src/renderer/components/Upload.vue diff --git a/package.json b/package.json index 6645932..7f86057 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "filter": [ "**/*" ] - }], + } + ], "files": [ "dist/electron/**/*" ], @@ -66,7 +67,7 @@ }, "dependencies": { "@turf/turf": "^5.1.6", - "axios": "^0.18.0", + "axios": "^0.18.1", "dijkstrajs": "^1.0.1", "electron-debug": "^3.0.1", "element-ui": "^2.12.0", diff --git a/src/renderer/components/AirportEdit.vue b/src/renderer/components/AirportEdit.vue index 8fb02e4..37c231f 100644 --- a/src/renderer/components/AirportEdit.vue +++ b/src/renderer/components/AirportEdit.vue @@ -26,75 +26,36 @@ {{ parking }} - + +

Frequencies

- - AWOS : - > - - - Ground : - - - - Tower : - - - - Approach : - - - - Departure : - + +
+ Add + + diff --git a/src/renderer/components/SettingsPanel.vue b/src/renderer/components/SettingsPanel.vue index c67fb2d..60cb939 100644 --- a/src/renderer/components/SettingsPanel.vue +++ b/src/renderer/components/SettingsPanel.vue @@ -42,7 +42,7 @@ Author : - + @@ -74,14 +74,14 @@ } }, computed: { - name: { + email: { // getter get: function () { - return this.$store.state.Settings.settings.name + return this.$store.state.Settings.settings.email }, // setter set: function (newValue) { - this.$store.commit('SET_USERNAME', newValue) + this.$store.commit('SET_EMAIL', newValue) } }, flightgear_directory: function () { diff --git a/src/renderer/components/Upload copy.vue b/src/renderer/components/Upload copy.vue new file mode 100644 index 0000000..15cf953 --- /dev/null +++ b/src/renderer/components/Upload copy.vue @@ -0,0 +1,80 @@ + + + + + diff --git a/src/renderer/components/Upload.vue b/src/renderer/components/Upload.vue new file mode 100644 index 0000000..94820af --- /dev/null +++ b/src/renderer/components/Upload.vue @@ -0,0 +1,104 @@ + + + + + diff --git a/src/renderer/loaders/groundnet_loader.js b/src/renderer/loaders/groundnet_loader.js index b45361e..19e4038 100644 --- a/src/renderer/loaders/groundnet_loader.js +++ b/src/renderer/loaders/groundnet_loader.js @@ -17,6 +17,17 @@ var $ = require('jquery'); var featureLookup = {}; +var frequencies = []; + +function addFrequencies (type, value) { + value.split(' ').forEach(frequencyValue => { + if( value.length > 0) { + var frequency = {type: type, value: frequencyValue}; + frequencies.push(frequency); + } + }) +} + exports.addFeature = function (feature) { featureLookup[feature.id] = new Array(); } @@ -54,14 +65,22 @@ exports.readGroundnetXML = function (fDir, icao, force) { // 12120 // - var awos = xml.find('groundnet/frequencies/AWOS/text()').text(); - store.default.dispatch('setAwos', awos); - var ground = xml.find('groundnet/frequencies/GROUND/text()').text(); - store.default.dispatch('setGround', ground); - var tower = xml.find('groundnet/frequencies/TOWER/text()').text(); - store.default.dispatch('setTower', tower); var approach = xml.find('groundnet/frequencies/APPROACH/text()').text(); - store.default.dispatch('setApproach', approach); + addFrequencies('APPROACH', approach); + var awos = xml.find('groundnet/frequencies/AWOS/text()').text(); + addFrequencies('AWOS', awos); + var clearance = xml.find('groundnet/frequencies/CLEARANCE/text()').text(); + addFrequencies('CLEARANCE', clearance); + var departure = xml.find('groundnet/frequencies/DEPARTURE/text()').text(); + addFrequencies('DEPARTURE', departure); + var ground = xml.find('groundnet/frequencies/GROUND/text()').text(); + addFrequencies('GROUND', ground); + var tower = xml.find('groundnet/frequencies/TOWER/text()').text(); + addFrequencies('TOWER', tower); + var unicom = xml.find('groundnet/frequencies/UNICOM/text()').text(); + addFrequencies('UNICOM', unicom); + + store.default.dispatch('setFrequencies', frequencies); var parkingNodes = xml.find('groundnet/parkingList/Parking'); console.log("Parking Nodes" + parkingNodes.length); diff --git a/src/renderer/loaders/groundnet_writer.js b/src/renderer/loaders/groundnet_writer.js index 86bb991..06a6afe 100644 --- a/src/renderer/loaders/groundnet_writer.js +++ b/src/renderer/loaders/groundnet_writer.js @@ -30,18 +30,12 @@ exports.writeGroundnetXML = function (fDir, icao, featureList) { var nodes = []; var arcList = []; + var frequencies = []; var version = new Date().toUTCString() + ' by FlightgearAirports'; - var name = store.default.state.Settings.settings.name; + var email = store.default.state.Settings.settings.email; + - //Frequencies - var frequencies = { - 'AWOS': store.default.state.Frequencies.AWOS, - 'GROUND': store.default.state.Frequencies.GROUND, - 'TOWER': store.default.state.Frequencies.TOWER, - 'APPROACH': store.default.state.Frequencies.APPROACH, - 'DEPARTURE': store.default.state.Frequencies.DEPARTURE - }; var featureLookup = []; // Loaded segments @@ -102,7 +96,23 @@ exports.writeGroundnetXML = function (fDir, icao, featureList) { var maxId = uniqueNodes.slice(-1)[0]['@index']; - var xmlObj = { groundnet: { version: version, name: name, frequencies, parkingList: { Parking: parkings }, TaxiNodes: { node: uniqueNodes }, TaxiWaySegments: { arc: arcList } } }; + var approachList = store.default.state.Frequencies.items.filter(f => f.type === 'APPROACH').map(mapFrequency); + + var awosList = store.default.state.Frequencies.items.filter(f => f.type === 'AWOS').map(mapFrequency); + + var clearanceList = store.default.state.Frequencies.items.filter(f => f.type === 'CLEARANCE').map(mapFrequency); + + var departureList = store.default.state.Frequencies.items.filter(f => f.type === 'DEPARTURE').map(mapFrequency); + + var groundList = store.default.state.Frequencies.items.filter(f => f.type === 'GROUND').map(mapFrequency); + + var towerList = store.default.state.Frequencies.items.filter(f => f.type === 'TOWER').map(mapFrequency); + + var unicomList = store.default.state.Frequencies.items.filter(f => f.type === 'UNICOM').map(mapFrequency); + + var xmlObj = { groundnet: { version: version, email: email, + 'frequencies': { APPROACH: approachList, DEPARTURE: departureList, AWOS: awosList, CLEARANCE: clearanceList, GROUND: groundList, TOWER: towerList, UNICOM: unicomList }, + parkingList: { Parking: parkings }, TaxiNodes: { node: uniqueNodes }, TaxiWaySegments: { arc: arcList } } }; xmlString = builder.create(xmlObj).end({ pretty: true }); fs.writeFileSync(f, xmlString); @@ -113,6 +123,10 @@ exports.writeGroundnetXML = function (fDir, icao, featureList) { return layerGroup; } +var mapFrequency = function (o) { + return o.value; +} + var mapParkings = function (o) { console.log(o); if (o instanceof L.ParkingSpot) { diff --git a/src/renderer/store/modules/Frequencies.js b/src/renderer/store/modules/Frequencies.js index f0fc716..605adfe 100644 --- a/src/renderer/store/modules/Frequencies.js +++ b/src/renderer/store/modules/Frequencies.js @@ -1,45 +1,29 @@ import Vue from 'vue' -const state = { - 'AWOS': 0, - 'GROUND': 0, - 'TOWER': 0, - 'APPROACH': 0 -} +const state = { items: [] } const mutations = { - 'SET_AWOS' (state, frequency) { - Vue.set(state, 'AWOS', frequency) + ADD_FREQUENCY: (state, item) => { + state.items.push(item) }, - 'SET_GROUND' (state, frequency) { - Vue.set(state, 'GROUND', frequency) + UPDATE_FREQUENCY: (state, item) => { + const existingItem = state.items.find((i) => i.id === item.id) + Object.assign(existingItem, item) }, - 'SET_TOWER' (state, frequency) { - Vue.set(state, 'TOWER', frequency) - }, - 'SET_APPROACH' (state, frequency) { - Vue.set(state, 'APPROACH', frequency) - }, - 'SET_DEPARTURE' (state, frequency) { - Vue.set(state, 'DEPARTURE', frequency) + SET_FREQUENCIES (state, frequencies) { + Vue.set(state, 'items', frequencies) } } const actions = { - async setAwos (context, frequency) { - context.commit('SET_AWOS', frequency) + async addFrequency (context, frequency) { + context.commit('ADD_FREQUENCY', frequency) }, - async setGround (context, frequency) { + async updateFrequency (context, frequency) { context.commit('SET_GROUND', frequency) }, - async setTower (context, frequency) { - context.commit('SET_TOWER', frequency) - }, - async setApproach (context, frequency) { - context.commit('SET_APPROACH', frequency) - }, - async setDeparture (context, frequency) { - context.commit('SET_DEPARTURE', frequency) + async setFrequencies (context, frequencies) { + context.commit('SET_FREQUENCIES', frequencies) } } diff --git a/src/renderer/store/modules/Settings.js b/src/renderer/store/modules/Settings.js index 67d495c..61925d6 100644 --- a/src/renderer/store/modules/Settings.js +++ b/src/renderer/store/modules/Settings.js @@ -1,5 +1,5 @@ const state = { - settings: {flightgearDirectory: '.', name: ''}, + settings: {flightgearDirectory: '.', email: 'x'}, zoom: 14, center: [47.413220, -1.219482], bounds: undefined @@ -25,8 +25,8 @@ const mutations = { 'BOUNDS' (state, bounds) { state.bounds = bounds }, - 'SET_USERNAME' (state, name) { - state.settings.name = name + 'SET_EMAIL' (state, email) { + state.settings.email = email } }