Check Intersection

This commit is contained in:
portree_kid 2020-03-07 21:35:41 +01:00
parent 9eb92fb13d
commit 2f86bed0bf
6 changed files with 86 additions and 6 deletions

View File

@ -27,4 +27,5 @@ deploy:
secure: Xm3z86gQmpSajvlXSVgG7mxcaS5K7GfE4HrARIDR4pQ4UguQ3/fFOenRyKAQImmH0kLCSIbVE21NMAQ3YI2F9El9I6GU7Wirccsg14TZZiBQAzKOTXZ+JsBloeBxuTOsR84SkO6pV8OT/pRnQd9frqyc1W7wzoX+0sQykMztXCNfI+1MXXGOAgMzlKuDMO1PVENz0V63mWipL/Mae/SyrHa1Bws+4LJKvv42m0HMKdN7ekt41vxcSUvLmN+YLlqUEVr/eUhQXUNCaWlmM0KxmfuzTedca5/1yzLvN8smEt2I2b0DFRM3Mi/QdI22fVRHs6XGpm8yqZRKmhySDXFspXKWBiuCF6AezX6NiIe/ZUh10gIukjkyLtrNk/o29qhj2WE9HJz4xhsGMAx3632cLSMPku5ALN7jv5scWjwCGNHs4ZeZyyePMeGM6Y6pje1uJPbxWGjwoV6iI4Y4esP+z3KcXvZdnzkpYMy2mzdT4gf7A7zieax1YwB6U/MEanXYKFBH4yzYK9+hx3ck2eLT3LcV/ChHN2bKmERJdf18h+zI8e5YKTzd3/kHLiUUv19N2a4TUYloGOyzrLwn2VD1Xm4jJVVLTIQvWbH5YK7cNkHYa4+PnsB+JppSoby7HiBcothw4OLpJO8eCMqXcPRU1n+cRAZTB7VOS7pWh8e8LFE=
file: build/*
on:
branch: master
repo: Portree-Kid/flightgear-airports

View File

@ -167,7 +167,13 @@
},
featuresMapper(o) {
if (o instanceof L.ParkingSpot) {
return { 'index': Number(o['id']), '_leaflet_id': o._leaflet_id, 'type': 'parking', 'name': o.options.attributes.name, 'radius': String(o.options.attributes.radius) };
return { 'index': Number(o['id']),
'_leaflet_id': o._leaflet_id,
'type': 'parking',
'name': o.options.attributes.name,
'radius': String(o.options.attributes.radius),
'lat': o._latlng.lat,
'lng': o._latlng.lng };
} else if (o instanceof L.RunwayNode) {
console.log(o)
return { 'index': Number(o['glueindex']), '_leaflet_id': o._leaflet_id, 'type': 'runway' };

View File

@ -9,7 +9,7 @@
ref="map"
>
<!--The backgroundmap-->
<l-tile-layer :url="url" :attribution="attribution">
<l-tile-layer :url="url" :attribution="attribution" :options="{maxZoom: 22, maxNativeZoom: 19}">
</l-tile-layer>
<!--<l-marker :lat-lng="marker"></l-marker>-->
<LeafletSidebar></LeafletSidebar>

View File

@ -36,6 +36,24 @@ var scanMethods = {
});
return promise;
},
18: async (l, apts) => {
var promise = new Promise(function (resolve, reject) {
logger('info','Airport light beacon:', l);
saveCoordinates(apts, icao, l[1], l[2]).then(result => {
resolve(result)
}).catch( err => {reject(err)});;
});
return promise;
},
19: async (l, apts) => {
var promise = new Promise(function (resolve, reject) {
logger('info','Windsock:', l);
saveCoordinates(apts, icao, l[1], l[2]).then(result => {
resolve(result)
}).catch( err => {reject(err)});;
});
return promise;
},
99: async (l) => {
logger('info','Finished');
}
@ -107,7 +125,14 @@ async function saveCoordinates(features, icao, lat, lon) {
}
};
}
feature.geometry.coordinates = [lon, lat];
if (!feature.geometry.coordinates || isNaN(feature.geometry.coordinates[0]) || isNaN(feature.geometry.coordinates[1])) {
feature.geometry.coordinates = [lon, lat];
} else {
var avgLon = (Number(lon) + Number(feature.geometry.coordinates[0])) / 2;
var avgLat = (Number(lat) + Number(feature.geometry.coordinates[1])) / 2;
feature.geometry.coordinates = [avgLon, avgLat];
}
logger('info',"ICAO : " + feature.properties.icao);
// Create another request that inserts the item back into the database
var updateAirportRequest = objectStore.put(feature);

View File

@ -11,6 +11,7 @@ importScripts('../../../node_modules/dijkstrajs/dijkstra.js');
const homedir = require('os').homedir();
importScripts('logger.js');
importScripts('haversine.js');
function errorReceiver(event) {
throw event.data;
@ -27,8 +28,8 @@ onmessage = function (event) {
// event.origin.webContents.send('scanFinished');
}
).catch(result => {
console.log('Crashed');
console.log(result);
console.error('Crashed');
console.error(result);
postMessage('DONE');
});
}
@ -41,7 +42,8 @@ async function checkGroundnet(data) {
var parkings = data.map(mapParkings).filter(n => n !== undefined);
var runwayNodes = data.map(mapRunwayNodes).filter(n => n !== undefined);
var edges = data.map(mapEdges).filter(n => n !== undefined);
this.max = parkings.length * runwayNodes.length;
this.max = parkings.length * runwayNodes.length +
parkings.length;
this.postMessage(['max', this.max]);
var graph = {};
@ -61,6 +63,7 @@ async function checkGroundnet(data) {
var node2 = graph[element.end];
node2[Number(element.start)] = 1;
});
// Check if there is a route from every parking to every runway node
var okNodes = [];
logger('info', graph);
parkings.forEach(parkingNode => {
@ -86,6 +89,7 @@ async function checkGroundnet(data) {
if (runwayNodes.length === 0) {
notOkNodes.push({id:0, message:'No Runwaynodes'});
}
// Ends that are not on Runway and not a Parking
var danglingEnds = Object.entries(graph).filter(
(v,i) => Object.keys(v[1]).length <= 1
).filter(
@ -94,6 +98,23 @@ async function checkGroundnet(data) {
v => {return {id:Number(v[0]), message:'Node not a legimate end'}}
);
notOkNodes = notOkNodes.concat(danglingEnds);
var parkingNodes = data.map(mapParkingNode).filter(n => n !== undefined);
// Check for intersecting radii
parkingNodes.forEach(parkingNode => {
parkingNodes.forEach( parkingNode1 => {
console.log(parkingNode, parkingNode1);
if(parkingNode.index !== parkingNode1.index) {
var d = distance([parkingNode.lng, parkingNode.lat],
[parkingNode1.lng, parkingNode1.lat]);
if (d < parkingNode.radius + parkingNode1.radius) {
notOkNodes.push({id: parkingNode.index, message:'Intersecting node'});
}
}
this.postMessage(['progress', 1]);
});
});
// check1(graph);
// check2();
@ -146,6 +167,12 @@ var mapParkings = function (o) {
console.log(o);
}
var mapParkingNode = function (o) {
if(o.type === 'parking')
return {index: o.index, lat:o.lat, lng:o.lng, radius: Number(o.radius)};
console.log(o);
}
var mapRunwayNodes = function (o) {
if(o.type === 'runway')
return o.index;

View File

@ -0,0 +1,21 @@
var earthRadius = 6371008.8;
function distance(point1, point2) {
var dLat = degrees_to_radians((point2[1] - point1[1]));
var dLon = degrees_to_radians((point2[0] - point1[0]));
var lat1 = degrees_to_radians(point1[1]);
var lat2 = degrees_to_radians(point2[1]);
var a = Math.pow(Math.sin(dLat / 2), 2) +
Math.pow(Math.sin(dLon / 2), 2) * Math.cos(lat1) * Math.cos(lat2);
return earthRadius * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
}
function degrees_to_radians(degrees)
{
var pi = Math.PI;
return degrees * (pi/180);
}