import { keepTrackApi } from '@app/js/api/keepTrackApi' ; import { SatObject } from '@app/js/api/keepTrackTypes' ; import { SpaceObjectType } from '@app/js/api/SpaceObjectType' ; import { ColorInformation , colorSchemeManager , Pickable } from '../colorSchemeManager' ; export const ageOfElsetRules = ( sat ) : ColorInformation => { const { timeManager } = keepTrackApi . programs ; if ( sat . static && sat . type === SpaceObjectType . STAR ) { if ( sat . vmag >= 4.7 && colorSchemeManager . objectTypeFlags . starLow ) { return { color : colorSchemeManager . colorTheme . starLow , pickable : Pickable . Yes , } ; } else if ( sat . vmag >= 3.5 && sat . vmag < 4.7 && colorSchemeManager . objectTypeFlags . starMed ) { return { color : colorSchemeManager . colorTheme . starMed , pickable : Pickable . Yes , } ; } else if ( sat . vmag < 3.5 && colorSchemeManager . objectTypeFlags . starHi ) { return { color : colorSchemeManager . colorTheme . starHi , pickable : Pickable . Yes , } ; } else { return { color : colorSchemeManager . colorTheme . deselected , pickable : Pickable . No , } ; } } switch ( sat . type ) { case SpaceObjectType . INTERGOVERNMENTAL_ORGANIZATION : case SpaceObjectType . SUBORBITAL_PAYLOAD_OPERATOR : case SpaceObjectType . PAYLOAD_OWNER : case SpaceObjectType . METEOROLOGICAL_ROCKET_LAUNCH_AGENCY_OR_MANUFACTURER : case SpaceObjectType . PAYLOAD_MANUFACTURER : case SpaceObjectType . LAUNCH_AGENCY : case SpaceObjectType . LAUNCH_SITE : case SpaceObjectType . LAUNCH_POSITION : return { color : colorSchemeManager . colorTheme . facility , pickable : Pickable . Yes , } ; default : } if ( sat . static ) { return { color : colorSchemeManager . colorTheme . sensor , pickable : Pickable . Yes , } ; } if ( sat . missile ) { return { color : colorSchemeManager . colorTheme . transparent , pickable : Pickable . No , } ; } let now = new Date ( ) ; const jday = timeManager . getDayOfYear ( now ) ; const year = now . getFullYear ( ) . toString ( ) . substr ( 2 , 2 ) ; let daysold ; if ( sat . TLE1 . substr ( 18 , 2 ) === year ) { daysold = jday - parseInt ( sat . TLE1 . substr ( 20 , 3 ) ) ; } else { daysold = jday + parseInt ( year ) * 365 - ( parseInt ( sat . TLE1 . substr ( 18 , 2 ) ) * 365 + parseInt ( sat . TLE1 . substr ( 20 , 3 ) ) ) ; } if ( daysold < 3 && colorSchemeManager . objectTypeFlags . ageNew ) { return { color : colorSchemeManager . colorTheme . ageNew , pickable : Pickable . Yes , } ; } if ( daysold >= 3 && daysold < 14 && colorSchemeManager . objectTypeFlags . ageMed ) { return { color : colorSchemeManager . colorTheme . ageMed , pickable : Pickable . Yes , } ; } if ( daysold >= 14 && daysold < 60 && colorSchemeManager . objectTypeFlags . ageOld ) { return { color : colorSchemeManager . colorTheme . ageOld , pickable : Pickable . Yes , } ; } if ( daysold >= 60 && colorSchemeManager . objectTypeFlags . ageLost ) { return { color : colorSchemeManager . colorTheme . ageLost , pickable : Pickable . Yes , } ; } return { color : colorSchemeManager . colorTheme . deselected , pickable : Pickable . No , } ; } ;