This commit is contained in:
parent
a52b3c3b67
commit
3ecace714e
64
src/renderer/check/mapper.js
Normal file
64
src/renderer/check/mapper.js
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
Copyright 2020 Keith Paterson
|
||||
|
||||
This file is part of FG Airports.
|
||||
|
||||
FG Airports is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
FG Airports is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FG Airports. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
var L = require('leaflet');
|
||||
|
||||
export function checkMapper(o) {
|
||||
if (o instanceof L.ParkingSpot) {
|
||||
/*
|
||||
if( o.box === undefined ) {
|
||||
debugger;
|
||||
} */
|
||||
return {
|
||||
'index': Number(o['id']),
|
||||
'_leaflet_id': o._leaflet_id,
|
||||
'type': 'parking',
|
||||
'parkingType': o.options.attributes.type,
|
||||
'name': o.options.attributes.name,
|
||||
'radius': String(o.options.attributes.radius),
|
||||
'lat': o._latlng.lat,
|
||||
'lng': o._latlng.lng,
|
||||
'box': o.box !== undefined ? o.box.getLatLngs() : null
|
||||
};
|
||||
} else if (o instanceof L.RunwayNode) {
|
||||
console.log(o)
|
||||
|
||||
return { 'index': Number(o['glueindex']), '_leaflet_id': o._leaflet_id, 'lat': o._latlng.lat, 'lng': o._latlng.lng, 'type': 'runway' };
|
||||
} else if (o instanceof L.HoldNode) {
|
||||
console.log(o)
|
||||
return { 'index': Number(o['glueindex']), '_leaflet_id': o._leaflet_id, 'type': o.holdPointType };
|
||||
} else if (o instanceof L.RunwayPolygon) {
|
||||
return {
|
||||
'type': 'runway_poly',
|
||||
'pavement': o.getLatLngs()
|
||||
}
|
||||
} else if (o instanceof L.Polyline) {
|
||||
console.log(o)
|
||||
//_latlngs[""0""].__vertex.glueindex
|
||||
var latLngs = o.getLatLngs().map(l => ({ lat: l.lat, lng: l.lng, index: l.glueindex }));
|
||||
if (o.options.attributes===undefined) {
|
||||
return null;
|
||||
}
|
||||
return { 'start': Number(o['begin']), 'end': Number(o['end']), '_leaflet_id': o._leaflet_id, 'type': 'poly', 'direction': o.options.attributes.direction, 'isPushBackRoute': o.options.attributes.isPushBackRoute, latLngs: latLngs };
|
||||
}
|
||||
else {
|
||||
console.log('Unknown Type ')
|
||||
console.log(typeof o)
|
||||
}
|
||||
}
|
||||
|
||||
export function groMapper(o) {
|
||||
if (o instanceof L.Polygon) {
|
||||
|
||||
}
|
||||
}
|
@ -74,14 +74,16 @@ You should have received a copy of the GNU General Public License along with FG
|
||||
|
||||
<script lang="js">
|
||||
/* eslint-disable */
|
||||
const path = require('path')
|
||||
const fs = require('fs');
|
||||
const mapper = require('../check/mapper');
|
||||
|
||||
import EditButton from './EditButton'
|
||||
import ZoomButton from './ZoomButton';
|
||||
import Upload from './Upload'
|
||||
import Vue from 'vue'
|
||||
|
||||
import fileUrl from 'file-url'
|
||||
const path = require('path')
|
||||
const fs = require('fs');
|
||||
|
||||
export default {
|
||||
components: { EditButton, Upload, ZoomButton },
|
||||
@ -211,15 +213,20 @@ You should have received a copy of the GNU General Public License along with FG
|
||||
worker.progress = 0
|
||||
// var worker = new Worker(fileUrl('src/renderer/utils/worker.js'))
|
||||
this.worker = worker
|
||||
var xml = []
|
||||
var groundnet = []
|
||||
this.$parent.$parent.$refs.editLayer.groundnetLayerGroup.eachLayer(l => {
|
||||
console.log(l)
|
||||
xml.push(l)
|
||||
groundnet.push(l)
|
||||
})
|
||||
var features = groundnet.map(mapper.checkMapper).filter(n => n)
|
||||
var pavement = []
|
||||
this.$parent.$parent.$refs.pavementLayer.pavement.eachLayer(l => {
|
||||
console.log(l)
|
||||
pavement.push(l)
|
||||
})
|
||||
var features2 = pavement.map(mapper.checkMapper).filter(n => n)
|
||||
|
||||
var features = xml.map(this.featuresMapper).filter(n => n)
|
||||
|
||||
worker.postMessage(['check', features ] )
|
||||
worker.postMessage(['check', features.concat(features2) ] )
|
||||
this.pollData()
|
||||
// the reply
|
||||
var store = this.$store
|
||||
@ -245,6 +252,12 @@ You should have received a copy of the GNU General Public License along with FG
|
||||
}
|
||||
// console.log(e.data)
|
||||
}
|
||||
worker.onError = function(e) {
|
||||
worker.terminate()
|
||||
worker.view.max = 0
|
||||
worker.view.checkDialogVisible = false
|
||||
e.preventDefault(); // <-- "Hey browser, I handled it!"
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
@ -273,38 +286,6 @@ You should have received a copy of the GNU General Public License along with FG
|
||||
this.$parent.$parent.$refs.editLayer.stopDrawing()
|
||||
Vue.set(this, 'checkDialogVisible', true)
|
||||
this.check()
|
||||
},
|
||||
featuresMapper(o) {
|
||||
if (o instanceof L.ParkingSpot) {
|
||||
/*
|
||||
if( o.box === undefined ) {
|
||||
debugger;
|
||||
} */
|
||||
return { 'index': Number(o['id']),
|
||||
'_leaflet_id': o._leaflet_id,
|
||||
'type': 'parking',
|
||||
'parkingType': o.options.attributes.type,
|
||||
'name': o.options.attributes.name,
|
||||
'radius': String(o.options.attributes.radius),
|
||||
'lat': o._latlng.lat,
|
||||
'lng': o._latlng.lng,
|
||||
'box': o.box!==undefined?o.box.getLatLngs():null
|
||||
};
|
||||
} else if (o instanceof L.RunwayNode) {
|
||||
console.log(o)
|
||||
return { 'index': Number(o['glueindex']), '_leaflet_id': o._leaflet_id, 'type': 'runway' };
|
||||
} else if (o instanceof L.HoldNode) {
|
||||
console.log(o)
|
||||
return { 'index': Number(o['glueindex']), '_leaflet_id': o._leaflet_id, 'type': o.holdPointType };
|
||||
} else if (o instanceof L.Polyline) {
|
||||
console.log(o)
|
||||
//_latlngs[""0""].__vertex.glueindex
|
||||
var latLngs = o.getLatLngs().map(l => ({lat: l.lat, lng: l.lng, index: l.glueindex}));
|
||||
return { 'start': Number(o['begin']), 'end': Number(o['end']), '_leaflet_id': o._leaflet_id, 'type': 'poly', 'direction': o.options.attributes.direction, 'isPushBackRoute': o.options.attributes.isPushBackRoute, latLngs: latLngs };
|
||||
} else {
|
||||
console.log('Unknown Type ')
|
||||
console.log(typeof o)
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -810,6 +810,8 @@ You should have received a copy of the GNU General Public License along with FG
|
||||
if (distance > 0 && distance < snap) {
|
||||
layers.push({d: distance, l: layer, latlng: latlng.__vertex.latlng, glueindex: latlng.glueindex})
|
||||
}
|
||||
} else {
|
||||
console.log(latlng);
|
||||
}
|
||||
})
|
||||
} else if (layer instanceof L.RunwayNode) {
|
||||
@ -913,9 +915,11 @@ You should have received a copy of the GNU General Public License along with FG
|
||||
console.warn('No glueindex : ' + latlng.__vertex);
|
||||
}
|
||||
let distance = latlng.distanceTo(centerLatLng)
|
||||
if (latlng.glueindex !== newIndex && distance < 10) {
|
||||
if (Number(latlng.glueindex) !== Number(newIndex) && distance < 10) {
|
||||
nearest.push({d: distance, l: layer, latlng: latlng.__vertex.latlng, glueindex: latlng.glueindex })
|
||||
}
|
||||
} else {
|
||||
console.error("No __Vertex");
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
import axios from 'axios'
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const mapper = require('../check/mapper');
|
||||
|
||||
export default {
|
||||
name: 'upload',
|
||||
@ -118,33 +119,6 @@
|
||||
}
|
||||
}, 1000)
|
||||
},
|
||||
featuresMapper(o) {
|
||||
if (o instanceof L.ParkingSpot) {
|
||||
return { 'index': Number(o['id']),
|
||||
'_leaflet_id': o._leaflet_id,
|
||||
'type': 'parking',
|
||||
'parkingType': o.options.attributes.type,
|
||||
'name': o.options.attributes.name,
|
||||
'radius': String(o.options.attributes.radius),
|
||||
'lat': o._latlng.lat,
|
||||
'lng': o._latlng.lng,
|
||||
'box': o.box!==undefined?o.box.getLatLngs():null
|
||||
};
|
||||
} else if (o instanceof L.RunwayNode) {
|
||||
console.log(o)
|
||||
return { 'index': Number(o['glueindex']), '_leaflet_id': o._leaflet_id, 'type': 'runway' };
|
||||
} else if (o instanceof L.HoldNode) {
|
||||
console.log(o)
|
||||
return { 'index': Number(o['glueindex']), '_leaflet_id': o._leaflet_id, 'type': o.holdPointType };
|
||||
} else if (o instanceof L.Polyline) {
|
||||
console.log(o)
|
||||
var latLngs = o.getLatLngs().map(l => ({lat: l.lat, lng: l.lng, index: l.attributes.index}));
|
||||
return { 'start': Number(o['begin']), 'end': Number(o['end']), '_leaflet_id': o._leaflet_id, 'type': 'poly', 'direction': o.options.attributes.direction, 'isPushBackRoute': o.options.attributes.isPushBackRoute, latLngs: latLngs };
|
||||
} else {
|
||||
console.log('Unknown Type ')
|
||||
console.log(typeof o)
|
||||
}
|
||||
},
|
||||
check () {
|
||||
try {
|
||||
this.scanning = true
|
||||
@ -169,7 +143,7 @@
|
||||
xml.push(l)
|
||||
})
|
||||
|
||||
var features = xml.map(this.featuresMapper).filter(n => n)
|
||||
var features = xml.map(mapper.checkMapper).filter(n => n)
|
||||
|
||||
worker.postMessage(['check', features ] )
|
||||
this.pollData()
|
||||
|
25
src/renderer/leaflet/Runway.js
Normal file
25
src/renderer/leaflet/Runway.js
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
Copyright 2020 Keith Paterson
|
||||
|
||||
This file is part of FG Airports.
|
||||
|
||||
FG Airports is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
FG Airports is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FG Airports. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
|
||||
L.RunwayPolygon = L.Polygon.extend({
|
||||
});
|
||||
|
||||
var runwayPoly = function (runwayPoints) {
|
||||
var runwayPoly = new L.RunwayPolygon(runwayPoints);
|
||||
runwayPoly.setStyle({ color: 'grey', fillColor: 'grey', opacity: 0.5, fillOpacity: 0.5, interactive: false });
|
||||
|
||||
return runwayPoly;
|
||||
}
|
||||
|
||||
module.exports = runwayPoly;
|
@ -1,3 +1,14 @@
|
||||
/*
|
||||
Copyright 2020 Keith Paterson
|
||||
|
||||
This file is part of FG Airports.
|
||||
|
||||
FG Airports is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
FG Airports is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with FG Airports. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
/* eslint-disable */
|
||||
const lineReader = require('readline');
|
||||
const zlib = require('zlib');
|
||||
@ -5,6 +16,8 @@ const zlib = require('zlib');
|
||||
const LatLonEllipsoidal = require('geodesy/latlon-ellipsoidal-vincenty.js').default;
|
||||
const fs = require('fs');
|
||||
|
||||
const buildRunwayPoly = require('../leaflet/Runway.js');
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} line
|
||||
@ -304,22 +317,14 @@ var scanMethods = {
|
||||
// APTDAT 715 Segment
|
||||
10: (line, icao, layerGroup) => {
|
||||
if (module.exports.isScanning) {
|
||||
//var marker = new L.marker([line[1], line[2]], { title: '10 Point', color: 'fuchsia' });
|
||||
//marker.bindTooltip(String(line), { className: "my-label", offset: [0, 0] });
|
||||
//marker.addTo(layerGroup);
|
||||
var pointMiddle = new LatLonEllipsoidal(Number(line[1]), Number(line[2]));
|
||||
var point1 = pointMiddle.destinationPoint(line[5]/6.562, line[4]);
|
||||
var point2 = pointMiddle.destinationPoint(line[5]/6.562, line[4]-180);
|
||||
|
||||
//var runwayPoly2 = new L.Polygon([point1, point2]);
|
||||
//var marker2 = new L.marker(point2, { title: '10 Point 2', color: 'fuchsia' });
|
||||
//marker2.bindTooltip(String(line), { className: "my-label", offset: [0, 0] });
|
||||
//marker2.addTo(layerGroup);
|
||||
//runwayPoly2.setStyle({ color: 'red', interactive: false });
|
||||
//runwayPoly2.addTo(layerGroup);
|
||||
var runwayPoints = [];
|
||||
|
||||
var bearing = point1.initialBearingTo(point2);
|
||||
// Width in ft
|
||||
var runwayWidth = Number(line[8])/3.281;
|
||||
|
||||
runwayPoints.push(point1.destinationPoint(runwayWidth / 2, (bearing + 90)));
|
||||
@ -327,8 +332,7 @@ var scanMethods = {
|
||||
runwayPoints.push(point2.destinationPoint(runwayWidth / 2, (bearing - 90)));
|
||||
runwayPoints.push(point1.destinationPoint(runwayWidth / 2, (bearing - 90)));
|
||||
|
||||
var runwayPoly = new L.Polygon(runwayPoints);
|
||||
runwayPoly.setStyle({ color: 'grey', fillColor: 'grey', opacity: 0.5, fillOpacity: 0.5, interactive: false });
|
||||
var runwayPoly = buildRunwayPoly(runwayPoints);
|
||||
runwayPoly.addTo(layerGroup);
|
||||
}
|
||||
},
|
||||
@ -350,10 +354,9 @@ var scanMethods = {
|
||||
runwayPoints.push(point2.destinationPoint(runwayWidth / 2, (bearing - 90)));
|
||||
runwayPoints.push(point1.destinationPoint(runwayWidth / 2, (bearing - 90)));
|
||||
|
||||
var runwayPoly = new L.Polygon(runwayPoints);
|
||||
runwayPoly.setStyle({ color: 'grey', interactive: false });
|
||||
var runwayPoly = buildRunwayPoly(runwayPoints);
|
||||
runwayPoly.addTo(layerGroup);
|
||||
|
||||
|
||||
var displacedEnd1 = point1.destinationPoint(Number(line[20]), bearing)
|
||||
var displacedEnd2 = point2.destinationPoint(Number(line[20]), bearing-180)
|
||||
|
||||
|
@ -10,7 +10,7 @@ var turf;
|
||||
|
||||
console.log(process.resourcesPath);
|
||||
|
||||
if(process.env.NODE_ENV === 'development') {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
importScripts('../../../node_modules/dijkstrajs/dijkstra.js');
|
||||
turf = require('./node_modules/@turf/turf');
|
||||
} else if (process.env.NODE_ENV === 'mocha') {
|
||||
@ -24,7 +24,7 @@ if(process.env.NODE_ENV === 'development') {
|
||||
const homedir = require('os').homedir();
|
||||
|
||||
importScripts('logger.js');
|
||||
importScripts('haversine.js');
|
||||
importScripts('haversine.js');
|
||||
|
||||
function errorReceiver(event) {
|
||||
throw event.data;
|
||||
@ -48,16 +48,27 @@ onmessage = function (event) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Implements the checks of the groundnet
|
||||
* @param {*} data
|
||||
*/
|
||||
|
||||
async function checkGroundnet(data) {
|
||||
var promise = new Promise(function (resolve, reject) {
|
||||
try {
|
||||
//debugger;
|
||||
var parkings = data.map(mapParkings).filter(n => n !== undefined);
|
||||
var runwayNodes = data.map(mapRunwayNodes).filter(n => n !== undefined);
|
||||
var runwayNodeIDs = data.map(mapRunwayNodeId).filter(n => n !== undefined);
|
||||
var runwayNodes = data.map(mapRunwayNode).filter(n => n !== undefined);
|
||||
var pushbackNodes = data.map(mapPushbackNodes).filter(n => n !== undefined);
|
||||
var edges = data.map(mapEdges).filter(n => n !== undefined);
|
||||
|
||||
this.max = 4 * parkings.length * runwayNodes.length +
|
||||
var normalNodes = data.map(mapEdges).filter(n => n !== undefined)
|
||||
.flatMap(m => m.latLngs).filter(n => runwayNodeIDs.indexOf(Number(n.index)) < 0);
|
||||
|
||||
var runways = data.map(mapRunways).filter(n => n !== undefined);
|
||||
|
||||
this.max = 4 * parkings.length * runwayNodeIDs.length +
|
||||
3 * parkings.length;
|
||||
this.postMessage(['max', this.max]);
|
||||
|
||||
@ -65,8 +76,8 @@ async function checkGroundnet(data) {
|
||||
//debugger;
|
||||
data.forEach(element => {
|
||||
//debugger;
|
||||
if(element.box!==undefined && element.box!==null) {
|
||||
boxes[element.index] = element.box[0].map(latlng => [latlng.lat, latlng.lng] );
|
||||
if (element.box !== undefined && element.box !== null) {
|
||||
boxes[element.index] = element.box[0].map(latlng => [latlng.lat, latlng.lng]);
|
||||
boxes[element.index].push(boxes[element.index][0]);
|
||||
}
|
||||
});
|
||||
@ -78,14 +89,14 @@ async function checkGroundnet(data) {
|
||||
directionalGraph[element] = {};
|
||||
bidirectionalGraph[element] = {};
|
||||
});
|
||||
runwayNodes.forEach(element => {
|
||||
runwayNodeIDs.forEach(element => {
|
||||
directionalGraph[element] = {};
|
||||
bidirectionalGraph[element] = {};
|
||||
});
|
||||
var notOkNodes = [];
|
||||
|
||||
console.log(edges);
|
||||
if(edges===undefined) {
|
||||
if (edges === undefined) {
|
||||
resolve({});
|
||||
}
|
||||
edges.forEach(edge => {
|
||||
@ -93,15 +104,15 @@ async function checkGroundnet(data) {
|
||||
bidirectionalGraph[edge.start] = {};
|
||||
directionalGraph[edge.end] = {};
|
||||
bidirectionalGraph[edge.end] = {};
|
||||
if(edge.latLngs !== undefined) {
|
||||
if (edge.latLngs !== undefined) {
|
||||
// Check if there are segments > 2km
|
||||
edge.latLngs.forEach((latLng, index, arr) => {
|
||||
if (index>0) {
|
||||
var d = distance([arr[index-1].lng, arr[index-1].lat], [latLng.lng, latLng.lat]);
|
||||
if(d>2000) {
|
||||
notOkNodes.push({ id: Number(arr[index-1].index), message: `Start of long route ${d.toFixed(2)}` });
|
||||
if (index > 0) {
|
||||
var d = distance([arr[index - 1].lng, arr[index - 1].lat], [latLng.lng, latLng.lat]);
|
||||
if (d > 2000) {
|
||||
notOkNodes.push({ id: Number(arr[index - 1].index), message: `Start of long route ${d.toFixed(2)}` });
|
||||
notOkNodes.push({ id: Number(arr[index].index), message: `End of long route ${d.toFixed(2)}` });
|
||||
}
|
||||
}
|
||||
//console.log(d);
|
||||
}
|
||||
});
|
||||
@ -109,39 +120,39 @@ async function checkGroundnet(data) {
|
||||
});
|
||||
// Add edges to directionalGraph
|
||||
edges.forEach(element => {
|
||||
var node1 = directionalGraph[element.start];
|
||||
var node1 = directionalGraph[element.start];
|
||||
var node2 = directionalGraph[element.end];
|
||||
if(element.direction === undefined) {
|
||||
if (element.direction === undefined) {
|
||||
notOkNodes.push({ id: Number(element._leaflet_id), message: `Edge missing direction` });
|
||||
}
|
||||
|
||||
if( element.direction === 'bi-directional' || element.direction === 'forward') {
|
||||
if (element.direction === 'bi-directional' || element.direction === 'forward') {
|
||||
node1[Number(element.end)] = 1;
|
||||
}
|
||||
if( element.direction === 'bi-directional' || element.direction === 'backward') {
|
||||
if (element.direction === 'bi-directional' || element.direction === 'backward') {
|
||||
node2[Number(element.start)] = 1;
|
||||
}
|
||||
|
||||
var node3 = bidirectionalGraph[element.start];
|
||||
var node3 = bidirectionalGraph[element.start];
|
||||
var node4 = bidirectionalGraph[element.end];
|
||||
node3[Number(element.end)] = 1;
|
||||
node4[Number(element.start)] = 1;
|
||||
});
|
||||
var isLegitEnd = function(v) {
|
||||
if( Object.keys(bidirectionalGraph[v]).length <= 1 ) {
|
||||
var isLegitEnd = function (v) {
|
||||
if (Object.keys(bidirectionalGraph[v]).length <= 1) {
|
||||
return true;
|
||||
}
|
||||
return Object.keys(bidirectionalGraph[v]).filter( v => runwayNodes[v]).length === 0;
|
||||
return Object.keys(bidirectionalGraph[v]).filter(v => runwayNodeIDs[v]).length === 0;
|
||||
}
|
||||
//debugger;
|
||||
runwayNodes = runwayNodes.filter(
|
||||
runwayNodeIDs = runwayNodeIDs.filter(
|
||||
(v, i) => isLegitEnd(v)
|
||||
);
|
||||
// Check if there is a route from every parking to every runway node
|
||||
var okNodes = [];
|
||||
logger('info', directionalGraph);
|
||||
parkings.forEach(parkingNode => {
|
||||
runwayNodes.forEach(runwayNode => {
|
||||
runwayNodeIDs.forEach(runwayNode => {
|
||||
var ok = checkRoute(directionalGraph, parkingNode, runwayNode);
|
||||
if (ok) {
|
||||
okNodes.push(parkingNode);
|
||||
@ -180,38 +191,38 @@ async function checkGroundnet(data) {
|
||||
parkings.forEach(parkingNode => {
|
||||
pushbackNodes.forEach(pushbackNode => {
|
||||
var numRoutes = checkRoute(noPushbackGraph, parkingNode, pushbackNode);
|
||||
if (numRoutes===0) {
|
||||
if (numRoutes === 0) {
|
||||
/*
|
||||
if(parkingNode===14) {
|
||||
debugger;
|
||||
}
|
||||
*/
|
||||
if (multiplePushbackRoutes[parkingNode]===undefined &&
|
||||
Object.keys(noPushbackGraph[parkingNode])>0) {
|
||||
if (multiplePushbackRoutes[parkingNode] === undefined &&
|
||||
Object.keys(noPushbackGraph[parkingNode]) > 0) {
|
||||
// Only when there is a edge leaving
|
||||
multiplePushbackRoutes[parkingNode] = [];
|
||||
}
|
||||
} else if (numRoutes===1){
|
||||
if (multiplePushbackRoutes[parkingNode]===undefined) {
|
||||
}
|
||||
} else if (numRoutes === 1) {
|
||||
if (multiplePushbackRoutes[parkingNode] === undefined) {
|
||||
multiplePushbackRoutes[parkingNode] = [pushbackNode];
|
||||
} else {
|
||||
multiplePushbackRoutes[parkingNode].push(pushbackNode);
|
||||
}
|
||||
} else if (numRoutes>1){
|
||||
if (multiplePushbackRoutes[parkingNode]===undefined) {
|
||||
}
|
||||
} else if (numRoutes > 1) {
|
||||
if (multiplePushbackRoutes[parkingNode] === undefined) {
|
||||
multiplePushbackRoutes[parkingNode] = [pushbackNode];
|
||||
} else {
|
||||
multiplePushbackRoutes[parkingNode].push(pushbackNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.postMessage(['progress', 1]);
|
||||
});
|
||||
});
|
||||
var rogueHoldPoints = pushbackNodes.map(
|
||||
id => {
|
||||
id => {
|
||||
var routes = noPushbackGraph[id];
|
||||
if(Object.keys(routes).length<1)
|
||||
return { id: id, message: 'Unconnected Pushbacknode' }
|
||||
if (Object.keys(routes).length < 1)
|
||||
return { id: id, message: 'Unconnected Pushbacknode' }
|
||||
/*
|
||||
else if(Object.keys(routes).length>1)
|
||||
return { id: id, message: 'Multiple connected pushback node' }
|
||||
@ -224,39 +235,39 @@ async function checkGroundnet(data) {
|
||||
return this[e] != undefined && this[e].length != 1;
|
||||
}
|
||||
, multiplePushbackRoutes).map(
|
||||
id => {
|
||||
id => {
|
||||
var endPoints = multiplePushbackRoutes[id];
|
||||
if( endPoints.length<1)
|
||||
return { id: id, message: 'No way to pushback holdpoint' }
|
||||
else
|
||||
return { id: id, message: 'Multiple connected pushback points' }
|
||||
if (endPoints.length < 1)
|
||||
return { id: id, message: 'No way to pushback holdpoint' }
|
||||
else
|
||||
return { id: id, message: 'Multiple connected pushback points' }
|
||||
}
|
||||
);
|
||||
wrongPushbackRoutes =wrongPushbackRoutes.concat(multiplePushbackRoutes);
|
||||
wrongPushbackRoutes = wrongPushbackRoutes.concat(multiplePushbackRoutes);
|
||||
|
||||
okNodes = okNodes.filter((v, i) => okNodes.indexOf(v) === i);
|
||||
var notOkNodesParkings = parkings.filter(
|
||||
(v, i) => okNodes.indexOf(v) < 0
|
||||
).map(
|
||||
id => { return { id: id, message: 'No way from parking to each runway' } }
|
||||
);
|
||||
var notOkNodesRunways = runwayNodes.filter(
|
||||
);
|
||||
var notOkNodesRunways = runwayNodeIDs.filter(
|
||||
(v, i) => okNodes.indexOf(v) < 0
|
||||
).map(
|
||||
).map(
|
||||
id => { return { id: id, message: 'No way from runway to each parking' } }
|
||||
);
|
||||
|
||||
|
||||
if (parkings.length === 0) {
|
||||
notOkNodes.push({ id: 0, message: 'No parkings' });
|
||||
}
|
||||
if (runwayNodes.length === 0) {
|
||||
if (runwayNodeIDs.length === 0) {
|
||||
notOkNodes.push({ id: 0, message: 'No Runwaynodes' });
|
||||
}
|
||||
var allEnds = Object.entries(bidirectionalGraph).filter(
|
||||
(v, i) => Object.keys(v[1]).length <= 1
|
||||
);
|
||||
// Ends that are not on Runway and not a Parking or Pushback
|
||||
var allLegitimateEndNodes = parkings.concat(runwayNodes).concat(pushbackNodes);
|
||||
var allLegitimateEndNodes = parkings.concat(runwayNodeIDs).concat(pushbackNodes);
|
||||
var danglingEnds = allEnds.filter(
|
||||
(v, i) => allLegitimateEndNodes.indexOf(Number(v[0])) < 0
|
||||
).map(
|
||||
@ -268,7 +279,7 @@ async function checkGroundnet(data) {
|
||||
var overlappingParkings = [];
|
||||
parkingNodes.forEach(parkingNode => {
|
||||
if (boxes[parkingNode.index] === undefined) {
|
||||
overlappingParkings.push({ id: parkingNode.index, message: 'Unknown radius' });
|
||||
overlappingParkings.push({ id: parkingNode.index, message: 'Unknown radius' });
|
||||
}
|
||||
});
|
||||
// Check for intersecting radii
|
||||
@ -281,17 +292,17 @@ async function checkGroundnet(data) {
|
||||
if (d < parkingNode.radius + parkingNode1.radius + 10) {
|
||||
// If bigger circles intersect we should check the boxes
|
||||
//debugger;
|
||||
if( boxes[parkingNode.index] !== null && boxes[parkingNode1.index] !== null &&
|
||||
if (boxes[parkingNode.index] !== null && boxes[parkingNode1.index] !== null &&
|
||||
boxes[parkingNode.index] !== undefined && boxes[parkingNode1.index] !== undefined) {
|
||||
var poly1 = turf.polygon([boxes[parkingNode.index]]);
|
||||
|
||||
var poly2 = turf.polygon([boxes[parkingNode1.index]]);
|
||||
|
||||
var poly1 = turf.polygon([boxes[parkingNode.index]]);
|
||||
|
||||
var poly2 = turf.polygon([boxes[parkingNode1.index]]);
|
||||
|
||||
var intersection = turf.intersect(poly1, poly2);
|
||||
if( intersection !== null ) {
|
||||
if (intersection !== null) {
|
||||
overlappingParkings.push({ id: parkingNode.index, message: 'Overlapping parkings' });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.postMessage(['progress', 1]);
|
||||
@ -308,44 +319,60 @@ async function checkGroundnet(data) {
|
||||
invalidParkings.push({ id: parkingNode.index, message: 'Parking type empty' });
|
||||
this.postMessage(['progress', 1]);
|
||||
}
|
||||
if (['ga','cargo', 'gate', 'mil-fighter', 'mil-cargo' ].indexOf(parkingNode.parkingType)<0) {
|
||||
if (['ga', 'cargo', 'gate', 'mil-fighter', 'mil-cargo'].indexOf(parkingNode.parkingType) < 0) {
|
||||
//debugger;
|
||||
invalidParkings.push({ id: parkingNode.index, message: `Parking type ${parkingNode.parkingType} not valid` });
|
||||
this.postMessage(['progress', 1]);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//Check for dual pushback/runway nodes
|
||||
runwayNodes.forEach(runwayNode => {
|
||||
runwayNodeIDs.forEach(runwayNode => {
|
||||
if (pushbackNodes.indexOf(runwayNode) >= 0) {
|
||||
notOkNodes.push({ id: runwayNode, message: 'Dual runway/ pushback node' });
|
||||
}
|
||||
});
|
||||
//Check if runwaynodes are on runway
|
||||
runwayNodes.forEach(runwayNode => {
|
||||
//debugger;
|
||||
if( runways.filter(r => turf.booleanContains(r, latToTurf(runwayNode))).length === 0 ) {
|
||||
notOkNodes.push({ id: runwayNode.index, message: 'Runwaynode not on runway' });
|
||||
}
|
||||
});
|
||||
|
||||
//Check if nodes no normal nodes are on runway
|
||||
// debugger;
|
||||
normalNodes.forEach(normalNode => {
|
||||
if( runways.filter(r => turf.booleanContains(r, latToTurf(normalNode))).length > 0 ) {
|
||||
//debugger;
|
||||
notOkNodes.push({ id: normalNode.index, message: 'Non Runwaynode on runway' });
|
||||
}
|
||||
});
|
||||
|
||||
notOkNodes = notOkNodes.concat(invalidParkings);
|
||||
if (invalidParkings.length===0) {
|
||||
notOkNodes.push({id:-1, message: 'Parkings valid'});
|
||||
if (invalidParkings.length === 0) {
|
||||
notOkNodes.push({ id: -1, message: 'Parkings valid' });
|
||||
}
|
||||
notOkNodes = notOkNodes.concat(overlappingParkings);
|
||||
if (overlappingParkings.length===0) {
|
||||
notOkNodes.push({id:-1, message: 'No parkings overlapping'});
|
||||
if (overlappingParkings.length === 0) {
|
||||
notOkNodes.push({ id: -1, message: 'No parkings overlapping' });
|
||||
}
|
||||
notOkNodes = notOkNodes.concat(danglingEnds);
|
||||
if (danglingEnds.length===0) {
|
||||
notOkNodes.push({id:-1, message: 'No invalid ends'});
|
||||
if (danglingEnds.length === 0) {
|
||||
notOkNodes.push({ id: -1, message: 'No invalid ends' });
|
||||
}
|
||||
notOkNodes = notOkNodes.concat(notOkNodesParkings).concat(rogueHoldPoints);
|
||||
if (notOkNodesParkings.length===0 && rogueHoldPoints===0) {
|
||||
notOkNodes.push({id:-1, message: 'Routes from parkings OK'});
|
||||
if (notOkNodesParkings.length === 0 && rogueHoldPoints === 0) {
|
||||
notOkNodes.push({ id: -1, message: 'Routes from parkings OK' });
|
||||
}
|
||||
|
||||
|
||||
notOkNodes = notOkNodes.concat(notOkNodesRunways);
|
||||
if (notOkNodesRunways.length===0) {
|
||||
notOkNodes.push({id:-1, message: 'Routes from runways OK'});
|
||||
if (notOkNodesRunways.length === 0) {
|
||||
notOkNodes.push({ id: -1, message: 'Routes from runways OK' });
|
||||
}
|
||||
notOkNodes = notOkNodes.concat(wrongPushbackRoutes);
|
||||
if (wrongPushbackRoutes.length===0) {
|
||||
notOkNodes.push({id:-1, message: 'Pushback routes OK'});
|
||||
if (wrongPushbackRoutes.length === 0) {
|
||||
notOkNodes.push({ id: -1, message: 'Pushback routes OK' });
|
||||
}
|
||||
// check1(directionalGraph);
|
||||
// check2();
|
||||
@ -417,12 +444,26 @@ var mapBoxes = function (o) {
|
||||
return { index: o.index };
|
||||
}
|
||||
|
||||
var mapRunwayNodes = function (o) {
|
||||
var mapRunwayNodeId = function (o) {
|
||||
if (o.type === 'runway')
|
||||
return o.index;
|
||||
console.debug(o);
|
||||
}
|
||||
|
||||
var mapRunwayNode = function (o) {
|
||||
if (o.type === 'runway') {
|
||||
return {index:o.index, lat: o.lat, lng: o.lng};
|
||||
}
|
||||
}
|
||||
|
||||
var mapRunways = function (o) {
|
||||
if (o.type === 'runway_poly') {
|
||||
var pts = o.pavement[0].map(latLngToArray);
|
||||
pts.push(pts[0]);
|
||||
return turf.polygon([pts]);
|
||||
}
|
||||
}
|
||||
|
||||
var mapEdges = function (o) {
|
||||
if (o.type === 'poly')
|
||||
// debugger;
|
||||
@ -432,3 +473,17 @@ var mapEdges = function (o) {
|
||||
};
|
||||
console.debug(o);
|
||||
}
|
||||
|
||||
var latToTurf = function (turfPoint) {
|
||||
return turf.point([turfPoint.lng, turfPoint.lat]);
|
||||
};
|
||||
|
||||
var latLngToArray = function (turfPoint) {
|
||||
//debugger;
|
||||
|
||||
return [turfPoint.lng, turfPoint.lat];
|
||||
};
|
||||
|
||||
var turfToLatLng = function (turfPoint) {
|
||||
return '' + turfPoint.geometry.coordinates[1].toFixed(6) + ',' + turfPoint.geometry.coordinates[0].toFixed(6);
|
||||
};
|
||||
|
@ -3,194 +3,223 @@ var Worker = require("tiny-worker");
|
||||
|
||||
process.chdir('src/renderer/utils');
|
||||
|
||||
describe("Test Check", function() {
|
||||
it("Not legitimate End", function(done) {
|
||||
var data = [
|
||||
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true}
|
||||
];
|
||||
var worker = new Worker('check.js');
|
||||
worker.onmessage = function (e) {
|
||||
if (e.data === 'checkStarted') {
|
||||
} else if (e.data[0] === 'DONE') {
|
||||
console.log('DONE')
|
||||
worker.terminate()
|
||||
if(e.data[1].length===0) {
|
||||
done('Crashed')
|
||||
} else {
|
||||
console.log(e.data[1]);
|
||||
console.log(e.data[1].filter(m => m.id === 1));
|
||||
assert.lengthOf(e.data[1].filter(m => m.id === 1).filter(m => m.message=== 'Node not a legimate end'), 1);
|
||||
assert.lengthOf(e.data[1].filter(m => m.id === 2).filter(m => m.message=== 'Node not a legimate end'), 1);
|
||||
assert.lengthOf(e.data[1].filter(m => m.message=== 'No invalid ends'), 0);
|
||||
|
||||
done()
|
||||
}
|
||||
} else if (e.data.length > 0) {
|
||||
}
|
||||
};
|
||||
worker.postMessage(['check', data]);
|
||||
});
|
||||
it("Legitimate End Runway", function(done) {
|
||||
describe("Test Check", function () {
|
||||
describe("Routing Checks", function () {
|
||||
it("Not legitimate End", function (done) {
|
||||
var data = [
|
||||
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, 'direction': 'bi-directional'},
|
||||
{ 'index': 1, '_leaflet_id': 2, 'type': 'runway' }
|
||||
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true }
|
||||
];
|
||||
var worker = new Worker('check.js');
|
||||
worker.onmessage = function (e) {
|
||||
if (e.data === 'checkStarted') {
|
||||
} else if (e.data[0] === 'DONE') {
|
||||
console.log('DONE')
|
||||
console.log('DONE')
|
||||
worker.terminate()
|
||||
if(e.data[1].length===0) {
|
||||
if (e.data[1].length === 0) {
|
||||
done('Crashed')
|
||||
} else {
|
||||
console.log(e.data[1]);
|
||||
console.log(e.data[1].filter(m => m.id === 1));
|
||||
assert.lengthOf(e.data[1].filter(m => m.id === 1).filter(m => m.message=== 'No way from runway to each parking'), 1);
|
||||
assert.lengthOf(e.data[1].filter(m => m.id === 2).filter(m => m.message=== 'Node not a legimate end'), 1);
|
||||
assert.lengthOf(e.data[1].filter(m => m.message=== 'No invalid ends'), 0);
|
||||
assert.lengthOf(e.data[1].filter(m => m.id === 1).filter(m => m.message === 'Node not a legimate end'), 1);
|
||||
assert.lengthOf(e.data[1].filter(m => m.id === 2).filter(m => m.message === 'Node not a legimate end'), 1);
|
||||
assert.lengthOf(e.data[1].filter(m => m.message === 'No invalid ends'), 0);
|
||||
|
||||
done()
|
||||
}
|
||||
} else if (e.data.length > 0) {
|
||||
}
|
||||
};
|
||||
worker.postMessage(['check', data]);
|
||||
});
|
||||
|
||||
it("From Parking to Runway bi-directional", function(done) {
|
||||
var data = [
|
||||
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, direction: 'bi-directional'},
|
||||
{ 'index': 1, '_leaflet_id': 2, 'type': 'runway' },
|
||||
{ 'index': 2, '_leaflet_id': 3, 'name': 'name', parkingType:'gate', 'type': 'parking' }
|
||||
];
|
||||
var worker = new Worker('check.js');
|
||||
worker.onmessage = function (e) {
|
||||
if (e.data === 'checkStarted') {
|
||||
} else if (e.data[0] === 'DONE') {
|
||||
console.log('DONE')
|
||||
worker.terminate()
|
||||
if(e.data[1].length===0) {
|
||||
done('Crashed')
|
||||
} else {
|
||||
console.log(e.data[1]);
|
||||
console.log(e.data[1].filter(m => m.id === 1));
|
||||
assert.lengthOf(e.data[1].filter(m => m.id === -1).filter(m => m.message=== 'Routes from runways OK'), 1);
|
||||
assert.lengthOf(e.data[1].filter(m => m.message=== 'No invalid ends'), 1);
|
||||
done()
|
||||
});
|
||||
it("Legitimate End Runway", function (done) {
|
||||
var data = [
|
||||
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, 'direction': 'bi-directional' },
|
||||
{ 'index': 1, '_leaflet_id': 2, 'type': 'runway' }
|
||||
];
|
||||
var worker = new Worker('check.js');
|
||||
worker.onmessage = function (e) {
|
||||
if (e.data === 'checkStarted') {
|
||||
} else if (e.data[0] === 'DONE') {
|
||||
console.log('DONE')
|
||||
worker.terminate()
|
||||
if (e.data[1].length === 0) {
|
||||
done('Crashed')
|
||||
} else {
|
||||
console.log(e.data[1]);
|
||||
console.log(e.data[1].filter(m => m.id === 1));
|
||||
assert.lengthOf(e.data[1].filter(m => m.id === 1).filter(m => m.message === 'No way from runway to each parking'), 1);
|
||||
assert.lengthOf(e.data[1].filter(m => m.id === 2).filter(m => m.message === 'Node not a legimate end'), 1);
|
||||
assert.lengthOf(e.data[1].filter(m => m.message === 'No invalid ends'), 0);
|
||||
done()
|
||||
}
|
||||
} else if (e.data.length > 0) {
|
||||
}
|
||||
} else if (e.data.length > 0) {
|
||||
}
|
||||
};
|
||||
worker.postMessage(['check', data]);
|
||||
});
|
||||
};
|
||||
worker.postMessage(['check', data]);
|
||||
});
|
||||
|
||||
it("From Parking to Runway forward OK", function(done) {
|
||||
var data = [
|
||||
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, direction: 'forward'},
|
||||
{ 'index': 1, '_leaflet_id': 3, 'name': 'name', parkingType:'gate', 'type': 'parking' },
|
||||
{ 'index': 2, '_leaflet_id': 2, 'type': 'runway' }
|
||||
];
|
||||
var worker = new Worker('check.js');
|
||||
worker.onmessage = function (e) {
|
||||
if (e.data === 'checkStarted') {
|
||||
} else if (e.data[0] === 'DONE') {
|
||||
console.log('DONE')
|
||||
worker.terminate()
|
||||
it("From Parking to Runway bi-directional", function (done) {
|
||||
var data = [
|
||||
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, direction: 'bi-directional' },
|
||||
{ 'index': 1, '_leaflet_id': 2, 'type': 'runway' },
|
||||
{ 'index': 2, '_leaflet_id': 3, 'name': 'name', parkingType: 'gate', 'type': 'parking' }
|
||||
];
|
||||
var worker = new Worker('check.js');
|
||||
worker.onmessage = function (e) {
|
||||
if (e.data === 'checkStarted') {
|
||||
} else if (e.data[0] === 'DONE') {
|
||||
console.log('DONE')
|
||||
worker.terminate()
|
||||
if (e.data[1].length === 0) {
|
||||
done('Crashed')
|
||||
} else {
|
||||
console.log(e.data[1]);
|
||||
console.log(e.data[1].filter(m => m.id === 1));
|
||||
assert.lengthOf(e.data[1].filter(m => m.id === -1).filter(m => m.message === 'Routes from runways OK'), 1);
|
||||
assert.lengthOf(e.data[1].filter(m => m.message === 'No invalid ends'), 1);
|
||||
done()
|
||||
}
|
||||
} else if (e.data.length > 0) {
|
||||
}
|
||||
};
|
||||
worker.postMessage(['check', data]);
|
||||
});
|
||||
|
||||
if(e.data[1].length===0) {
|
||||
done('Crashed')
|
||||
} else {
|
||||
console.log(e.data[1]);
|
||||
console.log(e.data[1].filter(m => m.id === 1));
|
||||
assert.lengthOf(e.data[1].filter(m => m.id === -1).filter(m => m.message=== 'Routes from runways OK'), 1);
|
||||
assert.lengthOf(e.data[1].filter(m => m.message=== 'No invalid ends'), 1);
|
||||
done()
|
||||
}
|
||||
} else if (e.data.length > 0) {
|
||||
}
|
||||
};
|
||||
worker.postMessage(['check', data]);
|
||||
});
|
||||
it("From Parking to Runway forward OK", function (done) {
|
||||
var data = [
|
||||
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, direction: 'forward' },
|
||||
{ 'index': 1, '_leaflet_id': 3, 'name': 'name', parkingType: 'gate', 'type': 'parking' },
|
||||
{ 'index': 2, '_leaflet_id': 2, 'type': 'runway' }
|
||||
];
|
||||
var worker = new Worker('check.js');
|
||||
worker.onmessage = function (e) {
|
||||
if (e.data === 'checkStarted') {
|
||||
} else if (e.data[0] === 'DONE') {
|
||||
console.log('DONE')
|
||||
worker.terminate()
|
||||
|
||||
it("From Parking to Runway forward Not Ok", function(done) {
|
||||
var data = [
|
||||
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, direction: 'forward'},
|
||||
{ 'index': 2, '_leaflet_id': 3, 'name': 'name', parkingType:'gate', 'type': 'parking' },
|
||||
{ 'index': 1, '_leaflet_id': 2, 'type': 'runway' }
|
||||
];
|
||||
var worker = new Worker('check.js');
|
||||
worker.onmessage = function (e) {
|
||||
if (e.data === 'checkStarted') {
|
||||
} else if (e.data[0] === 'DONE') {
|
||||
console.log('DONE')
|
||||
worker.terminate()
|
||||
if (e.data[1].length === 0) {
|
||||
done('Crashed')
|
||||
} else {
|
||||
console.log(e.data[1]);
|
||||
console.log(e.data[1].filter(m => m.id === 1));
|
||||
assert.lengthOf(e.data[1].filter(m => m.id === -1).filter(m => m.message === 'Routes from runways OK'), 1);
|
||||
assert.lengthOf(e.data[1].filter(m => m.message === 'No invalid ends'), 1);
|
||||
done()
|
||||
}
|
||||
} else if (e.data.length > 0) {
|
||||
}
|
||||
};
|
||||
worker.postMessage(['check', data]);
|
||||
});
|
||||
|
||||
if(e.data[1].length===0) {
|
||||
done('Crashed')
|
||||
} else {
|
||||
console.log(e.data[1]);
|
||||
console.log(e.data[1].filter(m => m.id === 1));
|
||||
assert.lengthOf(e.data[1].filter(m => m.id === -1).filter(m => m.message=== 'Routes from runways OK'), 0);
|
||||
assert.lengthOf(e.data[1].filter(m => m.message=== 'No invalid ends'), 1);
|
||||
done()
|
||||
}
|
||||
} else if (e.data.length > 0) {
|
||||
}
|
||||
};
|
||||
worker.postMessage(['check', data]);
|
||||
});
|
||||
it("From Parking to Runway forward Not Ok", function (done) {
|
||||
var data = [
|
||||
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, direction: 'forward' },
|
||||
{ 'index': 2, '_leaflet_id': 3, 'name': 'name', parkingType: 'gate', 'type': 'parking' },
|
||||
{ 'index': 1, '_leaflet_id': 2, 'type': 'runway' }
|
||||
];
|
||||
var worker = new Worker('check.js');
|
||||
worker.onmessage = function (e) {
|
||||
if (e.data === 'checkStarted') {
|
||||
} else if (e.data[0] === 'DONE') {
|
||||
console.log('DONE')
|
||||
worker.terminate()
|
||||
|
||||
it("From Parking to Runway reverse OK", function(done) {
|
||||
var data = [
|
||||
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, direction: 'backward'},
|
||||
{ 'index': 2, '_leaflet_id': 3, 'name': 'name', parkingType:'gate', 'type': 'parking' },
|
||||
{ 'index': 1, '_leaflet_id': 2, 'type': 'runway' }
|
||||
];
|
||||
var worker = new Worker('check.js');
|
||||
worker.onmessage = function (e) {
|
||||
if (e.data === 'checkStarted') {
|
||||
} else if (e.data[0] === 'DONE') {
|
||||
console.log('DONE')
|
||||
worker.terminate()
|
||||
if(e.data[1].length===0) {
|
||||
done('Crashed')
|
||||
} else {
|
||||
console.log(e.data[1]);
|
||||
console.log(e.data[1].filter(m => m.id === 1));
|
||||
assert.lengthOf(e.data[1].filter(m => m.id === -1).filter(m => m.message=== 'Routes from runways OK'), 1);
|
||||
assert.lengthOf(e.data[1].filter(m => m.message=== 'No invalid ends'), 1);
|
||||
done()
|
||||
}
|
||||
} else if (e.data.length > 0) {
|
||||
}
|
||||
};
|
||||
worker.postMessage(['check', data]);
|
||||
});
|
||||
if (e.data[1].length === 0) {
|
||||
done('Crashed')
|
||||
} else {
|
||||
console.log(e.data[1]);
|
||||
console.log(e.data[1].filter(m => m.id === 1));
|
||||
assert.lengthOf(e.data[1].filter(m => m.id === -1).filter(m => m.message === 'Routes from runways OK'), 0);
|
||||
assert.lengthOf(e.data[1].filter(m => m.message === 'No invalid ends'), 1);
|
||||
done()
|
||||
}
|
||||
} else if (e.data.length > 0) {
|
||||
}
|
||||
};
|
||||
worker.postMessage(['check', data]);
|
||||
});
|
||||
|
||||
it("From Parking to Runway reverse Not OK", function(done) {
|
||||
var data = [
|
||||
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, direction: 'backward'},
|
||||
{ 'index': 1, '_leaflet_id': 3, 'name': 'name', parkingType:'gate', 'type': 'parking' },
|
||||
{ 'index': 2, '_leaflet_id': 2, 'type': 'runway' }
|
||||
];
|
||||
var worker = new Worker('check.js');
|
||||
worker.onmessage = function (e) {
|
||||
if (e.data === 'checkStarted') {
|
||||
} else if (e.data[0] === 'DONE') {
|
||||
console.log('DONE')
|
||||
worker.terminate()
|
||||
if(e.data[1].length===0) {
|
||||
done('Crashed')
|
||||
} else {
|
||||
console.log(e.data[1]);
|
||||
console.log(e.data[1].filter(m => m.id === 1));
|
||||
assert.lengthOf(e.data[1].filter(m => m.id === -1).filter(m => m.message=== 'Routes from runways OK'), 0, 'No Routes from Runway');
|
||||
assert.lengthOf(e.data[1].filter(m => m.message=== 'No invalid ends'), 1, 'No invalid ends');
|
||||
done()
|
||||
}
|
||||
} else if (e.data.length > 0) {
|
||||
}
|
||||
};
|
||||
worker.postMessage(['check', data]);
|
||||
});
|
||||
it("From Parking to Runway reverse OK", function (done) {
|
||||
var data = [
|
||||
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, direction: 'backward' },
|
||||
{ 'index': 2, '_leaflet_id': 3, 'name': 'name', parkingType: 'gate', 'type': 'parking' },
|
||||
{ 'index': 1, '_leaflet_id': 2, 'type': 'runway' }
|
||||
];
|
||||
var worker = new Worker('check.js');
|
||||
worker.onmessage = function (e) {
|
||||
if (e.data === 'checkStarted') {
|
||||
} else if (e.data[0] === 'DONE') {
|
||||
console.log('DONE')
|
||||
worker.terminate()
|
||||
if (e.data[1].length === 0) {
|
||||
done('Crashed')
|
||||
} else {
|
||||
console.log(e.data[1]);
|
||||
console.log(e.data[1].filter(m => m.id === 1));
|
||||
assert.lengthOf(e.data[1].filter(m => m.id === -1).filter(m => m.message === 'Routes from runways OK'), 1);
|
||||
assert.lengthOf(e.data[1].filter(m => m.message === 'No invalid ends'), 1);
|
||||
done()
|
||||
}
|
||||
} else if (e.data.length > 0) {
|
||||
}
|
||||
};
|
||||
worker.postMessage(['check', data]);
|
||||
});
|
||||
|
||||
it("From Parking to Runway reverse Not OK", function (done) {
|
||||
var data = [
|
||||
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, direction: 'backward' },
|
||||
{ 'index': 1, '_leaflet_id': 3, 'name': 'name', parkingType: 'gate', 'type': 'parking' },
|
||||
{ 'index': 2, '_leaflet_id': 2, 'type': 'runway' }
|
||||
];
|
||||
var worker = new Worker('check.js');
|
||||
worker.onmessage = function (e) {
|
||||
if (e.data === 'checkStarted') {
|
||||
} else if (e.data[0] === 'DONE') {
|
||||
console.log('DONE')
|
||||
worker.terminate()
|
||||
if (e.data[1].length === 0) {
|
||||
done('Crashed')
|
||||
} else {
|
||||
console.log(e.data[1]);
|
||||
console.log(e.data[1].filter(m => m.id === 1));
|
||||
assert.lengthOf(e.data[1].filter(m => m.id === -1).filter(m => m.message === 'Routes from runways OK'), 0, 'No Routes from Runway');
|
||||
assert.lengthOf(e.data[1].filter(m => m.message === 'No invalid ends'), 1, 'No invalid ends');
|
||||
done()
|
||||
}
|
||||
} else if (e.data.length > 0) {
|
||||
}
|
||||
};
|
||||
worker.postMessage(['check', data]);
|
||||
});
|
||||
});
|
||||
describe("Routing Checks", function () {
|
||||
it("Runway Node not on Runway", function (done) {
|
||||
var data = [
|
||||
{ 'index': 2, '_leaflet_id': 2, 'type': 'runway' },
|
||||
{ 'name': 'R29', 'type': 'runway_area', 'polygon': [] }
|
||||
];
|
||||
var worker = new Worker('check.js');
|
||||
worker.onmessage = function (e) {
|
||||
if (e.data === 'checkStarted') {
|
||||
} else if (e.data[0] === 'DONE') {
|
||||
console.log('DONE')
|
||||
worker.terminate()
|
||||
if (e.data[1].length === 0) {
|
||||
done('Crashed')
|
||||
} else {
|
||||
console.log(e.data[1]);
|
||||
console.log(e.data[1].filter(m => m.id === 1));
|
||||
assert.lengthOf(e.data[1].filter(m => m.id === -1).filter(m => m.message === 'Routes from runways OK'), 0, 'No Routes from Runway');
|
||||
assert.lengthOf(e.data[1].filter(m => m.message === 'No invalid ends'), 1, 'No invalid ends');
|
||||
done()
|
||||
}
|
||||
} else if (e.data.length > 0) {
|
||||
}
|
||||
};
|
||||
worker.postMessage(['check', data]);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user