This commit is contained in:
Keith Paterson 2021-01-17 14:45:00 +01:00
parent d3daa87244
commit 2936559873
6 changed files with 166 additions and 111 deletions

34
package-lock.json generated
View File

@ -2091,9 +2091,9 @@
"dev": true "dev": true
}, },
"acorn": { "acorn": {
"version": "5.7.3", "version": "5.7.4",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz",
"integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==", "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==",
"dev": true "dev": true
}, },
"acorn-jsx": { "acorn-jsx": {
@ -7583,9 +7583,9 @@
"dev": true "dev": true
}, },
"element-ui": { "element-ui": {
"version": "2.13.2", "version": "2.15.0",
"resolved": "https://registry.npmjs.org/element-ui/-/element-ui-2.13.2.tgz", "resolved": "https://registry.npmjs.org/element-ui/-/element-ui-2.15.0.tgz",
"integrity": "sha512-r761DRPssMPKDiJZWFlG+4e4vr0cRG/atKr3Eqr8Xi0tQMNbtmYU1QXvFnKiFPFFGkgJ6zS6ASkG+sellcoHlQ==", "integrity": "sha512-9z/1+b7V8fvp08OnKUEW4/BZ72kT+IhuKR9cTMz3XoCTKmEsqLLb32XjbO/DznSFaaiFbOYU93G7WtkvrCAL9A==",
"requires": { "requires": {
"async-validator": "~1.8.1", "async-validator": "~1.8.1",
"babel-helper-vue-jsx-merge-props": "^2.0.0", "babel-helper-vue-jsx-merge-props": "^2.0.0",
@ -8013,9 +8013,9 @@
"dev": true "dev": true
}, },
"js-yaml": { "js-yaml": {
"version": "3.13.1", "version": "3.14.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
"integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
"dev": true, "dev": true,
"requires": { "requires": {
"argparse": "^1.0.7", "argparse": "^1.0.7",
@ -8302,12 +8302,20 @@
"dev": true "dev": true
}, },
"esquery": { "esquery": {
"version": "1.0.1", "version": "1.3.1",
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.3.1.tgz",
"integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", "integrity": "sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"estraverse": "^4.0.0" "estraverse": "^5.1.0"
},
"dependencies": {
"estraverse": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz",
"integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==",
"dev": true
}
} }
}, },
"esrecurse": { "esrecurse": {

View File

@ -3,7 +3,11 @@
"version": "0.0.28", "version": "0.0.28",
"author": "portree_kid <keith.paterson@gmx.de>", "author": "portree_kid <keith.paterson@gmx.de>",
"description": "An software to design Flightgear groundnets", "description": "An software to design Flightgear groundnets",
"license": "GPL v3", "license": "GPL-3.0",
"repository": {
"type" : "git",
"url" : "https://github.com/Portree-Kid/flightgear-airports.git"
},
"main": "./dist/electron/main.js", "main": "./dist/electron/main.js",
"scripts": { "scripts": {
"build": "node .electron-vue/build.js && electron-builder", "build": "node .electron-vue/build.js && electron-builder",
@ -92,7 +96,7 @@
"coordinate-parser": "^1.0.3", "coordinate-parser": "^1.0.3",
"dijkstrajs": "^1.0.1", "dijkstrajs": "^1.0.1",
"electron-debug": "^3.0.1", "electron-debug": "^3.0.1",
"element-ui": "^2.14.1", "element-ui": "^2.13.2",
"file-url": "^3.0.0", "file-url": "^3.0.0",
"fs": "0.0.1-security", "fs": "0.0.1-security",
"fs-extra": "^9.0.1", "fs-extra": "^9.0.1",

View File

@ -5,6 +5,7 @@
import L from 'leaflet' import L from 'leaflet'
import LEdit from 'leaflet-editable/src/Leaflet.Editable.js' import LEdit from 'leaflet-editable/src/Leaflet.Editable.js'
import {readPavement} from '../loaders/pavement_loader' import {readPavement} from '../loaders/pavement_loader'
import * as turf from '@turf/turf'
export default { export default {
name: 'edit-layer', name: 'edit-layer',
@ -75,6 +76,21 @@
this.deferredMountedTo(this.$parent.mapObject) this.deferredMountedTo(this.$parent.mapObject)
} }
}, },
isOnRunway (latlng) {
var ret = false
this.pavement.eachLayer(l => {
if (l instanceof L.RunwayPolygon) {
console.debug(l)
if (turf.booleanContains(l.turfyRunway, this.latToTurf(latlng))) {
ret = true
}
}
})
return ret
},
latToTurf (turfPoint) {
return turf.point([turfPoint.lng, turfPoint.lat])
},
setVisible (visible) { setVisible (visible) {
if (this.pavement !== undefined) { if (this.pavement !== undefined) {
if (visible !== this.visible) { if (visible !== this.visible) {

View File

@ -12,14 +12,30 @@ You should have received a copy of the GNU General Public License along with FG
/* eslint-disable */ /* eslint-disable */
const turf = require('@turf/turf')
L.RunwayPolygon = L.Polygon.extend({ L.RunwayPolygon = L.Polygon.extend({
turfyRunway: [],
setTurfy: function (runwayPoints) {
var latLngs = runwayPoints.map(this.turfToLatLng);
latLngs.push(latLngs[0]);
this.turfyRunway = turf.polygon([latLngs]);
},
turfToLatLng: function (turfPoint) {
return [turfPoint.lng, turfPoint.lat];
}
}); });
var runwayPoly = function (runwayPoints) { var runwayPoly = function (runwayPoints) {
var runwayPoly = new L.RunwayPolygon(runwayPoints); var runwayPoly = new L.RunwayPolygon(runwayPoints);
runwayPoly.setStyle({ color: 'grey', fillColor: 'grey', opacity: 0.5, fillOpacity: 0.5, interactive: false }); runwayPoly.setStyle({ color: 'grey', fillColor: 'grey', opacity: 0.5, fillOpacity: 0.5, interactive: false });
runwayPoly.setTurfy(runwayPoints);
console.debug(runwayPoints);
return runwayPoly; return runwayPoly;
} }
module.exports = runwayPoly; module.exports = runwayPoly;

View File

@ -159,7 +159,7 @@ const extendTaxiSegment = function (taxiwaySegment) {
if (event.target.options.attributes.name !== undefined) { if (event.target.options.attributes.name !== undefined) {
multiarc.name = assign(event.target.options.attributes.name); multiarc.name = assign(event.target.options.attributes.name);
} }
if(event.target.options.attributes.isPushBackRoute) { if (event.target.options.attributes.isPushBackRoute) {
multiarc.isPushBackRoute = assign(event.target.options.attributes.isPushBackRoute); multiarc.isPushBackRoute = assign(event.target.options.attributes.isPushBackRoute);
} else { } else {
multiarc.isPushBackRoute = false; multiarc.isPushBackRoute = false;
@ -195,103 +195,114 @@ const extendTaxiSegment = function (taxiwaySegment) {
this.on('editable:middlemarker:mousedown', event => { this.on('editable:middlemarker:mousedown', event => {
console.debug('editable:middlemarker:mousedown'); console.debug('editable:middlemarker:mousedown');
}), }),
this.on('editable:vertex:new', event => { this.on('editable:vertex:new', event => {
console.debug('editable:vertex:new ' + event.vertex.getIndex() + '\t' + event.vertex.getLastIndex() + '\t'); 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 isOnRunway = this.editLayer.isOnRunway(event.latlng)
let taxiwaySegment = event.vertex.editor.feature; let closest = this.editLayer.closestLayerSnap(event.latlng, 5)
if (taxiwaySegment.options.attributes === undefined) { let taxiwaySegment = event.vertex.editor.feature;
taxiwaySegment.options.attributes = { direction: 'bi-directional' }; if (taxiwaySegment.options.attributes === undefined) {
taxiwaySegment.options.attributes = { direction: 'bi-directional' };
}
var isOnRunwayNum = 0;
if (isOnRunway) {
isOnRunwayNum = 1;
}
taxiwaySegment.updateStyle();
if (event.vertex.getIndex() !== 0 && event.vertex.getIndex() !== event.vertex.getLastIndex()) {
var x = taxiwaySegment.getLatLngs().filter(l => l === event.vertex.latlng);
// Somehow the latlng is not in our Segment!?
if (taxiwaySegment.getLatLngs().length < 3 && x.length === 0) {
var fixed = taxiwaySegment.getLatLngs();
fixed.splice(1, 0, event.vertex.latlng);
taxiwaySegment.setLatLngs(fixed);
} }
taxiwaySegment.updateStyle(); var nextIndex = ++taxiwaySegment.editLayer.groundnetLayerGroup.maxId;
if (event.vertex.getIndex() !== 0 && event.vertex.getIndex() !== event.vertex.getLastIndex()) { var splitOffNodes = taxiwaySegment.getLatLngs().splice(-1);
var x = taxiwaySegment.getLatLngs().filter(l => l === event.vertex.latlng); var remainingNodes = taxiwaySegment.getLatLngs();
// Somehow the latlng is not in our Segment!? if (remainingNodes.length <= 1 || !remainingNodes[1]) {
if (taxiwaySegment.getLatLngs().length < 3 && x.length === 0) { console.error('Not enough remaining nodes', remainingNodes);
var fixed = taxiwaySegment.getLatLngs(); }
fixed.splice(1, 0, event.vertex.latlng); splitOffNodes.unshift(L.latLng(remainingNodes[1].lat, remainingNodes[1].lng, remainingNodes[1].alt));
taxiwaySegment.setLatLngs(fixed); remainingNodes[1]['glueindex'] = nextIndex;
} remainingNodes[1].attributes = { index: nextIndex, isOnRunway: isOnRunwayNum };
var nextIndex = ++taxiwaySegment.editLayer.groundnetLayerGroup.maxId; taxiwaySegment.options.attributes.end = nextIndex;
var splitOffNodes = taxiwaySegment.getLatLngs().splice(-1); splitOffNodes[0]['glueindex'] = nextIndex;
var remainingNodes = taxiwaySegment.getLatLngs(); splitOffNodes[0].attributes = { index: nextIndex, isOnRunway: isOnRunwayNum };
if (remainingNodes.length <= 1 || !remainingNodes[1]) { taxiwaySegment.setLatLngs(remainingNodes);
console.error(remainingNodes); //taxiwaySegment.editor.refresh();
} //taxiwaySegment.editor.reset();
splitOffNodes.unshift(L.latLng(remainingNodes[1].lat, remainingNodes[1].lng, remainingNodes[1].alt)); if (splitOffNodes.length > 1) {
remainingNodes[1]['glueindex'] = nextIndex; var polyline = new L.Polyline(splitOffNodes, { attributes: {} });
remainingNodes[1].attributes = { index: nextIndex, isOnRunway: 0 }; polyline.addTo(taxiwaySegment.editLayer.$parent.$parent.$refs.map.mapObject);
taxiwaySegment.options.attributes.end = nextIndex; polyline.addTo(taxiwaySegment.editLayer.groundnetLayerGroup);
splitOffNodes[0]['glueindex'] = nextIndex; extendTaxiSegment(polyline);
splitOffNodes[0].attributes = { index: nextIndex, isOnRunway: 0 }; polyline.addListeners();
taxiwaySegment.setLatLngs(remainingNodes); polyline.setEditlayer(taxiwaySegment.editLayer);
//taxiwaySegment.editor.refresh(); polyline.enableEdit(taxiwaySegment.editLayer.$parent.$parent.$refs.map.mapObject);
//taxiwaySegment.editor.reset(); polyline.editor.refresh();
if (splitOffNodes.length > 1) { //polyline.editor.reset();
var polyline = new L.Polyline(splitOffNodes, { attributes: {} }); polyline.featureLookup = this.featureLookup;
polyline.addTo(taxiwaySegment.editLayer.$parent.$parent.$refs.map.mapObject); polyline.options.attributes.name = taxiwaySegment.options.attributes.name;
polyline.addTo(taxiwaySegment.editLayer.groundnetLayerGroup); polyline.options.attributes.direction = taxiwaySegment.options.attributes.direction;
extendTaxiSegment(polyline); polyline.options.attributes.isPushBackRoute = taxiwaySegment.options.attributes.isPushBackRoute;
polyline.addListeners(); polyline.options.attributes.begin = nextIndex;
polyline.setEditlayer(taxiwaySegment.editLayer); polyline.options.attributes.end = taxiwaySegment.end;
polyline.enableEdit(taxiwaySegment.editLayer.$parent.$parent.$refs.map.mapObject); polyline.updateStyle();
polyline.editor.refresh(); polyline.begin = nextIndex;
//polyline.editor.reset(); polyline.end = taxiwaySegment.end;
polyline.featureLookup = this.featureLookup; taxiwaySegment.end = nextIndex;
polyline.options.attributes.name = taxiwaySegment.options.attributes.name; this.editLayer.featureLookup[nextIndex] = [];
polyline.options.attributes.direction = taxiwaySegment.options.attributes.direction; this.featureLookup[nextIndex].push(taxiwaySegment);
polyline.options.attributes.isPushBackRoute = taxiwaySegment.options.attributes.isPushBackRoute; this.featureLookup[nextIndex].push(polyline);
polyline.options.attributes.begin = nextIndex;
polyline.options.attributes.end = taxiwaySegment.end;
polyline.updateStyle();
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 {
console.error('SplitoffNodes Short ', splitOffNodes);
}
} else { } else {
// Glue to another node console.error('SplitoffNodes Short ', splitOffNodes);
if (closest) { }
event.latlng['glueindex'] = Number(closest.glueindex); } else {
event.latlng.__vertex.setLatLng(closest.latlng); // Glue to another node
event.latlng.attributes = { index: event.latlng.glueindex, isOnRunway: 0 }; if (closest) {
// Push Vertex to lookup event.latlng['glueindex'] = Number(closest.glueindex);
this.editLayer.featureLookup[event.latlng.glueindex].push(event.latlng.__vertex); event.latlng.__vertex.setLatLng(closest.latlng);
if (taxiwaySegment.options.attributes.begin === undefined) { event.latlng.attributes = { index: event.latlng.glueindex, isOnRunway: isOnRunwayNum };
taxiwaySegment.options.attributes.begin = event.latlng['glueindex'] // Push Vertex to lookup
} else { this.editLayer.featureLookup[event.latlng.glueindex].push(event.latlng.__vertex);
taxiwaySegment.options.attributes.end = event.latlng['glueindex'] if (isOnRunwayNum==1) {
} this.editLayer.addRunwayNode(event.latlng, event.latlng['glueindex'])
if (taxiwaySegment.getLatLngs().length === 1) { }
taxiwaySegment.begin = closest.glueindex; if (taxiwaySegment.options.attributes.begin === undefined) {
} taxiwaySegment.options.attributes.begin = event.latlng['glueindex']
taxiwaySegment.end = closest.glueindex;
console.debug(`Closest : ${closest}`)
} else { } else {
event.vertex.latlng['glueindex'] = ++this.editLayer.groundnetLayerGroup.maxId; taxiwaySegment.options.attributes.end = event.latlng['glueindex']
event.vertex.latlng.attributes = { index: event.vertex.latlng.glueindex, isOnRunway: 0 }; }
this.editLayer.featureLookup[event.vertex.latlng.glueindex] = []; if (taxiwaySegment.getLatLngs().length === 1) {
this.editLayer.featureLookup[event.vertex.latlng.glueindex].push(event.vertex); taxiwaySegment.begin = closest.glueindex;
this.editLayer.featureLookup[event.vertex.latlng.glueindex].push(taxiwaySegment); }
// taxiwaySegment.editor.refresh(); taxiwaySegment.end = closest.glueindex;
//taxiwaySegment.editor.reset(); console.debug(`Closest : ${closest}`)
if (taxiwaySegment.options.attributes.begin === undefined) { } else {
taxiwaySegment.options.attributes.begin = event.vertex.latlng['glueindex'] event.vertex.latlng['glueindex'] = ++this.editLayer.groundnetLayerGroup.maxId;
taxiwaySegment.begin = event.vertex.latlng.glueindex; event.vertex.latlng.attributes = { index: event.vertex.latlng.glueindex, isOnRunway: isOnRunwayNum };
} else if (taxiwaySegment.options.attributes.end === undefined || this.editLayer.featureLookup[event.vertex.latlng.glueindex] = [];
(taxiwaySegment.getLatLngs()[taxiwaySegment.getLatLngs().length - 1].glueindex && this.editLayer.featureLookup[event.vertex.latlng.glueindex].push(event.vertex);
Number(taxiwaySegment.getLatLngs()[taxiwaySegment.getLatLngs().length - 1].glueindex) !== taxiwaySegment.options.attributes.end)) { this.editLayer.featureLookup[event.vertex.latlng.glueindex].push(taxiwaySegment);
taxiwaySegment.options.attributes.end = event.vertex.latlng['glueindex'] if (isOnRunwayNum==1) {
taxiwaySegment.end = Number(event.vertex.latlng.glueindex); this.editLayer.addRunwayNode(event.latlng, event.vertex.latlng['glueindex'])
} }
// 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(), ) }
}); //this.splitShape(taxiwaySegment.getLatLngs(), )
});
this.on('editable:vertex:deleted', event => { this.on('editable:vertex:deleted', event => {
console.debug('editable:vertex:deleted') console.debug('editable:vertex:deleted')
}); });

View File

@ -87,7 +87,7 @@ async function checkGroundnet(data) {
var directionalGraph = {}; var directionalGraph = {};
var bidirectionalGraph = {}; var bidirectionalGraph = {};
console.log(parkings); console.debug(parkings);
parkings.forEach(element => { parkings.forEach(element => {
directionalGraph[element] = {}; directionalGraph[element] = {};
bidirectionalGraph[element] = {}; bidirectionalGraph[element] = {};
@ -99,7 +99,7 @@ async function checkGroundnet(data) {
var notOkNodes = []; var notOkNodes = [];
//debugger; //debugger;
console.log(edges); console.debug(edges);
if (edges === undefined) { if (edges === undefined) {
resolve([{ id: -1, message: check_msg.NO_EDGES }]); resolve([{ id: -1, message: check_msg.NO_EDGES }]);
} }