Glued Runway Nodes

This commit is contained in:
portree_kid 2020-01-26 22:28:48 +01:00
parent 756791206a
commit cbb78d7f3d
7 changed files with 156 additions and 43 deletions

View File

@ -43,7 +43,7 @@
this.groundnetLayerGroup.removeFrom(this.$parent.mapObject) this.groundnetLayerGroup.removeFrom(this.$parent.mapObject)
} }
this.icao = icao 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) { if (this.groundnetLayerGroup === undefined) {
console.console.error('ICAO not loaded ' + icao) console.console.error('ICAO not loaded ' + icao)
return return
@ -126,19 +126,21 @@
var polyLine = this.$parent.mapObject.editTools.startPolyline() var polyLine = this.$parent.mapObject.editTools.startPolyline()
polyLine.addTo(this.groundnetLayerGroup) polyLine.addTo(this.groundnetLayerGroup)
polyLine.groundnetLayerGroup = this.groundnetLayerGroup; polyLine.groundnetLayerGroup = this.groundnetLayerGroup;
polyLine.attributes = [];
polyLine.on('editable:vertex:new', event => { polyLine.on('editable:vertex:new', event => {
console.log(event) console.log(event)
let closest = this.closestLayerSnap(event.latlng, 10) let closest = this.closestLayerSnap(event.latlng, 10)
if (closest) { if (closest) {
event.latlng.__vertex.glueindex = closest.vertex.glueindex; event.latlng.__vertex.glueindex = closest.glueindex;
event.latlng.__vertex.setLatLng(closest.vertex.latlng); event.latlng.__vertex.setLatLng(closest.latlng);
this.featureLookup[event.latlng.__vertex.glueindex].push(event.latlng.__vertex);
console.log(closest) console.log(closest)
} } else {
else{
event.latlng.__vertex.glueindex = ++this.groundnetLayerGroup.maxId; event.latlng.__vertex.glueindex = ++this.groundnetLayerGroup.maxId;
this.featureLookup[event.latlng.__vertex.glueindex] = []; this.featureLookup[event.latlng.__vertex.glueindex] = [];
} }
event.latlng.attributes = [];
}) })
polyLine.on('editable:drawing:end', event => { polyLine.on('editable:drawing:end', event => {
event.target.featureLookup = this.featureLookup; event.target.featureLookup = this.featureLookup;
@ -152,15 +154,20 @@
var layers = [] var layers = []
this.groundnetLayerGroup.eachLayer((layer) => { this.groundnetLayerGroup.eachLayer((layer) => {
if (layer instanceof L.Polyline) { if (layer instanceof L.Polyline) {
console.log(layer._latlngs) // console.log(layer._latlngs)
layer._latlngs.forEach(latlng => { layer._latlngs.forEach(latlng => {
if (latlng.__vertex) { if (latlng.__vertex) {
let distance = latlng.distanceTo(eventLatlng) let distance = latlng.distanceTo(eventLatlng)
if (distance > 0 && distance < snap) { 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) layers.sort((l1, l2) => l1.d - l2.d)
@ -196,6 +203,7 @@
save () { save () {
var xml = [] var xml = []
this.groundnetLayerGroup.eachLayer(l => { this.groundnetLayerGroup.eachLayer(l => {
console.log(l)
xml.push(l) xml.push(l)
}) })
writeGroundnetXML(this.$store.state.Settings.settings.airportsDirectory, this.icao, xml) writeGroundnetXML(this.$store.state.Settings.settings.airportsDirectory, this.icao, xml)

View File

@ -11,8 +11,60 @@ L.RunwayNode = L.Marker.extend({
this.on('editable:drawing:move', function (event) { this.on('editable:drawing:move', function (event) {
console.log("Move : ", event); console.log("Move : ", event);
// Is it the edit vertex (Middle) moving? // 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();
}
}
})
} }
}); });

View File

@ -1,13 +1,9 @@
/* eslint-disable */ /* eslint-disable */
var L = require('leaflet'); var L = require('leaflet');
const store = require('../store');
L.TaxiwaySegment = L.Polyline.extend({ L.TaxiwaySegment = L.Polyline.extend({
options: {
id: 'Custom data!',
attributes: {}
},
begin: String, begin: String,
end: String, end: String,
bidirectional: Boolean, bidirectional: Boolean,
@ -106,7 +102,19 @@ L.TaxiwaySegment = L.Polyline.extend({
element.updateEndVertex(event.latlng); element.updateEndVertex(event.latlng);
element.updateMiddle(); 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) { if (this.options.attributes.isPushBackRoute) {
style.color = 'magenta'; style.color = 'magenta';
} }
console.log("isPushBackRoute ", this.options.attributes.isPushBackRoute);
this.setStyle(style); this.setStyle(style);
if (!this.bidirectional) { if (!this.bidirectional) {
this.setText(' ► ', {repeat: true, attributes: {fill: 'red', size: 20}}) this.setText(' ► ', {repeat: true, attributes: {fill: 'red', size: 20}})

View File

@ -1,5 +1,6 @@
/* eslint-disable */ /* eslint-disable */
var L = require('leaflet'); var L = require('leaflet');
const store = require('../store');
exports.extendTaxiSegment = function (taxiwaySegment) { exports.extendTaxiSegment = function (taxiwaySegment) {
taxiwaySegment.__proto__.begin; taxiwaySegment.__proto__.begin;

View File

@ -31,7 +31,7 @@ exports.readGroundnetXML = function (fDir, icao, force) {
if (f == null || !fs.existsSync(f)) if (f == null || !fs.existsSync(f))
return; return;
if(fNew != null && fs.existsSync(fNew) && !force) { if (fNew != null && fs.existsSync(fNew) && !force) {
f = fNew; f = fNew;
} }
@ -75,11 +75,12 @@ exports.readGroundnetXML = function (fDir, icao, force) {
nodesLookup[n.attr('index')] = n; nodesLookup[n.attr('index')] = n;
if (n.attr('isOnRunway') === '1') { if (n.attr('isOnRunway') === '1') {
var rNode = runwayNode(n, layerGroup); var rNode = runwayNode(n, layerGroup);
if(featureLookup[rNode.id] === undefined) { if (featureLookup[rNode.glueindex] === undefined) {
featureLookup[rNode.id] = []; featureLookup[rNode.glueindex] = [];
} }
featureLookup[rNode.id].push(rNode); featureLookup[rNode.glueindex].push(rNode);
} }
//store.default.dispatch('setNode', n)
}).sort(); }).sort();
@ -108,14 +109,32 @@ exports.readGroundnetXML = function (fDir, icao, force) {
if (!bidirectional) { if (!bidirectional) {
var beginlatlon = convert(begin.attr('lat') + " " + begin.attr('lon')); var beginlatlon = convert(begin.attr('lat') + " " + begin.attr('lon'));
var endlatlon = convert(end.attr('lat') + " " + end.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); var polyline = new L.TaxiwaySegment([[beginlatlon.decimalLatitude, beginlatlon.decimalLongitude], [endlatlon.decimalLatitude, endlatlon.decimalLongitude]], { attributes: {} }).addTo(layerGroup);
$.each( n.attrs, function( key, value ) { polyline._latlngs[0].attributes = {};
console.log( key + "\t" + value); $.each(begin.attrs, function (key, value) {
console.log(key + "\t" + value);
if(isNaN(value)) if (isNaN(value))
polyline.options.attributes[ key ] = value; polyline._latlngs[0].attributes[key] = value;
else 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.updateStyle();
@ -125,10 +144,10 @@ exports.readGroundnetXML = function (fDir, icao, force) {
// polyline.on('dblclick', function (event) { L.DomEvent.stop; polyline.toggleEdit; }); // polyline.on('dblclick', function (event) { L.DomEvent.stop; polyline.toggleEdit; });
if(featureLookup[n.attr('begin')] == undefined) { if (featureLookup[n.attr('begin')] == undefined) {
featureLookup[n.attr('begin')] = []; featureLookup[n.attr('begin')] = [];
} }
if(featureLookup[n.attr('end')] == undefined) { if (featureLookup[n.attr('end')] == undefined) {
featureLookup[n.attr('end')] = []; featureLookup[n.attr('end')] = [];
} }
featureLookup[n.attr('begin')].push(polyline); featureLookup[n.attr('begin')].push(polyline);

View File

@ -47,10 +47,12 @@ exports.writeGroundnetXML = function (fDir, icao, featureList) {
} }
}); });
// New segments // 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) }); // element._latlngs.forEach(latlng => { nodes[latlng.__vertex.glueindex] = mapVertexNode(latlng) });
var startIndex = -1; 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) { if (latlng.__vertex !== undefined && latlng.__vertex.glueindex !== undefined) {
nodes[latlng.__vertex.glueindex] = mapVertexNode(latlng); nodes[latlng.__vertex.glueindex] = mapVertexNode(latlng);
if (startIndex > 0) { if (startIndex > 0) {
@ -61,9 +63,11 @@ exports.writeGroundnetXML = function (fDir, icao, featureList) {
featureLookup[latlng.__vertex.glueindex] = []; featureLookup[latlng.__vertex.glueindex] = [];
} }
arc = { '@begin': startIndex, '@end': String(latlng.__vertex.glueindex) }; arc = { '@begin': startIndex, '@end': String(latlng.__vertex.glueindex) };
styleArc(currentArc, arc);
arcList.push(arc); arcList.push(arc);
featureLookup[startIndex][latlng.__vertex.glueindex] = arc; featureLookup[startIndex][latlng.__vertex.glueindex] = arc;
arc = { '@begin': String(latlng.__vertex.glueindex), '@end': startIndex }; arc = { '@begin': String(latlng.__vertex.glueindex), '@end': startIndex };
styleArc(currentArc, arc);
arcList.push(arc); arcList.push(arc);
featureLookup[latlng.__vertex.glueindex][startIndex] = arc; featureLookup[latlng.__vertex.glueindex][startIndex] = arc;
} }
@ -149,7 +153,7 @@ var mapBeginNode = function (o) {
if (o instanceof L.TaxiwaySegment) { if (o instanceof L.TaxiwaySegment) {
console.log(o); console.log(o);
// <Parking index="0" type="gate" name="GA_Parking" lat="S9 25.739923" lon="E160 2.927602" heading="67" radius="44" airlineCodes="" /> // <Parking index="0" type="gate" name="GA_Parking" lat="S9 25.739923" lon="E160 2.927602" heading="67" radius="44" airlineCodes="" />
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) { if (o instanceof L.TaxiwaySegment) {
console.log(o); console.log(o);
// <Parking index="0" type="gate" name="GA_Parking" lat="S9 25.739923" lon="E160 2.927602" heading="67" radius="44" airlineCodes="" /> // <Parking index="0" type="gate" name="GA_Parking" lat="S9 25.739923" lon="E160 2.927602" heading="67" radius="44" airlineCodes="" />
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) { if (l instanceof L.LatLng) {
console.log(l); console.log(l);
// <Parking index="0" type="gate" name="GA_Parking" lat="S9 25.739923" lon="E160 2.927602" heading="67" radius="44" airlineCodes="" /> // <Parking index="0" type="gate" name="GA_Parking" lat="S9 25.739923" lon="E160 2.927602" heading="67" radius="44" airlineCodes="" />
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'] };
} }
} }
@ -186,3 +190,15 @@ var convertLon = function (latlng) {
// console.log(NS + deg + " " + min); // console.log(NS + deg + " " + min);
return NS + String(deg).padStart(2, '0') + " " + mathjs.round(min, 3); 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;
}
}

View File

@ -1,7 +1,7 @@
const state = { const state = {
type: 'none', type: 'none',
index: 'none', index: 'none',
data: {airports: {}, parking: {}, arc: {}} data: {airports: {}, parking: {}, arc: {}, nodes: {}}
} }
const SET_EDIT_AIRPORT = 'SET_EDIT_AIRPORT' const SET_EDIT_AIRPORT = 'SET_EDIT_AIRPORT'
@ -19,6 +19,11 @@ const mutations = {
state.index = parking.index state.index = parking.index
state.type = 'parking' 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) { SET_EDIT_ARC (state, arc) {
state.data.arc = arc state.data.arc = arc
state.type = 'arc' state.type = 'arc'
@ -37,6 +42,9 @@ const actions = {
}, },
async setArc (context, arc) { async setArc (context, arc) {
context.commit(SET_EDIT_ARC, arc) context.commit(SET_EDIT_ARC, arc)
},
async setNode (context, node) {
context.commit('SET_EDIT_NODE', node)
} }
} }