portree_kid 2020-08-24 14:29:48 +02:00
parent 2ff284df5c
commit 939322471d
3 changed files with 122 additions and 68 deletions

View File

@ -56,7 +56,7 @@ You should have received a copy of the GNU General Public License along with FG
<el-popover <el-popover
placement="top-start" placement="top-start"
title="Description" title="Description"
width="200" width="50"
trigger="hover" trigger="hover"
content="Edit" content="Edit"
> >

View File

@ -5,7 +5,7 @@ var L = require('leaflet');
const store = require('../store'); const store = require('../store');
const util = require('util'); const util = require('util');
exports.extendTaxiSegment = function (taxiwaySegment) { const extendTaxiSegment = function (taxiwaySegment) {
taxiwaySegment.__proto__.begin; taxiwaySegment.__proto__.begin;
taxiwaySegment.__proto__.end; taxiwaySegment.__proto__.end;
taxiwaySegment.__proto__.bidirectional; taxiwaySegment.__proto__.bidirectional;
@ -145,8 +145,12 @@ exports.extendTaxiSegment = function (taxiwaySegment) {
this.follow(dragIndex, event); this.follow(dragIndex, event);
} }
}); });
this.on('editable:middlemarker:mousedown', event => {
console.debug('editable:middlemarker:mousedown' + util.inspect(event));
} ),
this.on('editable:vertex:new', event => { this.on('editable:vertex:new', event => {
console.debug('editable:vertex:new ' + util.inspect(event));
console.debug('editable:vertex:new ' + event.vertex.getIndex() + '\t' + event.vertex.getLastIndex() + '\t');
// Find nearest node // Find nearest node
let closest = this.editLayer.closestLayerSnap(event.latlng, 5) let closest = this.editLayer.closestLayerSnap(event.latlng, 5)
let taxiwaySegment = event.latlng.__vertex.editor.feature; let taxiwaySegment = event.latlng.__vertex.editor.feature;
@ -154,6 +158,41 @@ exports.extendTaxiSegment = function (taxiwaySegment) {
taxiwaySegment.options.attributes = { direction: 'bi-directional' }; taxiwaySegment.options.attributes = { direction: 'bi-directional' };
} }
taxiwaySegment.updateStyle(); taxiwaySegment.updateStyle();
if(event.vertex.getIndex() !== 0 && event.vertex.getIndex() !== event.vertex.getLastIndex()) {
var nextIndex = ++taxiwaySegment.editLayer.groundnetLayerGroup.maxId;
var splitOffNodes = taxiwaySegment.getLatLngs().splice(-1);
var remainingNodes = taxiwaySegment.getLatLngs();
splitOffNodes.unshift(L.latLng(remainingNodes[1].lat, remainingNodes[1].lng, remainingNodes[1].alt));
remainingNodes[1]['glueindex'] = nextIndex;
remainingNodes[1].attributes = { index: nextIndex, isOnRunway: 0 };
taxiwaySegment.options.attributes.end = nextIndex;
splitOffNodes[0]['glueindex'] = nextIndex;
splitOffNodes[0].attributes = { index: nextIndex, isOnRunway: 0 };
taxiwaySegment.setLatLngs(remainingNodes);
//taxiwaySegment.editor.refresh();
//taxiwaySegment.editor.reset();
if( splitOffNodes.length>1) {
var polyline = new L.Polyline(splitOffNodes, { attributes: {} });
polyline.addTo(taxiwaySegment.editLayer.groundnetLayerGroup);
extendTaxiSegment(polyline);
polyline.addListeners();
polyline.setEditlayer(taxiwaySegment.editLayer);
polyline.enableEdit();
//polyline.editor.refresh();
//polyline.editor.reset();
polyline.featureLookup = this.featureLookup;
polyline.options.attributes.name = taxiwaySegment.options.attributes.name;
polyline.options.attributes.direction = taxiwaySegment.options.attributes.direction;
polyline.options.attributes.begin = nextIndex;
polyline.options.attributes.end = taxiwaySegment.end;
polyline.begin = nextIndex;
polyline.end = taxiwaySegment.end;
taxiwaySegment.end = nextIndex;
this.editLayer.featureLookup[nextIndex] = [];
this.featureLookup[nextIndex].push(taxiwaySegment);
this.featureLookup[nextIndex].push(polyline);
}
} else {
// Glue to another node // Glue to another node
if (closest) { if (closest) {
event.latlng['glueindex'] = Number(closest.glueindex); event.latlng['glueindex'] = Number(closest.glueindex);
@ -189,6 +228,7 @@ exports.extendTaxiSegment = function (taxiwaySegment) {
taxiwaySegment.end = Number(event.vertex.latlng.glueindex); taxiwaySegment.end = Number(event.vertex.latlng.glueindex);
} }
} }
}
//this.splitShape(taxiwaySegment.getLatLngs(), ) //this.splitShape(taxiwaySegment.getLatLngs(), )
}); });
this.on('editable:vertex:deleted', event => { this.on('editable:vertex:deleted', event => {
@ -253,6 +293,7 @@ exports.extendTaxiSegment = function (taxiwaySegment) {
}); });
this.on('editable:vertex:dragend', function (event) { this.on('editable:vertex:dragend', function (event) {
console.log("Dragend : ", event.vertex); console.log("Dragend : ", event.vertex);
try {
if (dragIndex > 0) { if (dragIndex > 0) {
event.target.featureLookup[dragIndex].forEach(element => { event.target.featureLookup[dragIndex].forEach(element => {
if (element instanceof L.ParkingSpot) { if (element instanceof L.ParkingSpot) {
@ -284,7 +325,9 @@ exports.extendTaxiSegment = function (taxiwaySegment) {
}); });
}) })
} }
} catch (error) {
console.error(error);
}
}); });
}; };
/** /**
@ -365,3 +408,5 @@ exports.extendTaxiSegment = function (taxiwaySegment) {
} }
}; };
}; };
exports.extendTaxiSegment = extendTaxiSegment;

View File

@ -85,8 +85,12 @@ exports.writeGroundnetXML = function (fDir, icao, featureList) {
// Loaded segments // Loaded segments
featureList.filter(o => o instanceof L.TaxiwaySegment).filter(n => n).forEach(element => { featureList.filter(o => o instanceof L.TaxiwaySegment).filter(n => n).forEach(element => {
var begin = mapBeginNode(element); var begin = mapBeginNode(element);
if(begin['@index']==="")
console.warn("Begin missing");
nodes[begin['@index']] = begin; nodes[begin['@index']] = begin;
var end = mapEndNode(element); var end = mapEndNode(element);
if(end['@index']==="")
console.warn("End missing");
nodes[end['@index']] = end; nodes[end['@index']] = end;
}); });
// New segments // New segments
@ -117,8 +121,13 @@ exports.writeGroundnetXML = function (fDir, icao, featureList) {
arcList.push(arc); arcList.push(arc);
featureLookup[latlng.glueindex][startIndex] = arc; featureLookup[latlng.glueindex][startIndex] = arc;
} }
if (currentArc.direction === '' || !currentArc.direction) {
console.error( "Arc without direction " + util.inspect(currentArc) );
}
} }
startIndex = latlng.glueindex; startIndex = latlng.glueindex;
} else {
console.error( "LatLng without glueindex " + util.inspect(latlng) );
} }
}); });
}); });
@ -241,7 +250,7 @@ var mapVertexNode = function (l) {
} }
var convertLat = function (latlng) { var convertLat = function (latlng) {
console.debug(latlng.lat); //console.debug(latlng.lat);
var NS = latlng.lat > 0 ? 'N' : 'S'; var NS = latlng.lat > 0 ? 'N' : 'S';
var deg = mathjs.floor(mathjs.abs(latlng.lat)); var deg = mathjs.floor(mathjs.abs(latlng.lat));
var min = (mathjs.abs(latlng.lat) - deg) * 60; var min = (mathjs.abs(latlng.lat) - deg) * 60;
@ -250,7 +259,7 @@ var convertLat = function (latlng) {
} }
var convertLon = function (latlng) { var convertLon = function (latlng) {
console.debug(latlng.lng); //console.debug(latlng.lng);
var NS = latlng.lng > 0 ? 'E' : 'W'; var NS = latlng.lng > 0 ? 'E' : 'W';
var deg = mathjs.floor(mathjs.abs(latlng.lng)); var deg = mathjs.floor(mathjs.abs(latlng.lng));
var min = (mathjs.abs(latlng.lng) - deg) * 60; var min = (mathjs.abs(latlng.lng) - deg) * 60;
@ -259,7 +268,7 @@ var convertLon = function (latlng) {
} }
var styleArc = function (attributes, arc) { var styleArc = function (attributes, arc) {
console.debug(attributes); //console.debug(attributes);
if(attributes !== undefined){ if(attributes !== undefined){
if (attributes.isPushBackRoute !== undefined && Number(attributes.isPushBackRoute) === 1 ) { if (attributes.isPushBackRoute !== undefined && Number(attributes.isPushBackRoute) === 1 ) {
arc['@isPushBackRoute'] = "1"; arc['@isPushBackRoute'] = "1";