Glued Runway Nodes
This commit is contained in:
parent
756791206a
commit
cbb78d7f3d
@ -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)
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -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}})
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* eslint-disable */
|
||||
var L = require('leaflet');
|
||||
const store = require('../store');
|
||||
|
||||
exports.extendTaxiSegment = function (taxiwaySegment) {
|
||||
taxiwaySegment.__proto__.begin;
|
||||
|
@ -31,7 +31,7 @@ exports.readGroundnetXML = function (fDir, icao, force) {
|
||||
|
||||
if (f == null || !fs.existsSync(f))
|
||||
return;
|
||||
if(fNew != null && fs.existsSync(fNew) && !force) {
|
||||
if (fNew != null && fs.existsSync(fNew) && !force) {
|
||||
f = fNew;
|
||||
}
|
||||
|
||||
@ -75,11 +75,12 @@ exports.readGroundnetXML = function (fDir, icao, force) {
|
||||
nodesLookup[n.attr('index')] = n;
|
||||
if (n.attr('isOnRunway') === '1') {
|
||||
var rNode = runwayNode(n, layerGroup);
|
||||
if(featureLookup[rNode.id] === undefined) {
|
||||
featureLookup[rNode.id] = [];
|
||||
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,14 +109,32 @@ 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);
|
||||
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.options.attributes[ key ] = 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();
|
||||
|
||||
@ -125,10 +144,10 @@ exports.readGroundnetXML = function (fDir, icao, force) {
|
||||
|
||||
// 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')] = [];
|
||||
}
|
||||
if(featureLookup[n.attr('end')] == undefined) {
|
||||
if (featureLookup[n.attr('end')] == undefined) {
|
||||
featureLookup[n.attr('end')] = [];
|
||||
}
|
||||
featureLookup[n.attr('begin')].push(polyline);
|
||||
|
@ -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);
|
||||
// <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) {
|
||||
console.log(o);
|
||||
// <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) {
|
||||
console.log(l);
|
||||
// <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);
|
||||
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;
|
||||
}
|
||||
}
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user