Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
zachbf committed Jan 29, 2023
1 parent 6fab452 commit 688b647
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
11 changes: 7 additions & 4 deletions atc.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export async function getOnlinePositions() {
var onlineSectors = [];
var sectors = await getATCSectors();
var stations = await getVatsimAFV();
var sectorWithSubsectors = false;

// SY_APP 124.400 AFV 124400000
// iterate txvrs.element.transceivers.element frequency/1000000
Expand All @@ -254,7 +255,7 @@ export async function getOnlinePositions() {

// Check std sectors and load sub sectors.
if(element.standard_position === true && element.responsibleSectors.length > 0){
var sectorWithSubsectors = mergeSectors(element, element.responsibleSectors,sectors);
sectorWithSubsectors = mergeSectors(element, element.responsibleSectors,sectors);

onlineSectors.push(sectorWithSubsectors);
}else{
Expand All @@ -272,13 +273,15 @@ export async function getOnlinePositions() {
})

activeFrequencies = uniq(activeFrequencies);
var type = station.callsign.toUpperCase().includes("CTR");

if(activeFrequencies.length > 1){
if(activeFrequencies.length > 1 && type){

activeFrequencies.forEach(function(frequency){
sectors.find(function cb(element){
sectors.find(function cb(element){

if(element.Frequency == frequency && element.Callsign != station.callsign){

if(element.Frequency === frequency && element.Callsign != station.callsign){
var subSectorWithSubsectors = mergeSectors(element, element.responsibleSectors,sectors);

var poly1 = turf.polygon(sectorWithSubsectors.geometry.coordinates)
Expand Down
5 changes: 5 additions & 0 deletions pilots.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export async function getPilots(){

function pilotsInFIR(firs, aerodromes, data){
var pilotsInFIR = [];
if(!data.pilots){
console.log('no data.pilots')
return false;
}

data.pilots.forEach(function(pilot) {
var ppos = point(
[(pilot.longitude), (pilot.latitude)],
Expand Down
12 changes: 6 additions & 6 deletions public/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ async function getPilots() {
}
var json = await response.json();
pilots = json;
setPilotMarkers();
return json;
};

Expand Down Expand Up @@ -674,13 +675,14 @@ async function setPilotMarkers() {
reload = true;
});
}

updatePilotsLayer();

} catch (err) {
console.log(err)
}
};

getPilots();

(async () => {
var dataset = await getDataset();
//console.(dataset);
Expand All @@ -701,16 +703,14 @@ map.on('load', function () {
zoom: findGetParameter('zoom') || 4,
})

setPilotsLayer();
//setPilotMarkers();
//setPilotsLayer();

// Main loop
setAsyncInterval(async () => {
const promise = new Promise((resolve) => {
if (reload) {
getATCSectors();
setPilotMarkers(getPilots());
updatePilotsLayer();
getPilots();
} else {
//console.log('Reload inhibited')
}
Expand Down

0 comments on commit 688b647

Please sign in to comment.