From 62823feedddb256a46455e630610a27fa7155db7 Mon Sep 17 00:00:00 2001 From: portree_kid Date: Mon, 9 Mar 2020 19:58:40 +0100 Subject: [PATCH] Forward/Backward/Bidirection --- src/renderer/components/ArcEdit.vue | 33 +++++++++++++++++++ .../loaders/TaxiwaySegmentExtender.js | 15 ++++++--- src/renderer/loaders/groundnet_loader.js | 7 +++- src/renderer/loaders/groundnet_writer.js | 20 ++++++----- src/renderer/store/modules/Editable.js | 3 ++ 5 files changed, 65 insertions(+), 13 deletions(-) diff --git a/src/renderer/components/ArcEdit.vue b/src/renderer/components/ArcEdit.vue index 4ff58a3..2d718ec 100644 --- a/src/renderer/components/ArcEdit.vue +++ b/src/renderer/components/ArcEdit.vue @@ -27,6 +27,21 @@ + + + Direction : + + + + + + + @@ -36,6 +51,14 @@ arc: function () { return this.$store.state.Editable.type === 'arc' }, + // ga (general aviation), cargo (cargo), gate (commercial passenger traffic), + // mil-fighter (military fighter), mil-cargo (military transport) + options: function () { + return [{value: 'bi-directional', label: 'bi-directional'}, + {value: 'forward', label: 'forward'}, + {value: 'backward', label: 'backward'} + ] + }, name: { // getter get: function () { @@ -55,6 +78,16 @@ set: function (newValue) { this.$store.commit('SET_EDIT_PUSHBACK', newValue ? '1' : '0') } + }, + direction: { + // getter + get: function () { + return this.$store.state.Editable.data.arc.direction + }, + // setter + set: function (newValue) { + this.$store.commit('SET_EDIT_DIRECTION', newValue) + } } } } diff --git a/src/renderer/loaders/TaxiwaySegmentExtender.js b/src/renderer/loaders/TaxiwaySegmentExtender.js index ee05d77..4b18959 100644 --- a/src/renderer/loaders/TaxiwaySegmentExtender.js +++ b/src/renderer/loaders/TaxiwaySegmentExtender.js @@ -107,6 +107,9 @@ exports.extendTaxiSegment = function (taxiwaySegment) { }); this.on('editable:vertex:clicked', function (event) { console.log(this.featureLookup[event.vertex.glueindex]); + if (this.edit) { + + } store.default.dispatch('setNode', event.vertex.latlng.attributes) if(event.vertex._icon!=null) { @@ -235,10 +238,14 @@ exports.extendTaxiSegment = function (taxiwaySegment) { style.color = '#3388ff'; } this.setStyle(style); - if (!this.bidirectional) { - this.setText(' ► ', {repeat: true, attributes: {fill: 'red', size: 20}}) - } else { - this.setText('') + if (this.options.attributes.direction === 'forward') { + this.setText(null); + this.setText(' ⮞ ', {repeat: true, attributes: {fill: 'red', size: 30}}) + } else if (this.options.attributes.direction === 'backward') { + this.setText(null); + this.setText(' ⮜ ', {repeat: true, attributes: {fill: 'red', size: 30}}) + }else { + this.setText(null); } }; }; diff --git a/src/renderer/loaders/groundnet_loader.js b/src/renderer/loaders/groundnet_loader.js index f437814..f3fa8e4 100644 --- a/src/renderer/loaders/groundnet_loader.js +++ b/src/renderer/loaders/groundnet_loader.js @@ -53,6 +53,8 @@ exports.readGroundnetXML = function (fDir, icao, force) { var merged = new Array(); var nodesLookup = {}; + featureLookup = []; + parkingNodes.map(n => { var circle = parkingSpot(n, layerGroup); @@ -102,6 +104,7 @@ exports.readGroundnetXML = function (fDir, icao, force) { featureLookup[n.attr('begin')].forEach(element => { if (element instanceof L.Polyline && element.end === n.attr('begin') && element.begin === n.attr('end')) { element.bidirectional = true; + element.options.attributes.direction = 'bi-directional' bidirectional = true; element.updateStyle(); } @@ -111,7 +114,8 @@ exports.readGroundnetXML = function (fDir, icao, force) { featureLookup[n.attr('end')].forEach(element => { if (element instanceof L.Polyline && element.end === n.attr('begin') && element.begin === n.attr('end')) { element.bidirectional = true; - bidirectional = true; + element.options.attributes.direction = 'bi-directional' + bidirectional = true; element.updateStyle(); } }); @@ -148,6 +152,7 @@ exports.readGroundnetXML = function (fDir, icao, force) { else polyline.options.attributes[key] = Number(value); }); + polyline.options.attributes.direction = 'forward' polyline.updateStyle(); polyline.begin = beginNode.attr('index'); diff --git a/src/renderer/loaders/groundnet_writer.js b/src/renderer/loaders/groundnet_writer.js index cd36edc..d9f3cc2 100644 --- a/src/renderer/loaders/groundnet_writer.js +++ b/src/renderer/loaders/groundnet_writer.js @@ -55,14 +55,18 @@ exports.writeGroundnetXML = function (fDir, icao, featureList) { if (featureLookup[latlng.__vertex.glueindex] == undefined) { featureLookup[latlng.__vertex.glueindex] = []; } - arc = { '@begin': startIndex, '@end': String(latlng.__vertex.glueindex) }; - styleArc(currentArc, arc); - arcList.push(arc); - featureLookup[startIndex][latlng.__vertex.glueindex] = arc; - arc = { '@begin': String(latlng.__vertex.glueindex), '@end': startIndex }; - styleArc(currentArc, arc); - arcList.push(arc); - featureLookup[latlng.__vertex.glueindex][startIndex] = arc; + if( currentArc.direction === 'bi-directional' || currentArc.direction === 'forward' ){ + arc = { '@begin': startIndex, '@end': String(latlng.__vertex.glueindex) }; + styleArc(currentArc, arc); + arcList.push(arc); + featureLookup[startIndex][latlng.__vertex.glueindex] = arc; + } + if( currentArc.direction === 'bi-directional' || currentArc.direction === 'backward' ){ + arc = { '@begin': String(latlng.__vertex.glueindex), '@end': startIndex }; + styleArc(currentArc, arc); + arcList.push(arc); + featureLookup[latlng.__vertex.glueindex][startIndex] = arc; + } } startIndex = latlng.__vertex.glueindex; } diff --git a/src/renderer/store/modules/Editable.js b/src/renderer/store/modules/Editable.js index 220edad..cdd7fb4 100644 --- a/src/renderer/store/modules/Editable.js +++ b/src/renderer/store/modules/Editable.js @@ -63,6 +63,9 @@ const mutations = { 'SET_EDIT_PUSHBACK' (state, isPushBackRoute) { Vue.set(state.data.arc, 'isPushBackRoute', isPushBackRoute) }, + 'SET_EDIT_DIRECTION' (state, direction) { + Vue.set(state.data.arc, 'direction', direction) + }, 'SET_EDIT_HOLDPOINTTYPE' (state, holdPointType) { Vue.set(state.data.node, 'holdPointType', holdPointType) },