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">
|
<script lang="js">
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
const path = require('path')
|
||||||
|
const fs = require('fs');
|
||||||
|
const mapper = require('../check/mapper');
|
||||||
|
|
||||||
import EditButton from './EditButton'
|
import EditButton from './EditButton'
|
||||||
import ZoomButton from './ZoomButton';
|
import ZoomButton from './ZoomButton';
|
||||||
import Upload from './Upload'
|
import Upload from './Upload'
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
|
||||||
import fileUrl from 'file-url'
|
import fileUrl from 'file-url'
|
||||||
const path = require('path')
|
|
||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { EditButton, Upload, ZoomButton },
|
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
|
worker.progress = 0
|
||||||
// var worker = new Worker(fileUrl('src/renderer/utils/worker.js'))
|
// var worker = new Worker(fileUrl('src/renderer/utils/worker.js'))
|
||||||
this.worker = worker
|
this.worker = worker
|
||||||
var xml = []
|
var groundnet = []
|
||||||
this.$parent.$parent.$refs.editLayer.groundnetLayerGroup.eachLayer(l => {
|
this.$parent.$parent.$refs.editLayer.groundnetLayerGroup.eachLayer(l => {
|
||||||
console.log(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.concat(features2) ] )
|
||||||
|
|
||||||
worker.postMessage(['check', features ] )
|
|
||||||
this.pollData()
|
this.pollData()
|
||||||
// the reply
|
// the reply
|
||||||
var store = this.$store
|
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)
|
// 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) {
|
} catch (err) {
|
||||||
console.error(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()
|
this.$parent.$parent.$refs.editLayer.stopDrawing()
|
||||||
Vue.set(this, 'checkDialogVisible', true)
|
Vue.set(this, 'checkDialogVisible', true)
|
||||||
this.check()
|
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: {
|
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) {
|
if (distance > 0 && distance < snap) {
|
||||||
layers.push({d: distance, l: layer, latlng: latlng.__vertex.latlng, glueindex: latlng.glueindex})
|
layers.push({d: distance, l: layer, latlng: latlng.__vertex.latlng, glueindex: latlng.glueindex})
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
console.log(latlng);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else if (layer instanceof L.RunwayNode) {
|
} 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);
|
console.warn('No glueindex : ' + latlng.__vertex);
|
||||||
}
|
}
|
||||||
let distance = latlng.distanceTo(centerLatLng)
|
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 })
|
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'
|
import axios from 'axios'
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
const mapper = require('../check/mapper');
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'upload',
|
name: 'upload',
|
||||||
@ -118,33 +119,6 @@
|
|||||||
}
|
}
|
||||||
}, 1000)
|
}, 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 () {
|
check () {
|
||||||
try {
|
try {
|
||||||
this.scanning = true
|
this.scanning = true
|
||||||
@ -169,7 +143,7 @@
|
|||||||
xml.push(l)
|
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 ] )
|
worker.postMessage(['check', features ] )
|
||||||
this.pollData()
|
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 */
|
/* eslint-disable */
|
||||||
const lineReader = require('readline');
|
const lineReader = require('readline');
|
||||||
const zlib = require('zlib');
|
const zlib = require('zlib');
|
||||||
@ -5,6 +16,8 @@ const zlib = require('zlib');
|
|||||||
const LatLonEllipsoidal = require('geodesy/latlon-ellipsoidal-vincenty.js').default;
|
const LatLonEllipsoidal = require('geodesy/latlon-ellipsoidal-vincenty.js').default;
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
|
const buildRunwayPoly = require('../leaflet/Runway.js');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {*} line
|
* @param {*} line
|
||||||
@ -304,22 +317,14 @@ var scanMethods = {
|
|||||||
// APTDAT 715 Segment
|
// APTDAT 715 Segment
|
||||||
10: (line, icao, layerGroup) => {
|
10: (line, icao, layerGroup) => {
|
||||||
if (module.exports.isScanning) {
|
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 pointMiddle = new LatLonEllipsoidal(Number(line[1]), Number(line[2]));
|
||||||
var point1 = pointMiddle.destinationPoint(line[5]/6.562, line[4]);
|
var point1 = pointMiddle.destinationPoint(line[5]/6.562, line[4]);
|
||||||
var point2 = pointMiddle.destinationPoint(line[5]/6.562, line[4]-180);
|
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 runwayPoints = [];
|
||||||
|
|
||||||
var bearing = point1.initialBearingTo(point2);
|
var bearing = point1.initialBearingTo(point2);
|
||||||
|
// Width in ft
|
||||||
var runwayWidth = Number(line[8])/3.281;
|
var runwayWidth = Number(line[8])/3.281;
|
||||||
|
|
||||||
runwayPoints.push(point1.destinationPoint(runwayWidth / 2, (bearing + 90)));
|
runwayPoints.push(point1.destinationPoint(runwayWidth / 2, (bearing + 90)));
|
||||||
@ -327,8 +332,7 @@ var scanMethods = {
|
|||||||
runwayPoints.push(point2.destinationPoint(runwayWidth / 2, (bearing - 90)));
|
runwayPoints.push(point2.destinationPoint(runwayWidth / 2, (bearing - 90)));
|
||||||
runwayPoints.push(point1.destinationPoint(runwayWidth / 2, (bearing - 90)));
|
runwayPoints.push(point1.destinationPoint(runwayWidth / 2, (bearing - 90)));
|
||||||
|
|
||||||
var runwayPoly = new L.Polygon(runwayPoints);
|
var runwayPoly = buildRunwayPoly(runwayPoints);
|
||||||
runwayPoly.setStyle({ color: 'grey', fillColor: 'grey', opacity: 0.5, fillOpacity: 0.5, interactive: false });
|
|
||||||
runwayPoly.addTo(layerGroup);
|
runwayPoly.addTo(layerGroup);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -350,10 +354,9 @@ var scanMethods = {
|
|||||||
runwayPoints.push(point2.destinationPoint(runwayWidth / 2, (bearing - 90)));
|
runwayPoints.push(point2.destinationPoint(runwayWidth / 2, (bearing - 90)));
|
||||||
runwayPoints.push(point1.destinationPoint(runwayWidth / 2, (bearing - 90)));
|
runwayPoints.push(point1.destinationPoint(runwayWidth / 2, (bearing - 90)));
|
||||||
|
|
||||||
var runwayPoly = new L.Polygon(runwayPoints);
|
var runwayPoly = buildRunwayPoly(runwayPoints);
|
||||||
runwayPoly.setStyle({ color: 'grey', interactive: false });
|
|
||||||
runwayPoly.addTo(layerGroup);
|
runwayPoly.addTo(layerGroup);
|
||||||
|
|
||||||
var displacedEnd1 = point1.destinationPoint(Number(line[20]), bearing)
|
var displacedEnd1 = point1.destinationPoint(Number(line[20]), bearing)
|
||||||
var displacedEnd2 = point2.destinationPoint(Number(line[20]), bearing-180)
|
var displacedEnd2 = point2.destinationPoint(Number(line[20]), bearing-180)
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ var turf;
|
|||||||
|
|
||||||
console.log(process.resourcesPath);
|
console.log(process.resourcesPath);
|
||||||
|
|
||||||
if(process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
importScripts('../../../node_modules/dijkstrajs/dijkstra.js');
|
importScripts('../../../node_modules/dijkstrajs/dijkstra.js');
|
||||||
turf = require('./node_modules/@turf/turf');
|
turf = require('./node_modules/@turf/turf');
|
||||||
} else if (process.env.NODE_ENV === 'mocha') {
|
} else if (process.env.NODE_ENV === 'mocha') {
|
||||||
@ -24,7 +24,7 @@ if(process.env.NODE_ENV === 'development') {
|
|||||||
const homedir = require('os').homedir();
|
const homedir = require('os').homedir();
|
||||||
|
|
||||||
importScripts('logger.js');
|
importScripts('logger.js');
|
||||||
importScripts('haversine.js');
|
importScripts('haversine.js');
|
||||||
|
|
||||||
function errorReceiver(event) {
|
function errorReceiver(event) {
|
||||||
throw event.data;
|
throw event.data;
|
||||||
@ -48,16 +48,27 @@ onmessage = function (event) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements the checks of the groundnet
|
||||||
|
* @param {*} data
|
||||||
|
*/
|
||||||
|
|
||||||
async function checkGroundnet(data) {
|
async function checkGroundnet(data) {
|
||||||
var promise = new Promise(function (resolve, reject) {
|
var promise = new Promise(function (resolve, reject) {
|
||||||
try {
|
try {
|
||||||
//debugger;
|
//debugger;
|
||||||
var parkings = data.map(mapParkings).filter(n => n !== undefined);
|
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 pushbackNodes = data.map(mapPushbackNodes).filter(n => n !== undefined);
|
||||||
var edges = data.map(mapEdges).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;
|
3 * parkings.length;
|
||||||
this.postMessage(['max', this.max]);
|
this.postMessage(['max', this.max]);
|
||||||
|
|
||||||
@ -65,8 +76,8 @@ async function checkGroundnet(data) {
|
|||||||
//debugger;
|
//debugger;
|
||||||
data.forEach(element => {
|
data.forEach(element => {
|
||||||
//debugger;
|
//debugger;
|
||||||
if(element.box!==undefined && element.box!==null) {
|
if (element.box !== undefined && element.box !== null) {
|
||||||
boxes[element.index] = element.box[0].map(latlng => [latlng.lat, latlng.lng] );
|
boxes[element.index] = element.box[0].map(latlng => [latlng.lat, latlng.lng]);
|
||||||
boxes[element.index].push(boxes[element.index][0]);
|
boxes[element.index].push(boxes[element.index][0]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -78,14 +89,14 @@ async function checkGroundnet(data) {
|
|||||||
directionalGraph[element] = {};
|
directionalGraph[element] = {};
|
||||||
bidirectionalGraph[element] = {};
|
bidirectionalGraph[element] = {};
|
||||||
});
|
});
|
||||||
runwayNodes.forEach(element => {
|
runwayNodeIDs.forEach(element => {
|
||||||
directionalGraph[element] = {};
|
directionalGraph[element] = {};
|
||||||
bidirectionalGraph[element] = {};
|
bidirectionalGraph[element] = {};
|
||||||
});
|
});
|
||||||
var notOkNodes = [];
|
var notOkNodes = [];
|
||||||
|
|
||||||
console.log(edges);
|
console.log(edges);
|
||||||
if(edges===undefined) {
|
if (edges === undefined) {
|
||||||
resolve({});
|
resolve({});
|
||||||
}
|
}
|
||||||
edges.forEach(edge => {
|
edges.forEach(edge => {
|
||||||
@ -93,15 +104,15 @@ async function checkGroundnet(data) {
|
|||||||
bidirectionalGraph[edge.start] = {};
|
bidirectionalGraph[edge.start] = {};
|
||||||
directionalGraph[edge.end] = {};
|
directionalGraph[edge.end] = {};
|
||||||
bidirectionalGraph[edge.end] = {};
|
bidirectionalGraph[edge.end] = {};
|
||||||
if(edge.latLngs !== undefined) {
|
if (edge.latLngs !== undefined) {
|
||||||
// Check if there are segments > 2km
|
// Check if there are segments > 2km
|
||||||
edge.latLngs.forEach((latLng, index, arr) => {
|
edge.latLngs.forEach((latLng, index, arr) => {
|
||||||
if (index>0) {
|
if (index > 0) {
|
||||||
var d = distance([arr[index-1].lng, arr[index-1].lat], [latLng.lng, latLng.lat]);
|
var d = distance([arr[index - 1].lng, arr[index - 1].lat], [latLng.lng, latLng.lat]);
|
||||||
if(d>2000) {
|
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 - 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)}` });
|
notOkNodes.push({ id: Number(arr[index].index), message: `End of long route ${d.toFixed(2)}` });
|
||||||
}
|
}
|
||||||
//console.log(d);
|
//console.log(d);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -109,39 +120,39 @@ async function checkGroundnet(data) {
|
|||||||
});
|
});
|
||||||
// Add edges to directionalGraph
|
// Add edges to directionalGraph
|
||||||
edges.forEach(element => {
|
edges.forEach(element => {
|
||||||
var node1 = directionalGraph[element.start];
|
var node1 = directionalGraph[element.start];
|
||||||
var node2 = directionalGraph[element.end];
|
var node2 = directionalGraph[element.end];
|
||||||
if(element.direction === undefined) {
|
if (element.direction === undefined) {
|
||||||
notOkNodes.push({ id: Number(element._leaflet_id), message: `Edge missing direction` });
|
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;
|
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;
|
node2[Number(element.start)] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var node3 = bidirectionalGraph[element.start];
|
var node3 = bidirectionalGraph[element.start];
|
||||||
var node4 = bidirectionalGraph[element.end];
|
var node4 = bidirectionalGraph[element.end];
|
||||||
node3[Number(element.end)] = 1;
|
node3[Number(element.end)] = 1;
|
||||||
node4[Number(element.start)] = 1;
|
node4[Number(element.start)] = 1;
|
||||||
});
|
});
|
||||||
var isLegitEnd = function(v) {
|
var isLegitEnd = function (v) {
|
||||||
if( Object.keys(bidirectionalGraph[v]).length <= 1 ) {
|
if (Object.keys(bidirectionalGraph[v]).length <= 1) {
|
||||||
return true;
|
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;
|
//debugger;
|
||||||
runwayNodes = runwayNodes.filter(
|
runwayNodeIDs = runwayNodeIDs.filter(
|
||||||
(v, i) => isLegitEnd(v)
|
(v, i) => isLegitEnd(v)
|
||||||
);
|
);
|
||||||
// Check if there is a route from every parking to every runway node
|
// Check if there is a route from every parking to every runway node
|
||||||
var okNodes = [];
|
var okNodes = [];
|
||||||
logger('info', directionalGraph);
|
logger('info', directionalGraph);
|
||||||
parkings.forEach(parkingNode => {
|
parkings.forEach(parkingNode => {
|
||||||
runwayNodes.forEach(runwayNode => {
|
runwayNodeIDs.forEach(runwayNode => {
|
||||||
var ok = checkRoute(directionalGraph, parkingNode, runwayNode);
|
var ok = checkRoute(directionalGraph, parkingNode, runwayNode);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
okNodes.push(parkingNode);
|
okNodes.push(parkingNode);
|
||||||
@ -180,38 +191,38 @@ async function checkGroundnet(data) {
|
|||||||
parkings.forEach(parkingNode => {
|
parkings.forEach(parkingNode => {
|
||||||
pushbackNodes.forEach(pushbackNode => {
|
pushbackNodes.forEach(pushbackNode => {
|
||||||
var numRoutes = checkRoute(noPushbackGraph, parkingNode, pushbackNode);
|
var numRoutes = checkRoute(noPushbackGraph, parkingNode, pushbackNode);
|
||||||
if (numRoutes===0) {
|
if (numRoutes === 0) {
|
||||||
/*
|
/*
|
||||||
if(parkingNode===14) {
|
if(parkingNode===14) {
|
||||||
debugger;
|
debugger;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (multiplePushbackRoutes[parkingNode]===undefined &&
|
if (multiplePushbackRoutes[parkingNode] === undefined &&
|
||||||
Object.keys(noPushbackGraph[parkingNode])>0) {
|
Object.keys(noPushbackGraph[parkingNode]) > 0) {
|
||||||
// Only when there is a edge leaving
|
// Only when there is a edge leaving
|
||||||
multiplePushbackRoutes[parkingNode] = [];
|
multiplePushbackRoutes[parkingNode] = [];
|
||||||
}
|
}
|
||||||
} else if (numRoutes===1){
|
} else if (numRoutes === 1) {
|
||||||
if (multiplePushbackRoutes[parkingNode]===undefined) {
|
if (multiplePushbackRoutes[parkingNode] === undefined) {
|
||||||
multiplePushbackRoutes[parkingNode] = [pushbackNode];
|
multiplePushbackRoutes[parkingNode] = [pushbackNode];
|
||||||
} else {
|
} else {
|
||||||
multiplePushbackRoutes[parkingNode].push(pushbackNode);
|
multiplePushbackRoutes[parkingNode].push(pushbackNode);
|
||||||
}
|
}
|
||||||
} else if (numRoutes>1){
|
} else if (numRoutes > 1) {
|
||||||
if (multiplePushbackRoutes[parkingNode]===undefined) {
|
if (multiplePushbackRoutes[parkingNode] === undefined) {
|
||||||
multiplePushbackRoutes[parkingNode] = [pushbackNode];
|
multiplePushbackRoutes[parkingNode] = [pushbackNode];
|
||||||
} else {
|
} else {
|
||||||
multiplePushbackRoutes[parkingNode].push(pushbackNode);
|
multiplePushbackRoutes[parkingNode].push(pushbackNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.postMessage(['progress', 1]);
|
this.postMessage(['progress', 1]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
var rogueHoldPoints = pushbackNodes.map(
|
var rogueHoldPoints = pushbackNodes.map(
|
||||||
id => {
|
id => {
|
||||||
var routes = noPushbackGraph[id];
|
var routes = noPushbackGraph[id];
|
||||||
if(Object.keys(routes).length<1)
|
if (Object.keys(routes).length < 1)
|
||||||
return { id: id, message: 'Unconnected Pushbacknode' }
|
return { id: id, message: 'Unconnected Pushbacknode' }
|
||||||
/*
|
/*
|
||||||
else if(Object.keys(routes).length>1)
|
else if(Object.keys(routes).length>1)
|
||||||
return { id: id, message: 'Multiple connected pushback node' }
|
return { id: id, message: 'Multiple connected pushback node' }
|
||||||
@ -224,39 +235,39 @@ async function checkGroundnet(data) {
|
|||||||
return this[e] != undefined && this[e].length != 1;
|
return this[e] != undefined && this[e].length != 1;
|
||||||
}
|
}
|
||||||
, multiplePushbackRoutes).map(
|
, multiplePushbackRoutes).map(
|
||||||
id => {
|
id => {
|
||||||
var endPoints = multiplePushbackRoutes[id];
|
var endPoints = multiplePushbackRoutes[id];
|
||||||
if( endPoints.length<1)
|
if (endPoints.length < 1)
|
||||||
return { id: id, message: 'No way to pushback holdpoint' }
|
return { id: id, message: 'No way to pushback holdpoint' }
|
||||||
else
|
else
|
||||||
return { id: id, message: 'Multiple connected pushback points' }
|
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);
|
okNodes = okNodes.filter((v, i) => okNodes.indexOf(v) === i);
|
||||||
var notOkNodesParkings = parkings.filter(
|
var notOkNodesParkings = parkings.filter(
|
||||||
(v, i) => okNodes.indexOf(v) < 0
|
(v, i) => okNodes.indexOf(v) < 0
|
||||||
).map(
|
).map(
|
||||||
id => { return { id: id, message: 'No way from parking to each runway' } }
|
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
|
(v, i) => okNodes.indexOf(v) < 0
|
||||||
).map(
|
).map(
|
||||||
id => { return { id: id, message: 'No way from runway to each parking' } }
|
id => { return { id: id, message: 'No way from runway to each parking' } }
|
||||||
);
|
);
|
||||||
|
|
||||||
if (parkings.length === 0) {
|
if (parkings.length === 0) {
|
||||||
notOkNodes.push({ id: 0, message: 'No parkings' });
|
notOkNodes.push({ id: 0, message: 'No parkings' });
|
||||||
}
|
}
|
||||||
if (runwayNodes.length === 0) {
|
if (runwayNodeIDs.length === 0) {
|
||||||
notOkNodes.push({ id: 0, message: 'No Runwaynodes' });
|
notOkNodes.push({ id: 0, message: 'No Runwaynodes' });
|
||||||
}
|
}
|
||||||
var allEnds = Object.entries(bidirectionalGraph).filter(
|
var allEnds = Object.entries(bidirectionalGraph).filter(
|
||||||
(v, i) => Object.keys(v[1]).length <= 1
|
(v, i) => Object.keys(v[1]).length <= 1
|
||||||
);
|
);
|
||||||
// Ends that are not on Runway and not a Parking or Pushback
|
// 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(
|
var danglingEnds = allEnds.filter(
|
||||||
(v, i) => allLegitimateEndNodes.indexOf(Number(v[0])) < 0
|
(v, i) => allLegitimateEndNodes.indexOf(Number(v[0])) < 0
|
||||||
).map(
|
).map(
|
||||||
@ -268,7 +279,7 @@ async function checkGroundnet(data) {
|
|||||||
var overlappingParkings = [];
|
var overlappingParkings = [];
|
||||||
parkingNodes.forEach(parkingNode => {
|
parkingNodes.forEach(parkingNode => {
|
||||||
if (boxes[parkingNode.index] === undefined) {
|
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
|
// Check for intersecting radii
|
||||||
@ -281,17 +292,17 @@ async function checkGroundnet(data) {
|
|||||||
if (d < parkingNode.radius + parkingNode1.radius + 10) {
|
if (d < parkingNode.radius + parkingNode1.radius + 10) {
|
||||||
// If bigger circles intersect we should check the boxes
|
// If bigger circles intersect we should check the boxes
|
||||||
//debugger;
|
//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) {
|
boxes[parkingNode.index] !== undefined && boxes[parkingNode1.index] !== undefined) {
|
||||||
var poly1 = turf.polygon([boxes[parkingNode.index]]);
|
var poly1 = turf.polygon([boxes[parkingNode.index]]);
|
||||||
|
|
||||||
var poly2 = turf.polygon([boxes[parkingNode1.index]]);
|
var poly2 = turf.polygon([boxes[parkingNode1.index]]);
|
||||||
|
|
||||||
var intersection = turf.intersect(poly1, poly2);
|
var intersection = turf.intersect(poly1, poly2);
|
||||||
if( intersection !== null ) {
|
if (intersection !== null) {
|
||||||
overlappingParkings.push({ id: parkingNode.index, message: 'Overlapping parkings' });
|
overlappingParkings.push({ id: parkingNode.index, message: 'Overlapping parkings' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.postMessage(['progress', 1]);
|
this.postMessage(['progress', 1]);
|
||||||
@ -308,44 +319,60 @@ async function checkGroundnet(data) {
|
|||||||
invalidParkings.push({ id: parkingNode.index, message: 'Parking type empty' });
|
invalidParkings.push({ id: parkingNode.index, message: 'Parking type empty' });
|
||||||
this.postMessage(['progress', 1]);
|
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;
|
//debugger;
|
||||||
invalidParkings.push({ id: parkingNode.index, message: `Parking type ${parkingNode.parkingType} not valid` });
|
invalidParkings.push({ id: parkingNode.index, message: `Parking type ${parkingNode.parkingType} not valid` });
|
||||||
this.postMessage(['progress', 1]);
|
this.postMessage(['progress', 1]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//Check for dual pushback/runway nodes
|
//Check for dual pushback/runway nodes
|
||||||
runwayNodes.forEach(runwayNode => {
|
runwayNodeIDs.forEach(runwayNode => {
|
||||||
if (pushbackNodes.indexOf(runwayNode) >= 0) {
|
if (pushbackNodes.indexOf(runwayNode) >= 0) {
|
||||||
notOkNodes.push({ id: runwayNode, message: 'Dual runway/ pushback node' });
|
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);
|
notOkNodes = notOkNodes.concat(invalidParkings);
|
||||||
if (invalidParkings.length===0) {
|
if (invalidParkings.length === 0) {
|
||||||
notOkNodes.push({id:-1, message: 'Parkings valid'});
|
notOkNodes.push({ id: -1, message: 'Parkings valid' });
|
||||||
}
|
}
|
||||||
notOkNodes = notOkNodes.concat(overlappingParkings);
|
notOkNodes = notOkNodes.concat(overlappingParkings);
|
||||||
if (overlappingParkings.length===0) {
|
if (overlappingParkings.length === 0) {
|
||||||
notOkNodes.push({id:-1, message: 'No parkings overlapping'});
|
notOkNodes.push({ id: -1, message: 'No parkings overlapping' });
|
||||||
}
|
}
|
||||||
notOkNodes = notOkNodes.concat(danglingEnds);
|
notOkNodes = notOkNodes.concat(danglingEnds);
|
||||||
if (danglingEnds.length===0) {
|
if (danglingEnds.length === 0) {
|
||||||
notOkNodes.push({id:-1, message: 'No invalid ends'});
|
notOkNodes.push({ id: -1, message: 'No invalid ends' });
|
||||||
}
|
}
|
||||||
notOkNodes = notOkNodes.concat(notOkNodesParkings).concat(rogueHoldPoints);
|
notOkNodes = notOkNodes.concat(notOkNodesParkings).concat(rogueHoldPoints);
|
||||||
if (notOkNodesParkings.length===0 && rogueHoldPoints===0) {
|
if (notOkNodesParkings.length === 0 && rogueHoldPoints === 0) {
|
||||||
notOkNodes.push({id:-1, message: 'Routes from parkings OK'});
|
notOkNodes.push({ id: -1, message: 'Routes from parkings OK' });
|
||||||
}
|
}
|
||||||
|
|
||||||
notOkNodes = notOkNodes.concat(notOkNodesRunways);
|
notOkNodes = notOkNodes.concat(notOkNodesRunways);
|
||||||
if (notOkNodesRunways.length===0) {
|
if (notOkNodesRunways.length === 0) {
|
||||||
notOkNodes.push({id:-1, message: 'Routes from runways OK'});
|
notOkNodes.push({ id: -1, message: 'Routes from runways OK' });
|
||||||
}
|
}
|
||||||
notOkNodes = notOkNodes.concat(wrongPushbackRoutes);
|
notOkNodes = notOkNodes.concat(wrongPushbackRoutes);
|
||||||
if (wrongPushbackRoutes.length===0) {
|
if (wrongPushbackRoutes.length === 0) {
|
||||||
notOkNodes.push({id:-1, message: 'Pushback routes OK'});
|
notOkNodes.push({ id: -1, message: 'Pushback routes OK' });
|
||||||
}
|
}
|
||||||
// check1(directionalGraph);
|
// check1(directionalGraph);
|
||||||
// check2();
|
// check2();
|
||||||
@ -417,12 +444,26 @@ var mapBoxes = function (o) {
|
|||||||
return { index: o.index };
|
return { index: o.index };
|
||||||
}
|
}
|
||||||
|
|
||||||
var mapRunwayNodes = function (o) {
|
var mapRunwayNodeId = function (o) {
|
||||||
if (o.type === 'runway')
|
if (o.type === 'runway')
|
||||||
return o.index;
|
return o.index;
|
||||||
console.debug(o);
|
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) {
|
var mapEdges = function (o) {
|
||||||
if (o.type === 'poly')
|
if (o.type === 'poly')
|
||||||
// debugger;
|
// debugger;
|
||||||
@ -432,3 +473,17 @@ var mapEdges = function (o) {
|
|||||||
};
|
};
|
||||||
console.debug(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');
|
process.chdir('src/renderer/utils');
|
||||||
|
|
||||||
describe("Test Check", function() {
|
describe("Test Check", function () {
|
||||||
it("Not legitimate End", function(done) {
|
describe("Routing Checks", function () {
|
||||||
var data = [
|
it("Not legitimate End", function (done) {
|
||||||
{ '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) {
|
|
||||||
var data = [
|
var data = [
|
||||||
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, 'direction': 'bi-directional'},
|
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true }
|
||||||
{ 'index': 1, '_leaflet_id': 2, 'type': 'runway' }
|
|
||||||
];
|
];
|
||||||
var worker = new Worker('check.js');
|
var worker = new Worker('check.js');
|
||||||
worker.onmessage = function (e) {
|
worker.onmessage = function (e) {
|
||||||
if (e.data === 'checkStarted') {
|
if (e.data === 'checkStarted') {
|
||||||
} else if (e.data[0] === 'DONE') {
|
} else if (e.data[0] === 'DONE') {
|
||||||
console.log('DONE')
|
console.log('DONE')
|
||||||
worker.terminate()
|
worker.terminate()
|
||||||
if(e.data[1].length===0) {
|
if (e.data[1].length === 0) {
|
||||||
done('Crashed')
|
done('Crashed')
|
||||||
} else {
|
} else {
|
||||||
console.log(e.data[1]);
|
console.log(e.data[1]);
|
||||||
console.log(e.data[1].filter(m => m.id === 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 === 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.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.message === 'No invalid ends'), 0);
|
||||||
|
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
} else if (e.data.length > 0) {
|
} else if (e.data.length > 0) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
worker.postMessage(['check', data]);
|
worker.postMessage(['check', data]);
|
||||||
});
|
});
|
||||||
|
it("Legitimate End Runway", function (done) {
|
||||||
it("From Parking to Runway bi-directional", function(done) {
|
var data = [
|
||||||
var data = [
|
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, 'direction': 'bi-directional' },
|
||||||
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, direction: 'bi-directional'},
|
{ 'index': 1, '_leaflet_id': 2, 'type': 'runway' }
|
||||||
{ '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) {
|
||||||
var worker = new Worker('check.js');
|
if (e.data === 'checkStarted') {
|
||||||
worker.onmessage = function (e) {
|
} else if (e.data[0] === 'DONE') {
|
||||||
if (e.data === 'checkStarted') {
|
console.log('DONE')
|
||||||
} else if (e.data[0] === 'DONE') {
|
worker.terminate()
|
||||||
console.log('DONE')
|
if (e.data[1].length === 0) {
|
||||||
worker.terminate()
|
done('Crashed')
|
||||||
if(e.data[1].length===0) {
|
} else {
|
||||||
done('Crashed')
|
console.log(e.data[1]);
|
||||||
} else {
|
console.log(e.data[1].filter(m => m.id === 1));
|
||||||
console.log(e.data[1]);
|
assert.lengthOf(e.data[1].filter(m => m.id === 1).filter(m => m.message === 'No way from runway to each parking'), 1);
|
||||||
console.log(e.data[1].filter(m => m.id === 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.id === -1).filter(m => m.message=== 'Routes from runways OK'), 1);
|
assert.lengthOf(e.data[1].filter(m => m.message === 'No invalid ends'), 0);
|
||||||
assert.lengthOf(e.data[1].filter(m => m.message=== 'No invalid ends'), 1);
|
done()
|
||||||
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) {
|
it("From Parking to Runway bi-directional", function (done) {
|
||||||
var data = [
|
var data = [
|
||||||
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, direction: 'forward'},
|
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, direction: 'bi-directional' },
|
||||||
{ 'index': 1, '_leaflet_id': 3, 'name': 'name', parkingType:'gate', 'type': 'parking' },
|
{ 'index': 1, '_leaflet_id': 2, 'type': 'runway' },
|
||||||
{ 'index': 2, '_leaflet_id': 2, 'type': 'runway' }
|
{ 'index': 2, '_leaflet_id': 3, 'name': 'name', parkingType: 'gate', 'type': 'parking' }
|
||||||
];
|
];
|
||||||
var worker = new Worker('check.js');
|
var worker = new Worker('check.js');
|
||||||
worker.onmessage = function (e) {
|
worker.onmessage = function (e) {
|
||||||
if (e.data === 'checkStarted') {
|
if (e.data === 'checkStarted') {
|
||||||
} else if (e.data[0] === 'DONE') {
|
} else if (e.data[0] === 'DONE') {
|
||||||
console.log('DONE')
|
console.log('DONE')
|
||||||
worker.terminate()
|
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) {
|
it("From Parking to Runway forward OK", function (done) {
|
||||||
done('Crashed')
|
var data = [
|
||||||
} else {
|
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, direction: 'forward' },
|
||||||
console.log(e.data[1]);
|
{ 'index': 1, '_leaflet_id': 3, 'name': 'name', parkingType: 'gate', 'type': 'parking' },
|
||||||
console.log(e.data[1].filter(m => m.id === 1));
|
{ 'index': 2, '_leaflet_id': 2, 'type': 'runway' }
|
||||||
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);
|
var worker = new Worker('check.js');
|
||||||
done()
|
worker.onmessage = function (e) {
|
||||||
}
|
if (e.data === 'checkStarted') {
|
||||||
} else if (e.data.length > 0) {
|
} else if (e.data[0] === 'DONE') {
|
||||||
}
|
console.log('DONE')
|
||||||
};
|
worker.terminate()
|
||||||
worker.postMessage(['check', data]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("From Parking to Runway forward Not Ok", function(done) {
|
if (e.data[1].length === 0) {
|
||||||
var data = [
|
done('Crashed')
|
||||||
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, direction: 'forward'},
|
} else {
|
||||||
{ 'index': 2, '_leaflet_id': 3, 'name': 'name', parkingType:'gate', 'type': 'parking' },
|
console.log(e.data[1]);
|
||||||
{ 'index': 1, '_leaflet_id': 2, 'type': 'runway' }
|
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);
|
||||||
var worker = new Worker('check.js');
|
assert.lengthOf(e.data[1].filter(m => m.message === 'No invalid ends'), 1);
|
||||||
worker.onmessage = function (e) {
|
done()
|
||||||
if (e.data === 'checkStarted') {
|
}
|
||||||
} else if (e.data[0] === 'DONE') {
|
} else if (e.data.length > 0) {
|
||||||
console.log('DONE')
|
}
|
||||||
worker.terminate()
|
};
|
||||||
|
worker.postMessage(['check', data]);
|
||||||
|
});
|
||||||
|
|
||||||
if(e.data[1].length===0) {
|
it("From Parking to Runway forward Not Ok", function (done) {
|
||||||
done('Crashed')
|
var data = [
|
||||||
} else {
|
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, direction: 'forward' },
|
||||||
console.log(e.data[1]);
|
{ 'index': 2, '_leaflet_id': 3, 'name': 'name', parkingType: 'gate', 'type': 'parking' },
|
||||||
console.log(e.data[1].filter(m => m.id === 1));
|
{ 'index': 1, '_leaflet_id': 2, 'type': 'runway' }
|
||||||
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);
|
var worker = new Worker('check.js');
|
||||||
done()
|
worker.onmessage = function (e) {
|
||||||
}
|
if (e.data === 'checkStarted') {
|
||||||
} else if (e.data.length > 0) {
|
} else if (e.data[0] === 'DONE') {
|
||||||
}
|
console.log('DONE')
|
||||||
};
|
worker.terminate()
|
||||||
worker.postMessage(['check', data]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("From Parking to Runway reverse OK", function(done) {
|
if (e.data[1].length === 0) {
|
||||||
var data = [
|
done('Crashed')
|
||||||
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, direction: 'backward'},
|
} else {
|
||||||
{ 'index': 2, '_leaflet_id': 3, 'name': 'name', parkingType:'gate', 'type': 'parking' },
|
console.log(e.data[1]);
|
||||||
{ 'index': 1, '_leaflet_id': 2, 'type': 'runway' }
|
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);
|
||||||
var worker = new Worker('check.js');
|
assert.lengthOf(e.data[1].filter(m => m.message === 'No invalid ends'), 1);
|
||||||
worker.onmessage = function (e) {
|
done()
|
||||||
if (e.data === 'checkStarted') {
|
}
|
||||||
} else if (e.data[0] === 'DONE') {
|
} else if (e.data.length > 0) {
|
||||||
console.log('DONE')
|
}
|
||||||
worker.terminate()
|
};
|
||||||
if(e.data[1].length===0) {
|
worker.postMessage(['check', data]);
|
||||||
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) {
|
it("From Parking to Runway reverse OK", function (done) {
|
||||||
var data = [
|
var data = [
|
||||||
{ 'start': 1, 'end': 2, '_leaflet_id': 1, 'type': 'poly', 'isPushBackRoute': true, direction: 'backward'},
|
{ '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': 3, 'name': 'name', parkingType: 'gate', 'type': 'parking' },
|
||||||
{ 'index': 2, '_leaflet_id': 2, 'type': 'runway' }
|
{ 'index': 1, '_leaflet_id': 2, 'type': 'runway' }
|
||||||
];
|
];
|
||||||
var worker = new Worker('check.js');
|
var worker = new Worker('check.js');
|
||||||
worker.onmessage = function (e) {
|
worker.onmessage = function (e) {
|
||||||
if (e.data === 'checkStarted') {
|
if (e.data === 'checkStarted') {
|
||||||
} else if (e.data[0] === 'DONE') {
|
} else if (e.data[0] === 'DONE') {
|
||||||
console.log('DONE')
|
console.log('DONE')
|
||||||
worker.terminate()
|
worker.terminate()
|
||||||
if(e.data[1].length===0) {
|
if (e.data[1].length === 0) {
|
||||||
done('Crashed')
|
done('Crashed')
|
||||||
} else {
|
} else {
|
||||||
console.log(e.data[1]);
|
console.log(e.data[1]);
|
||||||
console.log(e.data[1].filter(m => m.id === 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.id === -1).filter(m => m.message === 'Routes from runways OK'), 1);
|
||||||
assert.lengthOf(e.data[1].filter(m => m.message=== 'No invalid ends'), 1, 'No invalid ends');
|
assert.lengthOf(e.data[1].filter(m => m.message === 'No invalid ends'), 1);
|
||||||
done()
|
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 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