|
|
|
@ -5,7 +5,7 @@ var L = require('leaflet');
|
|
|
|
|
const store = require('../store');
|
|
|
|
|
const util = require('util');
|
|
|
|
|
|
|
|
|
|
exports.extendTaxiSegment = function (taxiwaySegment) {
|
|
|
|
|
const extendTaxiSegment = function (taxiwaySegment) {
|
|
|
|
|
taxiwaySegment.__proto__.begin;
|
|
|
|
|
taxiwaySegment.__proto__.end;
|
|
|
|
|
taxiwaySegment.__proto__.bidirectional;
|
|
|
|
@ -145,8 +145,12 @@ exports.extendTaxiSegment = function (taxiwaySegment) {
|
|
|
|
|
this.follow(dragIndex, event);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.on('editable:middlemarker:mousedown', event => {
|
|
|
|
|
console.debug('editable:middlemarker:mousedown' + util.inspect(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
|
|
|
|
|
let closest = this.editLayer.closestLayerSnap(event.latlng, 5)
|
|
|
|
|
let taxiwaySegment = event.latlng.__vertex.editor.feature;
|
|
|
|
@ -154,6 +158,41 @@ exports.extendTaxiSegment = function (taxiwaySegment) {
|
|
|
|
|
taxiwaySegment.options.attributes = { direction: 'bi-directional' };
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
if (closest) {
|
|
|
|
|
event.latlng['glueindex'] = Number(closest.glueindex);
|
|
|
|
@ -189,6 +228,7 @@ exports.extendTaxiSegment = function (taxiwaySegment) {
|
|
|
|
|
taxiwaySegment.end = Number(event.vertex.latlng.glueindex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//this.splitShape(taxiwaySegment.getLatLngs(), )
|
|
|
|
|
});
|
|
|
|
|
this.on('editable:vertex:deleted', event => {
|
|
|
|
@ -253,6 +293,7 @@ exports.extendTaxiSegment = function (taxiwaySegment) {
|
|
|
|
|
});
|
|
|
|
|
this.on('editable:vertex:dragend', function (event) {
|
|
|
|
|
console.log("Dragend : ", event.vertex);
|
|
|
|
|
try {
|
|
|
|
|
if (dragIndex > 0) {
|
|
|
|
|
event.target.featureLookup[dragIndex].forEach(element => {
|
|
|
|
|
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;
|