import { CatalogManager , MissileObject , OrbitManager , SatGroupCollection , SatObject } from '../api/keepTrackTypes' ; import { country } from '../satSet/search' ; export class SatGroup { sats : SatGroupCollection [ ] ; hasSat : any ; updateOrbits : any ; forEach : any ; constructor ( groupType , data , satSet ) { switch ( groupType ) { case 'all' : this . sats = [ ] ; satSet . satData . every ( ( sat ) => { if ( typeof sat . sccNum !== 'undefined' ) { this . sats . push ( { satId : sat . id , isIntlDes : true , } ) ; } return this . sats . length <= settingsManager . maxOribtsDisplayed ; } ) ; break ; case 'year' : this . sats = satSet . search . year ( satSet . satData , data ) . slice ( 0 , settingsManager . maxOribtsDisplayed ) . map ( ( sat ) => ( { satId : sat . id , } ) ) ; break ; case 'yearOrLess' : this . sats = satSet . search . yearOrLess ( satSet . satData , data ) . slice ( 0 , settingsManager . maxOribtsDisplayed ) . map ( ( sat ) => ( { satId : sat . id , } ) ) ; break ; case 'intlDes' : this . sats = data . slice ( 0 , settingsManager . maxOribtsDisplayed ) . map ( ( intlDes ) => satSet . getIdFromIntlDes ( intlDes ) ) . filter ( ( sccNUm ) => sccNUm !== null ) . map ( ( sccNUm ) => ( { satId : sccNUm , isIntlDes : true , } ) ) ; break ; case 'nameRegex' : this . sats = satSet . search . name ( satSet . satData , data ) . slice ( 0 , settingsManager . maxOribtsDisplayed ) . map ( ( sat ) => ( { satId : sat . id , } ) ) ; break ; case 'countryRegex' : this . sats = country ( satSet . satData , data ) . slice ( 0 , settingsManager . maxOribtsDisplayed ) . map ( ( sat ) => ( { satId : sat . id , } ) ) ; break ; case 'shapeRegex' : this . sats = satSet . search . shape ( satSet . satData , data ) . slice ( 0 , settingsManager . maxOribtsDisplayed ) . map ( ( sat ) => ( { satId : sat . id , } ) ) ; break ; case 'busRegex' : this . sats = satSet . search . bus ( satSet . satData , data ) . slice ( 0 , settingsManager . maxOribtsDisplayed ) . map ( ( sat ) => ( { satId : sat . id , } ) ) ; break ; case 'objNum' : this . sats = data . slice ( 0 , settingsManager . maxOribtsDisplayed ) . map ( ( id ) => satSet . getIdFromObjNum ( id ) ) . filter ( ( sccNUm ) => sccNUm !== null ) . map ( ( sccNUm ) => ( { satId : sccNUm , isObjnum : true , } ) ) ; break ; case 'idList' : this . sats = data . slice ( 0 , settingsManager . maxOribtsDisplayed ) . map ( ( id ) => ( { satId : id , } ) ) ; break ; default : throw new Error ( 'Unknown group type' ) ; } this . hasSat = ( id ) => this . sats . findIndex ( ( sat ) => sat . satId === id ) !== - 1 ; this . updateOrbits = ( orbitManager ) => { this . sats . forEach ( ( sat ) => { if ( sat . missile ) { const missile = < MissileObject > ( < unknown > sat ) ; orbitManager . updateOrbitBuffer ( missile . id , null , null , null , true , missile . latList , missile . lonList , missile . altList , missile . startTime ) ; } else { orbitManager . updateOrbitBuffer ( sat . satId ) ; } } ) ; } ; this . forEach = ( callback ) => { for ( var i = 0 ; i < this . sats . length ; i ++ ) { callback ( this . sats [ i ] ?. satId ) ; } } ; } }