This commit is contained in:
parent
2ff284df5c
commit
939322471d
@ -56,7 +56,7 @@ You should have received a copy of the GNU General Public License along with FG
|
||||
<el-popover
|
||||
placement="top-start"
|
||||
title="Description"
|
||||
width="200"
|
||||
width="50"
|
||||
trigger="hover"
|
||||
content="Edit"
|
||||
>
|
||||
|
@ -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,39 +158,75 @@ exports.extendTaxiSegment = function (taxiwaySegment) {
|
||||
taxiwaySegment.options.attributes = { direction: 'bi-directional' };
|
||||
}
|
||||
taxiwaySegment.updateStyle();
|
||||
// Glue to another node
|
||||
if (closest) {
|
||||
event.latlng['glueindex'] = Number(closest.glueindex);
|
||||
event.latlng.__vertex.setLatLng(closest.latlng);
|
||||
event.latlng.attributes = { index: event.latlng.glueindex, isOnRunway: 0 };
|
||||
// Push Vertex to lookup
|
||||
this.editLayer.featureLookup[event.latlng.glueindex].push(event.latlng.__vertex);
|
||||
if (taxiwaySegment.options.attributes.begin === undefined) {
|
||||
taxiwaySegment.options.attributes.begin = event.latlng['glueindex']
|
||||
} else {
|
||||
taxiwaySegment.options.attributes.end = event.latlng['glueindex']
|
||||
}
|
||||
if (taxiwaySegment.getLatLngs().length === 1) {
|
||||
taxiwaySegment.begin = closest.glueindex;
|
||||
}
|
||||
taxiwaySegment.end = closest.glueindex;
|
||||
console.log(`Closest : ${closest}`)
|
||||
} else {
|
||||
event.vertex.latlng['glueindex'] = ++this.editLayer.groundnetLayerGroup.maxId;
|
||||
event.vertex.latlng.attributes = { index: event.vertex.latlng.glueindex, isOnRunway: 0 };
|
||||
this.editLayer.featureLookup[event.vertex.latlng.glueindex] = [];
|
||||
this.editLayer.featureLookup[event.vertex.latlng.glueindex].push(event.vertex);
|
||||
this.editLayer.featureLookup[event.vertex.latlng.glueindex].push(taxiwaySegment);
|
||||
// taxiwaySegment.editor.refresh();
|
||||
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 (taxiwaySegment.options.attributes.begin === undefined) {
|
||||
taxiwaySegment.options.attributes.begin = event.vertex.latlng['glueindex']
|
||||
taxiwaySegment.begin = event.vertex.latlng.glueindex;
|
||||
} else if (taxiwaySegment.options.attributes.end === undefined ||
|
||||
(taxiwaySegment.getLatLngs()[taxiwaySegment.getLatLngs().length - 1].glueindex &&
|
||||
Number(taxiwaySegment.getLatLngs()[taxiwaySegment.getLatLngs().length - 1].glueindex) !== taxiwaySegment.options.attributes.end)) {
|
||||
taxiwaySegment.options.attributes.end = event.vertex.latlng['glueindex']
|
||||
taxiwaySegment.end = Number(event.vertex.latlng.glueindex);
|
||||
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);
|
||||
event.latlng.__vertex.setLatLng(closest.latlng);
|
||||
event.latlng.attributes = { index: event.latlng.glueindex, isOnRunway: 0 };
|
||||
// Push Vertex to lookup
|
||||
this.editLayer.featureLookup[event.latlng.glueindex].push(event.latlng.__vertex);
|
||||
if (taxiwaySegment.options.attributes.begin === undefined) {
|
||||
taxiwaySegment.options.attributes.begin = event.latlng['glueindex']
|
||||
} else {
|
||||
taxiwaySegment.options.attributes.end = event.latlng['glueindex']
|
||||
}
|
||||
if (taxiwaySegment.getLatLngs().length === 1) {
|
||||
taxiwaySegment.begin = closest.glueindex;
|
||||
}
|
||||
taxiwaySegment.end = closest.glueindex;
|
||||
console.log(`Closest : ${closest}`)
|
||||
} else {
|
||||
event.vertex.latlng['glueindex'] = ++this.editLayer.groundnetLayerGroup.maxId;
|
||||
event.vertex.latlng.attributes = { index: event.vertex.latlng.glueindex, isOnRunway: 0 };
|
||||
this.editLayer.featureLookup[event.vertex.latlng.glueindex] = [];
|
||||
this.editLayer.featureLookup[event.vertex.latlng.glueindex].push(event.vertex);
|
||||
this.editLayer.featureLookup[event.vertex.latlng.glueindex].push(taxiwaySegment);
|
||||
// taxiwaySegment.editor.refresh();
|
||||
//taxiwaySegment.editor.reset();
|
||||
if (taxiwaySegment.options.attributes.begin === undefined) {
|
||||
taxiwaySegment.options.attributes.begin = event.vertex.latlng['glueindex']
|
||||
taxiwaySegment.begin = event.vertex.latlng.glueindex;
|
||||
} else if (taxiwaySegment.options.attributes.end === undefined ||
|
||||
(taxiwaySegment.getLatLngs()[taxiwaySegment.getLatLngs().length - 1].glueindex &&
|
||||
Number(taxiwaySegment.getLatLngs()[taxiwaySegment.getLatLngs().length - 1].glueindex) !== taxiwaySegment.options.attributes.end)) {
|
||||
taxiwaySegment.options.attributes.end = event.vertex.latlng['glueindex']
|
||||
taxiwaySegment.end = Number(event.vertex.latlng.glueindex);
|
||||
}
|
||||
}
|
||||
}
|
||||
//this.splitShape(taxiwaySegment.getLatLngs(), )
|
||||
@ -253,38 +293,41 @@ exports.extendTaxiSegment = function (taxiwaySegment) {
|
||||
});
|
||||
this.on('editable:vertex:dragend', function (event) {
|
||||
console.log("Dragend : ", event.vertex);
|
||||
if (dragIndex > 0) {
|
||||
event.target.featureLookup[dragIndex].forEach(element => {
|
||||
if (element instanceof L.ParkingSpot) {
|
||||
//element.setLatLng(event);
|
||||
console.log(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
dragIndex = -1;
|
||||
var parking = this.featureLookup[event.vertex.latlng.glueindex].filter(n => n instanceof L.ParkingSpot);
|
||||
if (parking.length > 0) {
|
||||
parking[0].selectParking();
|
||||
} else {
|
||||
if( Number(event.vertex.latlng.glueindex) !== store.default.state.Editable.index) {
|
||||
if (Number(store.default.state.Editable.index) >= 0 &&
|
||||
this.featureLookup[store.default.state.Editable.index] !== undefined) {
|
||||
this.featureLookup[store.default.state.Editable.index].forEach(element => {
|
||||
if(element.deselect !== undefined) {
|
||||
element.deselect();
|
||||
}
|
||||
});
|
||||
}
|
||||
store.default.dispatch('setNode', event.vertex.latlng)
|
||||
}
|
||||
var lines = this.featureLookup[event.vertex.latlng.glueindex].filter(n => n instanceof L.Polyline);
|
||||
Vue.default.nextTick(function () {
|
||||
lines.forEach( line => {
|
||||
line.selectVertex(store.default.state.Editable.index)
|
||||
try {
|
||||
if (dragIndex > 0) {
|
||||
event.target.featureLookup[dragIndex].forEach(element => {
|
||||
if (element instanceof L.ParkingSpot) {
|
||||
//element.setLatLng(event);
|
||||
console.log(element);
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
dragIndex = -1;
|
||||
var parking = this.featureLookup[event.vertex.latlng.glueindex].filter(n => n instanceof L.ParkingSpot);
|
||||
if (parking.length > 0) {
|
||||
parking[0].selectParking();
|
||||
} else {
|
||||
if( Number(event.vertex.latlng.glueindex) !== store.default.state.Editable.index) {
|
||||
if (Number(store.default.state.Editable.index) >= 0 &&
|
||||
this.featureLookup[store.default.state.Editable.index] !== undefined) {
|
||||
this.featureLookup[store.default.state.Editable.index].forEach(element => {
|
||||
if(element.deselect !== undefined) {
|
||||
element.deselect();
|
||||
}
|
||||
});
|
||||
}
|
||||
store.default.dispatch('setNode', event.vertex.latlng)
|
||||
}
|
||||
var lines = this.featureLookup[event.vertex.latlng.glueindex].filter(n => n instanceof L.Polyline);
|
||||
Vue.default.nextTick(function () {
|
||||
lines.forEach( line => {
|
||||
line.selectVertex(store.default.state.Editable.index)
|
||||
});
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
/**
|
||||
@ -365,3 +408,5 @@ exports.extendTaxiSegment = function (taxiwaySegment) {
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
exports.extendTaxiSegment = extendTaxiSegment;
|
@ -85,8 +85,12 @@ exports.writeGroundnetXML = function (fDir, icao, featureList) {
|
||||
// Loaded segments
|
||||
featureList.filter(o => o instanceof L.TaxiwaySegment).filter(n => n).forEach(element => {
|
||||
var begin = mapBeginNode(element);
|
||||
if(begin['@index']==="")
|
||||
console.warn("Begin missing");
|
||||
nodes[begin['@index']] = begin;
|
||||
var end = mapEndNode(element);
|
||||
if(end['@index']==="")
|
||||
console.warn("End missing");
|
||||
nodes[end['@index']] = end;
|
||||
});
|
||||
// New segments
|
||||
@ -117,8 +121,13 @@ exports.writeGroundnetXML = function (fDir, icao, featureList) {
|
||||
arcList.push(arc);
|
||||
featureLookup[latlng.glueindex][startIndex] = arc;
|
||||
}
|
||||
if (currentArc.direction === '' || !currentArc.direction) {
|
||||
console.error( "Arc without direction " + util.inspect(currentArc) );
|
||||
}
|
||||
}
|
||||
startIndex = latlng.glueindex;
|
||||
} else {
|
||||
console.error( "LatLng without glueindex " + util.inspect(latlng) );
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -241,7 +250,7 @@ var mapVertexNode = function (l) {
|
||||
}
|
||||
|
||||
var convertLat = function (latlng) {
|
||||
console.debug(latlng.lat);
|
||||
//console.debug(latlng.lat);
|
||||
var NS = latlng.lat > 0 ? 'N' : 'S';
|
||||
var deg = mathjs.floor(mathjs.abs(latlng.lat));
|
||||
var min = (mathjs.abs(latlng.lat) - deg) * 60;
|
||||
@ -250,7 +259,7 @@ var convertLat = function (latlng) {
|
||||
}
|
||||
|
||||
var convertLon = function (latlng) {
|
||||
console.debug(latlng.lng);
|
||||
//console.debug(latlng.lng);
|
||||
var NS = latlng.lng > 0 ? 'E' : 'W';
|
||||
var deg = mathjs.floor(mathjs.abs(latlng.lng));
|
||||
var min = (mathjs.abs(latlng.lng) - deg) * 60;
|
||||
@ -259,7 +268,7 @@ var convertLon = function (latlng) {
|
||||
}
|
||||
|
||||
var styleArc = function (attributes, arc) {
|
||||
console.debug(attributes);
|
||||
//console.debug(attributes);
|
||||
if(attributes !== undefined){
|
||||
if (attributes.isPushBackRoute !== undefined && Number(attributes.isPushBackRoute) === 1 ) {
|
||||
arc['@isPushBackRoute'] = "1";
|
||||
|
Loading…
Reference in New Issue
Block a user