Holdpoint nodes

This commit is contained in:
portree_kid
2020-02-06 20:06:38 +01:00
parent cbc5e14531
commit 00aac46a27
12 changed files with 136 additions and 14 deletions
+88
View File
@@ -0,0 +1,88 @@
/* eslint-disable */
const convert = require('geo-coordinates-parser');
const leaflet = require('leaflet');
const turf = require('@turf/turf');
const util = require('util');
const store = require('../store');
var $ = require('jquery');
L.HoldNode = L.Marker.extend({
addListeners: function () {
this.on('editable:drawing:move', function (event) {
console.log("Move : ", event);
// Is it the edit vertex (Middle) moving?
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.HoldNode) {
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();
}
}
})
}
});
var holdNode = function (n, layerGroup) {
//console.log(n.attr('lat') + " " + n.attr('lon'));
var latlon = convert(n.attr('lat') + " " + n.attr('lon'));
const icon = new L.DivIcon({
className: 'custom-div-icon',
html: "<div style='background-color:#4838cc;' class='marker-pin'></div><i class='fas fa-hand-paper'></i>",
iconSize: [30, 42],
iconAnchor: [15, 42]
});
const node = new L.HoldNode([latlon.decimalLatitude, latlon.decimalLongitude], { icon: icon });
node.glueindex = n.attr('index');
node.holdPointType = n.attr('holdPointType');
node.addTo(layerGroup);
node.addListeners();
return node;
}
module.exports = holdNode;
+1 -1
View File
@@ -134,7 +134,7 @@ L.ParkingSpot = L.Circle.extend({
follow (dragIndex, event) {
this.featureLookup[dragIndex].forEach(element => {
if(element !== event.target){
if (element instanceof L.RunwayNode) {
if (element instanceof L.HoldNode) {
element.setLatLng(event.latlng);
}
else if (element instanceof L.ParkingSpot) {
+1 -4
View File
@@ -27,7 +27,7 @@ L.RunwayNode = L.Marker.extend({
follow(dragIndex, event) {
this.featureLookup[dragIndex].forEach(element => {
if (element !== event.target) {
if (element instanceof L.RunwayNode) {
if (element instanceof L.HoldNode) {
element.setLatLng(event.latlng);
}
else if (element instanceof L.ParkingSpot) {
@@ -69,10 +69,7 @@ L.RunwayNode = L.Marker.extend({
});
var runwayNode = function (n, layerGroup) {
//console.log(n.attr('lat') + " " + n.attr('lon'));
var latlon = convert(n.attr('lat') + " " + n.attr('lon'));
//console.log(latlon.decimalLatitude);
//console.log(convert(n.attr('lat') + " " + n.attr('lon')).decimalLongitude);
const icon = new L.DivIcon({
className: 'custom-div-icon',
html: "<div style='background-color:#4838cc;' class='marker-pin'></div><i class='fas fa-plane-departure'></i>",
+3
View File
@@ -88,6 +88,9 @@ L.TaxiwaySegment = L.Polyline.extend({
if (element instanceof L.RunwayNode) {
element.setLatLng(event.latlng);
}
else if (element instanceof L.HoldNode) {
element.setLatLng(event.latlng);
}
else if (element instanceof L.ParkingSpot) {
// element.disableEdit();
element.setLatLng(event.latlng);
@@ -85,6 +85,9 @@ exports.extendTaxiSegment = function (taxiwaySegment) {
if (element instanceof L.RunwayNode) {
element.setLatLng(event.latlng);
}
else if (element instanceof L.HoldNode) {
element.setLatLng(event.latlng);
}
else if (element instanceof L.ParkingSpot) {
// element.disableEdit();
element.setLatLng(event.latlng);
+8
View File
@@ -9,6 +9,7 @@ const TaxiwaySegment = require('./TaxiwaySegment');
const parkingSpot = require('./ParkingSpot.js');
const runwayNode = require('./RunwayNode.js');
const holdNode = require('./HoldNode.js');
const store = require('../store');
@@ -81,6 +82,13 @@ exports.readGroundnetXML = function (fDir, icao, force) {
}
featureLookup[rNode.glueindex].push(rNode);
}
if (n.attr('holdPointType') !== 'none' && n.attr('holdPointType') !== null) {
var hNode = holdNode(n, layerGroup);
if (featureLookup[hNode.glueindex] === undefined) {
featureLookup[hNode.glueindex] = [];
}
featureLookup[hNode.glueindex].push(hNode);
}
//store.default.dispatch('setNode', n)
}).sort();
+5 -2
View File
@@ -103,14 +103,17 @@ var mapParkings = function (o) {
var lat = convertLat(o.getLatLng());
var lon = convertLon(o.getLatLng());
// <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['id']), '@type': o.options.attributes.type, '@name': o.options.attributes.name, '@lat': lat, '@lon': lon, '@heading': Number(o.options.attributes.heading), '@radius': String(o.options.radius) };
return { '@index': String(o['id']), '@type': o.options.attributes.type, '@name': o.options.attributes.name, '@lat': lat, '@lon': lon, '@heading': Number(o.options.attributes.heading), '@radius': String(o.options.attributes.radius) };
}
}
var mapRunwayNodes = function (o) {
console.log(o);
if (o instanceof L.RunwayNode) {
return { '@index': String(o['glueindex']), '@lat': convertLat(o._latlng), '@lon': convertLon(o._latlng), '@isOnRunway': '1' };
return { '@index': String(o['glueindex']), '@lat': convertLat(o._latlng), '@lon': convertLon(o._latlng), '@isOnRunway': '1', '@holdPointType': 'none' };
}
if (o instanceof L.HoldNode) {
return { '@index': String(o['glueindex']), '@lat': convertLat(o._latlng), '@lon': convertLon(o._latlng), '@isOnRunway': '0', '@holdPointType': o['holdPointType'] };
}
}