diff --git a/atc.js b/atc.js index 367fdfc..58363ea 100644 --- a/atc.js +++ b/atc.js @@ -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 @@ -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{ @@ -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) diff --git a/pilots.js b/pilots.js index 149bb79..e14b9ed 100644 --- a/pilots.js +++ b/pilots.js @@ -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)], diff --git a/public/map.js b/public/map.js index 699b17f..c0698f3 100644 --- a/public/map.js +++ b/public/map.js @@ -216,6 +216,7 @@ async function getPilots() { } var json = await response.json(); pilots = json; + setPilotMarkers(); return json; }; @@ -674,13 +675,14 @@ async function setPilotMarkers() { reload = true; }); } + + updatePilotsLayer(); + } catch (err) { console.log(err) } }; -getPilots(); - (async () => { var dataset = await getDataset(); //console.(dataset); @@ -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') }