Skip to content

HomePosition assignment logic

Danila Rodichkin edited this page Jul 14, 2024 · 2 revisions
stateDiagram-v2
    classDef NotFound stroke:red
    class notFound NotFound
    class stationIsSkipped NotFound
    class stationIsSkippedPosition NotFound
    class zonesNotFound NotFound

    classDef Found stroke:green
    class found Found
    class localStationIsFound Found
    class zonesFound Found

    state "stations.json/airports.json" as [*] {
        [*] --> lookup
        state "Find the station in stations.json" as lookup

        state "Look up for prefix" as prefixSearch {
            state "Try to look up for a prefix for this station.\n Give priority to the longest prefix you can find (if there’s multiple): \nyou should match ULLL_R6 instead of ULLL_R for ULLL_R6_CTR" as prefixSearch1
            --
            state "Verify suffix if present during this search (for example, _CTR)" as prefixSearch2
            --
            state "Verify frequency if present during this search" as prefixSearch3
        }
       
        state "Station not found in stations.json" as notFound
        state "Station was found in stations.json" as found

        prefixSearch --> notFound
        prefixSearch --> found

        state "Station is not CTR and FSS (ground/app)" as stationIsLocal
        state "Station is CTR or FSS (ground/app)" as stationIsNotLocal
        state "Station is skipped and not displayed" as stationIsSkipped

        notFound --> stationIsLocal
        notFound --> stationIsNotLocal

        stationIsLocal --> findLocalStation

        state "Look in airports.json" as findLocalStation {
            [*] --> findLocalStation1
            state "1. Check for suffix to match ICAO if present\nFor example, ULLI_123_GND should look for airport with ICAO ULLI" as findLocalStation1

            state "2. Check for airports prefixes\nwith same logic as on step 1" as findLocalStation2

            findLocalStation1 --> localStationIsFound: Found
            findLocalStation1 --> findLocalStation2: Not found
            findLocalStation2 --> localStationIsFound: Found
            findLocalStation2 --> stationIsSkipped: Not found

            state "Local station is found\nDisplay it simply as ground (local) station, or as approach circle without any zone" as localStationIsFound
        }

        stationIsNotLocal --> stationIsSkipped

        lookup --> prefixSearch

        found --> [*]
    }

    [*] --> makeAList
    makeAList --> positions

    state "make a list of all possible stations" as makeAList

    state "positions.json" as positions {
        [*] --> findPositions

        state "Find all positions for this station" as findPositions
        state "Station is skipped and not displayed" as stationIsSkippedPosition
        findPositions --> stationIsSkippedPosition: Nothing is found

        state "Prioritize positions" as prioritizePositions {
            state "Try to find any positions higher than this one in stations list" as prioritizePositions1
            --
            state "For example, ULLL_R_CTR can replace ULLL_CTR in his sector" as prioritizePositions2
        }
        findPositions--> prioritizePositions: Something was found

        prioritizePositions --> stationIsSkippedPosition: Higher stations found
        prioritizePositions --> [*]: This is the highest sector
    }

     state "make a list of all possible positions" as makeAPositionsList
     positions --> makeAPositionsList
     makeAPositionsList --> zones


    state "zones.json" as zones {
        
        [*] --> findAZone

        state "Find zones for each position by position field" as findAZone

        findAZone --> chooseRunways: runways fields is filled

        state "Using vertical splits" as verticalMode
        state "Standard display" as verticalModeNo

        findAZone --> verticalMode: You have to pick active alt
        findAZone --> verticalModeNo: Display without alt in mind

        state "Choose runways" as chooseRunways {
            [*] --> chooseRunwaysUser:  User has selected runways
            [*] --> chooseRunways2: No user selection

            state "Show user selection" as chooseRunwaysUser
            state "Show all zones" as chooseRunwaysAll
            state "Show detected zone runways" as chooseRunwaysDetected

            state "Parse ATIS for active runways" as chooseRunways2
            chooseRunways2 --> chooseRunwaysUser: Without success
            chooseRunways2 --> chooseRunwaysAll: Without success
            chooseRunways2 --> chooseRunwaysDetected: Success
            state "Filter (or skip) zones based on runways" as chooseRunwaysFinal

            chooseRunwaysUser --> chooseRunwaysFinal
            chooseRunwaysAll --> chooseRunwaysFinal
            chooseRunwaysDetected --> chooseRunwaysFinal
            chooseRunwaysFinal --> verticalMode: You have to pick active alt
            chooseRunwaysFinal --> verticalModeNo: Display without alt in mind
        }
        

        verticalModeNo--> pickNormalZones
        state "Filter non-vertical zones\nby noAltitudeLimit field" as pickNormalZones

        verticalMode--> pickVerticalZones
        state "Filter zones that have\naltitudeFrom/altitudeTo fields" as pickVerticalZones

        state "Create a sector from found zones\n and positions/stations" as zonesFound
        state "Skip this sector & position" as zonesNotFound

            state fork_state <<fork>>
                fork_state --> zonesNotFound: Was not able to found zones by filter
                fork_state --> zonesFound: Found at least one zone

        pickVerticalZones --> fork_state
        pickNormalZones --> fork_state
        pickVerticalZones --> fork_state
        pickNormalZones --> fork_state

        zonesFound --> [*]
    }
Loading
Clone this wiki locally