Skip to content

Commit

Permalink
bug fix performance again
Browse files Browse the repository at this point in the history
  • Loading branch information
zachbf committed Jan 29, 2023
1 parent 3ae9072 commit 668c6cd
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 1,783 deletions.
138 changes: 71 additions & 67 deletions atc.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,84 +242,88 @@ export async function getOnlinePositions() {

// SY_APP 124.400 AFV 124400000
// iterate txvrs.element.transceivers.element frequency/1000000
stations.forEach(function(station, index){
// Keep only CTR, APP, and TWR.
if(station.callsign.toUpperCase().includes("CTR") === false && station.callsign.toUpperCase().includes("APP") === false && station.callsign.toUpperCase().includes("TWR") === false){
delete stations[index];
}else{

// Join sectors by callsign
var sector = sectors.find(function cb(element){
if(element.Callsign === station.callsign){

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

onlineSectors.push(sectorWithSubsectors);
}else{
onlineSectors.push(mergeBoundaries(element));
}

// check if other frequencies are active and show them as online.
// this only works for ENR sectors.

var activeFrequencies = [];
station.transceivers.forEach(function(element){
// Hertz to Megahurts
element.frequency = element.frequency/1000000;
activeFrequencies.push(element.frequency.toFixed(3));
})
if(stations){
stations.forEach(function(station, index){
// Keep only CTR, APP, and TWR.
if(station.callsign.toUpperCase().includes("CTR") || station.callsign.toUpperCase().includes("APP") || station.callsign.toUpperCase().includes("TWR"))
{
// Join sectors by callsign
var sector = sectors.find(function cb(element){
if(element.Callsign == station.callsign){

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

if(activeFrequencies.length > 1){
onlineSectors.push(sectorWithSubsectors);
}else{
onlineSectors.push(mergeBoundaries(element));
}

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

activeFrequencies = uniq(activeFrequencies);
var type = station.callsign.toUpperCase().includes("CTR");
// check if other frequencies are active and show them as online.
// this only works for ENR sectors.

if(element.Frequency == frequency && element.Callsign != station.callsign && type){
var activeFrequencies = [];
station.transceivers.forEach(function(element){
// Hertz to Megahurts
element.frequency = element.frequency/1000000;
activeFrequencies.push(element.frequency.toFixed(3));
})

var subSectorWithSubsectors = mergeSectors(element, element.responsibleSectors,sectors);
if(activeFrequencies.length > 1){

var poly1 = turf.polygon(sectorWithSubsectors.geometry.coordinates)
var poly2 = turf.polygon(subSectorWithSubsectors.geometry.coordinates)
activeFrequencies.forEach(function(frequency){
sectors.find(function cb(element){

var intersection = turf.booleanOverlap(poly1, poly2)
activeFrequencies = uniq(activeFrequencies);
var type = station.callsign.toUpperCase().includes("CTR");

if(intersection){
onlineSectors.push(subSectorWithSubsectors);
if(element.Frequency == frequency && element.Callsign != station.callsign && type && sectorWithSubsectors != false){

var subSectorWithSubsectors = mergeSectors(element, element.responsibleSectors,sectors);

var poly1 = turf.polygon(sectorWithSubsectors.geometry.coordinates)
var poly2 = turf.polygon(subSectorWithSubsectors.geometry.coordinates)

var intersection = turf.booleanOverlap(poly1, poly2)

if(intersection){
onlineSectors.push(subSectorWithSubsectors);
}
}
}

})
})
})
}
};
});

/*
if(activePosition !== false){
// Join sectors by frequency
// TODO - How to incrementally add sectors working outwards from the logged on sector?
var extendedPoly = activePosition;
activeFrequncies.forEach(function(element){
var adjacentSector = isAdjacentSector(element, extendedPoly, sectors);
if(adjacentSector !== false){
extendedPoly = unionArray([extendedPoly, sectorWithSubsectors])
if(adjacentSector.standard_position === true){
var sectorWithSubsectors = mergeSectors(adjacentSector, adjacentSector.responsibleSectors,sectors);
onlineSectors.push(sectorWithSubsectors);
}else{
onlineSectors.push(mergeBoundaries(adjacentSector));
}
}
})
};
});

/*
if(activePosition !== false){
// Join sectors by frequency
// TODO - How to incrementally add sectors working outwards from the logged on sector?
var extendedPoly = activePosition;
activeFrequncies.forEach(function(element){
var adjacentSector = isAdjacentSector(element, extendedPoly, sectors);
if(adjacentSector !== false){
extendedPoly = unionArray([extendedPoly, sectorWithSubsectors])
if(adjacentSector.standard_position === true){
var sectorWithSubsectors = mergeSectors(adjacentSector, adjacentSector.responsibleSectors,sectors);
onlineSectors.push(sectorWithSubsectors);
}else{
onlineSectors.push(mergeBoundaries(adjacentSector));
}
}
})
}
*/
}
*/
}
})
else
{
delete stations[index];
}
})

return turf.featureCollection(uniq(onlineSectors));
return turf.featureCollection(uniq(onlineSectors));
}
}
1 change: 0 additions & 1 deletion dependencies/query-overpass/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions dependencies/query-overpass/.travis.yml

This file was deleted.

7 changes: 0 additions & 7 deletions dependencies/query-overpass/LICENSE.md

This file was deleted.

90 changes: 0 additions & 90 deletions dependencies/query-overpass/README.md

This file was deleted.

35 changes: 0 additions & 35 deletions dependencies/query-overpass/cli.js

This file was deleted.

87 changes: 0 additions & 87 deletions dependencies/query-overpass/index.js

This file was deleted.

Loading

0 comments on commit 668c6cd

Please sign in to comment.