diff --git a/src/renderer/components/EditLayer.vue b/src/renderer/components/EditLayer.vue
index 0c98aa4..be8cbea 100644
--- a/src/renderer/components/EditLayer.vue
+++ b/src/renderer/components/EditLayer.vue
@@ -43,7 +43,7 @@
this.groundnetLayerGroup.removeFrom(this.$parent.mapObject)
}
this.icao = icao
- this.groundnetLayerGroup = readGroundnetXML(this.$store.state.Settings.settings.airportsDirectory, icao, false)
+ this.groundnetLayerGroup = readGroundnetXML(this.$store.state.Settings.settings.airportsDirectory, icao, true)
if (this.groundnetLayerGroup === undefined) {
console.console.error('ICAO not loaded ' + icao)
return
@@ -126,19 +126,21 @@
var polyLine = this.$parent.mapObject.editTools.startPolyline()
polyLine.addTo(this.groundnetLayerGroup)
polyLine.groundnetLayerGroup = this.groundnetLayerGroup;
+ polyLine.attributes = [];
polyLine.on('editable:vertex:new', event => {
console.log(event)
let closest = this.closestLayerSnap(event.latlng, 10)
if (closest) {
- event.latlng.__vertex.glueindex = closest.vertex.glueindex;
- event.latlng.__vertex.setLatLng(closest.vertex.latlng);
+ event.latlng.__vertex.glueindex = closest.glueindex;
+ event.latlng.__vertex.setLatLng(closest.latlng);
+ this.featureLookup[event.latlng.__vertex.glueindex].push(event.latlng.__vertex);
console.log(closest)
- }
- else{
+ } else {
event.latlng.__vertex.glueindex = ++this.groundnetLayerGroup.maxId;
this.featureLookup[event.latlng.__vertex.glueindex] = [];
}
+ event.latlng.attributes = [];
})
polyLine.on('editable:drawing:end', event => {
event.target.featureLookup = this.featureLookup;
@@ -152,15 +154,20 @@
var layers = []
this.groundnetLayerGroup.eachLayer((layer) => {
if (layer instanceof L.Polyline) {
- console.log(layer._latlngs)
+ // console.log(layer._latlngs)
layer._latlngs.forEach(latlng => {
if (latlng.__vertex) {
let distance = latlng.distanceTo(eventLatlng)
if (distance > 0 && distance < snap) {
- layers.push({d: latlng.distanceTo(eventLatlng), l: layer, vertex: latlng.__vertex})
+ layers.push({d: distance, l: layer, latlng: latlng.__vertex.latlng, glueindex: latlng.__vertex.glueindex})
}
}
})
+ } else if (layer instanceof L.RunwayNode) {
+ let distance = layer._latlng.distanceTo(eventLatlng)
+ if (distance > 0 && distance < snap) {
+ layers.push({d: distance, l: layer, latlng: layer._latlng, glueindex: layer.glueindex})
+ }
}
})
layers.sort((l1, l2) => l1.d - l2.d)
@@ -196,6 +203,7 @@
save () {
var xml = []
this.groundnetLayerGroup.eachLayer(l => {
+ console.log(l)
xml.push(l)
})
writeGroundnetXML(this.$store.state.Settings.settings.airportsDirectory, this.icao, xml)
diff --git a/src/renderer/loaders/RunwayNode.js b/src/renderer/loaders/RunwayNode.js
index 242b75e..aea7ca4 100644
--- a/src/renderer/loaders/RunwayNode.js
+++ b/src/renderer/loaders/RunwayNode.js
@@ -11,8 +11,60 @@ L.RunwayNode = L.Marker.extend({
this.on('editable:drawing:move', function (event) {
console.log("Move : ", event);
// Is it the edit vertex (Middle) moving?
- follow(event.target.id, event);
+ this.follow(event.target.glueindex, event);
});
+ },
+ extensions: function () {
+ if (typeof this.featureLookup[this.glueindex] === 'undefined') {
+ this.featureLookup[this.glueindex] = new Array();
+ }
+ this.featureLookup[this.glueindex].push(this);
+ },
+ /**
+ *
+ */
+
+ follow(dragIndex, event) {
+ this.featureLookup[dragIndex].forEach(element => {
+ if (element !== event.target) {
+ if (element instanceof L.RunwayNode) {
+ element.setLatLng(event.latlng);
+ }
+ else if (element instanceof L.ParkingSpot) {
+ // element.disableEdit();
+ element.setLatLng(event.latlng);
+ // element.enableEdit();
+ // element.extensions();
+ element.updateMiddleMarker();
+ element.updateVertexFromDirection();
+ }
+ else if (element instanceof L.TaxiwaySegment) {
+ if (element.begin === dragIndex) {
+ element.getLatLngs()[0].update(event.latlng);
+ element.setLatLngs(element.getLatLngs());
+ element.updateBeginVertex(event.latlng);
+ element.updateMiddle();
+ }
+ if (element.end === dragIndex) {
+ element.getLatLngs()[element.getLatLngs().length - 1].update(event.latlng);
+ element.setLatLngs(element.getLatLngs());
+ element.updateEndVertex(event.latlng);
+ element.updateMiddle();
+ }
+ } else if (element instanceof L.Editable.VertexMarker) {
+ console.log(element);
+ element.setLatLng(event.latlng);
+ element.latlngs.forEach((latlng, index) => {
+ console.log(latlng);
+ if(latlng.__vertex === element) {
+ latlng.update(event.latlng);
+ }
+ });
+ element.editor.feature.setLatLngs(element.latlngs);
+ element.editor.feature.updateMiddle();
+ }
+ }
+ })
}
});
diff --git a/src/renderer/loaders/TaxiwaySegment.js b/src/renderer/loaders/TaxiwaySegment.js
index 5d50472..fb7011a 100644
--- a/src/renderer/loaders/TaxiwaySegment.js
+++ b/src/renderer/loaders/TaxiwaySegment.js
@@ -1,13 +1,9 @@
/* eslint-disable */
var L = require('leaflet');
+const store = require('../store');
L.TaxiwaySegment = L.Polyline.extend({
- options: {
- id: 'Custom data!',
- attributes: {}
- },
-
begin: String,
end: String,
bidirectional: Boolean,
@@ -106,7 +102,19 @@ L.TaxiwaySegment = L.Polyline.extend({
element.updateEndVertex(event.latlng);
element.updateMiddle();
}
+ } else if (element instanceof L.Editable.VertexMarker) {
+ console.log(element);
+ element.setLatLng(event.latlng);
+ element.latlngs.forEach((latlng, index) => {
+ console.log(latlng);
+ if(latlng.__vertex === element) {
+ latlng.update(event.latlng);
+ }
+ });
+ element.editor.feature.setLatLngs(element.latlngs);
+ element.editor.feature.updateMiddle();
}
+
}
})
},
@@ -116,6 +124,7 @@ L.TaxiwaySegment = L.Polyline.extend({
if (this.options.attributes.isPushBackRoute) {
style.color = 'magenta';
}
+ console.log("isPushBackRoute ", this.options.attributes.isPushBackRoute);
this.setStyle(style);
if (!this.bidirectional) {
this.setText(' ► ', {repeat: true, attributes: {fill: 'red', size: 20}})
diff --git a/src/renderer/loaders/TaxiwaySegmentExtender.js b/src/renderer/loaders/TaxiwaySegmentExtender.js
index 52c267a..21aa06e 100644
--- a/src/renderer/loaders/TaxiwaySegmentExtender.js
+++ b/src/renderer/loaders/TaxiwaySegmentExtender.js
@@ -1,5 +1,6 @@
/* eslint-disable */
var L = require('leaflet');
+const store = require('../store');
exports.extendTaxiSegment = function (taxiwaySegment) {
taxiwaySegment.__proto__.begin;
diff --git a/src/renderer/loaders/groundnet_loader.js b/src/renderer/loaders/groundnet_loader.js
index ca59735..fd63fe6 100644
--- a/src/renderer/loaders/groundnet_loader.js
+++ b/src/renderer/loaders/groundnet_loader.js
@@ -19,19 +19,19 @@ var $ = require('jquery');
var featureLookup = {};
exports.addFeature = function (feature) {
- featureLookup[feature.id] = new Array();
+ featureLookup[feature.id] = new Array();
}
exports.readGroundnetXML = function (fDir, icao, force) {
- try {
+ try {
layerGroup = L.layerGroup();
- layerGroup.maxId = 0;
- var f = path.join(fDir, icao[0], icao[1], icao[2], icao + '.groundnet.xml');
- var fNew = path.join(fDir, icao[0], icao[1], icao[2], icao + '.groundnet.new.xml');
+ layerGroup.maxId = 0;
+ var f = path.join(fDir, icao[0], icao[1], icao[2], icao + '.groundnet.xml');
+ var fNew = path.join(fDir, icao[0], icao[1], icao[2], icao + '.groundnet.new.xml');
if (f == null || !fs.existsSync(f))
return;
- if(fNew != null && fs.existsSync(fNew) && !force) {
+ if (fNew != null && fs.existsSync(fNew) && !force) {
f = fNew;
}
@@ -56,7 +56,7 @@ exports.readGroundnetXML = function (fDir, icao, force) {
var nodesLookup = {};
parkingNodes.map(n => {
- var circle = parkingSpot(n, layerGroup);
+ var circle = parkingSpot(n, layerGroup);
nodesLookup[n.attr('index')] = n;
featureLookup[n.attr('index')] = new Array();
featureLookup[n.attr('index')].push(circle);
@@ -74,12 +74,13 @@ exports.readGroundnetXML = function (fDir, icao, force) {
layerGroup.maxId = Math.max(layerGroup.maxId, Number(n.attr('index')))
nodesLookup[n.attr('index')] = n;
if (n.attr('isOnRunway') === '1') {
- var rNode = runwayNode(n, layerGroup);
- if(featureLookup[rNode.id] === undefined) {
- featureLookup[rNode.id] = [];
+ var rNode = runwayNode(n, layerGroup);
+ if (featureLookup[rNode.glueindex] === undefined) {
+ featureLookup[rNode.glueindex] = [];
}
- featureLookup[rNode.id].push(rNode);
+ featureLookup[rNode.glueindex].push(rNode);
}
+ //store.default.dispatch('setNode', n)
}).sort();
@@ -108,28 +109,46 @@ exports.readGroundnetXML = function (fDir, icao, force) {
if (!bidirectional) {
var beginlatlon = convert(begin.attr('lat') + " " + begin.attr('lon'));
var endlatlon = convert(end.attr('lat') + " " + end.attr('lon'));
- const polyline = new L.TaxiwaySegment([[beginlatlon.decimalLatitude, beginlatlon.decimalLongitude], [endlatlon.decimalLatitude, endlatlon.decimalLongitude]], {}).addTo(layerGroup);
- $.each( n.attrs, function( key, value ) {
- console.log( key + "\t" + value);
-
- if(isNaN(value))
- polyline.options.attributes[ key ] = value;
+ var polyline = new L.TaxiwaySegment([[beginlatlon.decimalLatitude, beginlatlon.decimalLongitude], [endlatlon.decimalLatitude, endlatlon.decimalLongitude]], { attributes: {} }).addTo(layerGroup);
+ polyline._latlngs[0].attributes = {};
+ $.each(begin.attrs, function (key, value) {
+ console.log(key + "\t" + value);
+
+ if (isNaN(value))
+ polyline._latlngs[0].attributes[key] = value;
else
- polyline.options.attributes[ key ] = Number( value);
- });
+ polyline._latlngs[0].attributes[key] = Number(value);
+ });
+ polyline._latlngs[1].attributes = {};
+ $.each(end.attrs, function (key, value) {
+ console.log(key + "\t" + value);
+
+ if (isNaN(value))
+ polyline._latlngs[1].attributes[key] = value;
+ else
+ polyline._latlngs[1].attributes[key] = Number(value);
+ });
+ $.each(n.attrs, function (key, value) {
+ console.log(key + "\t" + value);
+
+ if (isNaN(value))
+ polyline.options.attributes[key] = value;
+ else
+ polyline.options.attributes[key] = Number(value);
+ });
polyline.updateStyle();
-
+
polyline.begin = begin.attr('index');
polyline.end = end.attr('index');
// polyline.enableEdit();
// polyline.on('dblclick', function (event) { L.DomEvent.stop; polyline.toggleEdit; });
- if(featureLookup[n.attr('begin')] == undefined) {
- featureLookup[n.attr('begin')] = [];
+ if (featureLookup[n.attr('begin')] == undefined) {
+ featureLookup[n.attr('begin')] = [];
}
- if(featureLookup[n.attr('end')] == undefined) {
- featureLookup[n.attr('end')] = [];
+ if (featureLookup[n.attr('end')] == undefined) {
+ featureLookup[n.attr('end')] = [];
}
featureLookup[n.attr('begin')].push(polyline);
featureLookup[n.attr('end')].push(polyline);
diff --git a/src/renderer/loaders/groundnet_writer.js b/src/renderer/loaders/groundnet_writer.js
index 30859ff..13c890c 100644
--- a/src/renderer/loaders/groundnet_writer.js
+++ b/src/renderer/loaders/groundnet_writer.js
@@ -47,10 +47,12 @@ exports.writeGroundnetXML = function (fDir, icao, featureList) {
}
});
// New segments
- featureList.filter(o => o instanceof L.Polyline).filter(n => n).forEach(element => {
+ featureList.filter(o => o instanceof L.Polyline).filter(n => n).forEach(arcElement => {
// element._latlngs.forEach(latlng => { nodes[latlng.__vertex.glueindex] = mapVertexNode(latlng) });
var startIndex = -1;
- element._latlngs.forEach(latlng => {
+ console.log(arcElement.options.attributes);
+ var currentArc = arcElement.options.attributes;
+ arcElement._latlngs.forEach( latlng => {
if (latlng.__vertex !== undefined && latlng.__vertex.glueindex !== undefined) {
nodes[latlng.__vertex.glueindex] = mapVertexNode(latlng);
if (startIndex > 0) {
@@ -61,9 +63,11 @@ exports.writeGroundnetXML = function (fDir, icao, featureList) {
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;
}
@@ -149,7 +153,7 @@ var mapBeginNode = function (o) {
if (o instanceof L.TaxiwaySegment) {
console.log(o);
//
- return { '@index': String(o['begin']), '@lat': convertLat(o._latlngs[0]), '@lon': convertLon(o._latlngs[0]), '@isOnRunway': '0' };
+ return { '@index': String(o['begin']), '@lat': convertLat(o._latlngs[0]), '@lon': convertLon(o._latlngs[0]), '@isOnRunway': '0', '@type': 'begin' };
}
}
@@ -157,7 +161,7 @@ var mapEndNode = function (o) {
if (o instanceof L.TaxiwaySegment) {
console.log(o);
//
- return { '@index': String(o['end']), '@lat': convertLat(o._latlngs[1]), '@lon': convertLon(o._latlngs[1]), '@isOnRunway': '0' };
+ return { '@index': String(o['end']), '@lat': convertLat(o._latlngs[1]), '@lon': convertLon(o._latlngs[1]), '@isOnRunway': '0', '@type': 'end' };
}
}
@@ -165,7 +169,7 @@ var mapVertexNode = function (l) {
if (l instanceof L.LatLng) {
console.log(l);
//
- return { '@index': String(l.__vertex.glueindex), '@lat': convertLat(l), '@lon': convertLon(l) };
+ return { '@index': String(l.__vertex.glueindex), '@lat': convertLat(l), '@lon': convertLon(l), '@isOnRunway': '0', '@holdPointType': l.attributes['holdPointType'] };
}
}
@@ -185,4 +189,16 @@ var convertLon = function (latlng) {
var min = (mathjs.abs(latlng.lng) - deg) * 60;
// console.log(NS + deg + " " + min);
return NS + String(deg).padStart(2, '0') + " " + mathjs.round(min, 3);
+}
+
+var styleArc = function (attributes, arc) {
+ console.log(attributes);
+ if(attributes !== undefined){
+ if (attributes.isPushBackRoute !== undefined && Number(attributes.isPushBackRoute) === 1 ) {
+ arc['@isPushBackRoute'] = "1";
+ } else {
+ arc['@isPushBackRoute'] = "0";
+ }
+ arc['@name'] = attributes.name;
+ }
}
\ No newline at end of file
diff --git a/src/renderer/store/modules/Editable.js b/src/renderer/store/modules/Editable.js
index 850092a..8ca5f7b 100644
--- a/src/renderer/store/modules/Editable.js
+++ b/src/renderer/store/modules/Editable.js
@@ -1,7 +1,7 @@
const state = {
type: 'none',
index: 'none',
- data: {airports: {}, parking: {}, arc: {}}
+ data: {airports: {}, parking: {}, arc: {}, nodes: {}}
}
const SET_EDIT_AIRPORT = 'SET_EDIT_AIRPORT'
@@ -19,6 +19,11 @@ const mutations = {
state.index = parking.index
state.type = 'parking'
},
+ 'SET_EDIT_NODE' (state, node) {
+ state.data.nodes[node.index] = node
+ state.index = node.index
+ state.type = 'node'
+ },
SET_EDIT_ARC (state, arc) {
state.data.arc = arc
state.type = 'arc'
@@ -37,6 +42,9 @@ const actions = {
},
async setArc (context, arc) {
context.commit(SET_EDIT_ARC, arc)
+ },
+ async setNode (context, node) {
+ context.commit('SET_EDIT_NODE', node)
}
}