Check for parking type

This commit is contained in:
portree_kid 2020-06-18 22:10:44 +02:00
parent bd7530a9a1
commit 33421e5aab
5 changed files with 63 additions and 56 deletions

View File

@ -223,6 +223,7 @@
return { 'index': Number(o['id']), return { 'index': Number(o['id']),
'_leaflet_id': o._leaflet_id, '_leaflet_id': o._leaflet_id,
'type': 'parking', 'type': 'parking',
'parkingType': o.options.attributes.type,
'name': o.options.attributes.name, 'name': o.options.attributes.name,
'radius': String(o.options.attributes.radius), 'radius': String(o.options.attributes.radius),
'lat': o._latlng.lat, 'lat': o._latlng.lat,

View File

@ -103,6 +103,7 @@
return { 'index': Number(o['id']), return { 'index': Number(o['id']),
'_leaflet_id': o._leaflet_id, '_leaflet_id': o._leaflet_id,
'type': 'parking', 'type': 'parking',
'parkingType': o.options.attributes.type,
'name': o.options.attributes.name, 'name': o.options.attributes.name,
'radius': String(o.options.attributes.radius), 'radius': String(o.options.attributes.radius),
'lat': o._latlng.lat, 'lat': o._latlng.lat,

View File

@ -117,6 +117,8 @@ L.ParkingSpot = L.Circle.extend({
} }
}, },
select() { select() {
store.default.dispatch('setParking', this.options.attributes);
store.default.dispatch('setParkingCoords', this.getLatLng().lat.toFixed(5) + ' ' + this.getLatLng().lng.toFixed(5));
var style = {}; var style = {};
style['color'] = 'red'; style['color'] = 'red';
this.setStyle(style); this.setStyle(style);
@ -176,8 +178,6 @@ L.ParkingSpot = L.Circle.extend({
} }
}); });
} }
store.default.dispatch('setParking', event.target.options.attributes);
store.default.dispatch('setParkingCoords', event.target.getLatLng().lat.toFixed(5) + ' ' + event.target.getLatLng().lng.toFixed(5));
this.select(); this.select();
}); });
this.on('editable:vertex:clicked', function (event) { this.on('editable:vertex:clicked', function (event) {

View File

@ -73,26 +73,29 @@ exports.extendTaxiSegment = function (taxiwaySegment) {
this.options.attributes.selected = false; this.options.attributes.selected = false;
this.updateStyle(); this.updateStyle();
this.getLatLngs().forEach( element => { this.getLatLngs().forEach( element => {
if (element.__vertex._icon != null) { if (element.__vertex!==undefined) {
element.__vertex._icon.style['background-color'] = 'white'; if (element.__vertex._icon != null) {
} else if (element.vertex.icon != null) { element.__vertex._icon.style['background-color'] = 'white';
if (element.__vertex.icon.style != null) { } else if (element.__vertex.icon != null) {
element.__vertex.icon.style['background-color'] = 'white'; if (element.__vertex.icon.style != null) {
} else { element.__vertex.icon.style['background-color'] = 'white';
element.__vertex.setStyle({ color: 'white' }) } else {
} element.__vertex.setStyle({ color: 'white' })
} else if (element.__vertex.options.icon != null) { }
if (element.__vertex.options.icon.style != null) { } else if (element.__vertex.options.icon != null) {
element.__vertex.options.icon.style['background-color'] = 'white'; if (element.__vertex.options.icon.style != null) {
} else { element.__vertex.options.icon.style['background-color'] = 'white';
element.__vertex.options.icon._setIconStyles({ color: 'white' }) } else {
element.__vertex.options.icon._setIconStyles({ color: 'white' })
}
} }
} }
}); });
}; };
taxiwaySegment.__proto__.addListeners = function () { taxiwaySegment.__proto__.addListeners = function () {
this.on('click', function (event) { this.on('click', function (event) {
if (Number(store.default.state.Editable.index) >= 0) { if (Number(store.default.state.Editable.index) >= 0 &&
this.featureLookup[store.default.state.Editable.index] !== undefined) {
this.featureLookup[store.default.state.Editable.index].forEach(element => { this.featureLookup[store.default.state.Editable.index].forEach(element => {
element.deselect(); element.deselect();
}); });
@ -286,14 +289,17 @@ exports.extendTaxiSegment = function (taxiwaySegment) {
style.color = '#3388ff'; style.color = '#3388ff';
} }
this.setStyle(style); this.setStyle(style);
if (this.options.attributes.direction === 'forward') { if(this._map !== null) {
this.setText(null); if (this.options.attributes.direction === 'forward') {
this.setText(' ⮞ ', { repeat: true, attributes: { fill: 'red', size: 30 } }) this.setText(null);
} else if (this.options.attributes.direction === 'backward') { this.setText(' ⮞ ', { repeat: true, attributes: { fill: 'red', size: 30 } })
this.setText(null); } else if (this.options.attributes.direction === 'backward') {
this.setText(' ⮜ ', { repeat: true, attributes: { fill: 'red', size: 30 } }) this.setText(null);
} else { this.setText(' ⮜ ', { repeat: true, attributes: { fill: 'red', size: 30 } })
this.setText(null); } else {
this.setText(null);
}
} }
}; };
}; };

View File

@ -6,7 +6,11 @@ const winURL = process.env.NODE_ENV === 'development'
var path = require('path'); var path = require('path');
const fs = require('fs'); const fs = require('fs');
importScripts('dijkstra.js'); if(process.env.NODE_ENV === 'development') {
importScripts('../../../node_modules/dijkstrajs/dijkstra.js');
} else {
importScripts('dijkstra.js');
}
const homedir = require('os').homedir(); const homedir = require('os').homedir();
@ -136,7 +140,6 @@ async function checkGroundnet(data) {
); );
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
@ -165,21 +168,10 @@ async function checkGroundnet(data) {
).map( ).map(
v => { return { id: Number(v[0]), message: 'Node not a legimate end' } } v => { return { id: Number(v[0]), message: 'Node not a legimate end' } }
); );
notOkNodes = notOkNodes.concat(danglingEnds);
notOkNodes = notOkNodes.concat(notOkNodesParkings);
notOkNodes = notOkNodes.concat(notOkNodesRunways);
// Ends that are not on Runway and not a Parking or Pushback
/*var wrongPushbackEnds = pushbackNodes.filter(
(v, i) => allEnds.map(a => Number(a[0])).indexOf(Number(v)) < 0
).map(
v => { return { id: Number(v), message: 'Pushback node not an end' } }
);
notOkNodes = notOkNodes.concat(wrongPushbackEnds)*/
notOkNodes = notOkNodes.concat(wrongPushbackRoutes);
var parkingNodes = data.map(mapParkingNode).filter(n => n !== undefined); var parkingNodes = data.map(mapParkingNode).filter(n => n !== undefined);
var overlappingParkings = [];
// Check for intersecting radii // Check for intersecting radii
parkingNodes.forEach(parkingNode => { parkingNodes.forEach(parkingNode => {
parkingNodes.forEach(parkingNode1 => { parkingNodes.forEach(parkingNode1 => {
@ -188,30 +180,30 @@ async function checkGroundnet(data) {
var d = distance([parkingNode.lng, parkingNode.lat], var d = distance([parkingNode.lng, parkingNode.lat],
[parkingNode1.lng, parkingNode1.lat]); [parkingNode1.lng, parkingNode1.lat]);
if (d < parkingNode.radius + parkingNode1.radius) { if (d < parkingNode.radius + parkingNode1.radius) {
notOkNodes.push({ id: parkingNode.index, message: 'Overlapping parkings' }); overlappingParkings.push({ id: parkingNode.index, message: 'Overlapping parkings' });
} }
} }
this.postMessage(['progress', 1]); this.postMessage(['progress', 1]);
}); });
}); });
// Check for name var invalidParkings = [];
parkingNodes.forEach(parkingNode => {
if (!parkingNode.name) {
notOkNodes.push({ id: parkingNode.index, message: 'Name empty' });
this.postMessage(['progress', 1]);
}
if (!parkingNode.type) {
notOkNodes.push({ id: parkingNode.index, message: 'Parking type empty' });
this.postMessage(['progress', 1]);
}
});
// Check for name // Check for name
parkingNodes.forEach(parkingNode => { parkingNodes.forEach(parkingNode => {
if (!parkingNode.name || /^\s*$/.test(parkingNode.name)) { if (!parkingNode.name || /^\s*$/.test(parkingNode.name)) {
notOkNodes.push({ id: parkingNode.index, message: 'Empty name' }); invalidParkings.push({ id: parkingNode.index, message: 'Name empty' });
this.postMessage(['progress', 1]);
}
if (!parkingNode.type) {
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) {
//debugger;
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 => { runwayNodes.forEach(runwayNode => {
if (pushbackNodes.indexOf(runwayNode) >= 0) { if (pushbackNodes.indexOf(runwayNode) >= 0) {
@ -219,6 +211,12 @@ async function checkGroundnet(data) {
} }
}); });
notOkNodes = notOkNodes.concat(invalidParkings);
notOkNodes = notOkNodes.concat(overlappingParkings);
notOkNodes = notOkNodes.concat(danglingEnds);
notOkNodes = notOkNodes.concat(notOkNodesParkings);
notOkNodes = notOkNodes.concat(notOkNodesRunways);
notOkNodes = notOkNodes.concat(wrongPushbackRoutes);
// check1(graph); // check1(graph);
// check2(); // check2();
// this.postMessage(['progress', 1]); // this.postMessage(['progress', 1]);
@ -278,8 +276,9 @@ var mapParkings = function (o) {
} }
var mapParkingNode = function (o) { var mapParkingNode = function (o) {
// debugger;
if (o.type === 'parking') if (o.type === 'parking')
return { index: o.index, lat: o.lat, lng: o.lng, name: o.name, radius: Number(o.radius), type: o.type }; return { index: o.index, lat: o.lat, lng: o.lng, name: o.name, radius: Number(o.radius), type: o.type, parkingType: o.parkingType };
console.log(o); console.log(o);
} }