<filename>src/maps/tracon/atlanta/atl_tracon.py<gh_stars>0
# Copyright 2021 <NAME>
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.

from math import pi
import pygame
from pygame.locals import *

from ....settings.options import WINDOW_HEIGHT, WINDOW_WIDTH
from ....objects.airport import *
from ....objects.runway import *
from ....objects.approach import *

class ATL_TRACON(pygame.Surface):

    def __init__(self):
        super().__init__((WINDOW_HEIGHT, WINDOW_HEIGHT))
        self.airports = []
        self.planes = []
        self.airspace_enabled = False
        self.atl_east = False
        self.atl_west = False
        self.build_scope()
        self.draw_scope(True)

    def build_scope(self):
        self.build_atl()
        self.build_pdk()
        self.build_fty()
        self.build_mge()
        self.build_ryy()
        self.build_cvc()
        self.build_hmp()
        self.build_ffc()
        self.build_cco()
        self.build_lzu()
        self.build_6a2()
        self.build_puj()

    def build_atl(self):
        ATL = Airport(40, 65, (425, 425), "Hartsfield-Jackson", "ATL", 1026, (20, 32))

        ATL.add_runway(Runway(ATL, 270, 9000, 150, (0, 25))) # 28
        ATL.add_runway(Runway(ATL, 270, 9000, 150, (0, 15))) # 27L
        ATL.add_runway(Runway(ATL, 270, 12390, 150, (0, 12))) # 27R
        ATL.add_runway(Runway(ATL, 270, 9999, 150, (7, 2))) # 26L
        ATL.add_runway(Runway(ATL, 270, 9000, 150, (6, 0))) # 26R

        ATL.add_approach(Approach(self, 270, 20, 5000, 3, (465, 425))) # 26R
        ATL.add_approach(Approach(self, 270, 21, 7000, 3, (465, 440))) # 27L
        ATL.add_approach(Approach(self, 270, 18, 4000, 3, (465, 450))) # 28

        ATL.add_approach(Approach(self, 90, 21, 5000, 3, (110, 425))) # 8L
        ATL.add_approach(Approach(self, 90, 21, 7000, 3, (95, 440))) # 9R
        ATL.add_approach(Approach(self, 90, 16, 4000, 3, (185, 450))) # 10

        self.airports.append(ATL)

    def build_pdk(self):
        PDK = Airport(40, 40, (520, 215), "Dekalb-Peachtree", "PDK", 998, (10, 20))

        PDK.add_runway(Runway(PDK, 210, 3745, 150, (0,12))) # 21 R
        PDK.add_runway(Runway(PDK, 210, 6001, 100, (1,13))) # 21 L
        PDK.add_runway(Runway(PDK, 340, 3968, 150, (0,1))) # 34

        PDK.add_approach(Approach(self, 210, 12, 5400, 3, (531, 210)))

        self.airports.append(PDK)

    def build_fty(self):
        FTY = Airport(40,40, (357, 309), "Fulton County Executive", "FTY", 841, (10, 20))

        FTY.add_runway(Runway(FTY, 260, 5795, 100, (0,4))) # 26
        FTY.add_runway(Runway(FTY, 320, 4158, 100, (0,3))) # 32

        FTY.add_approach(Approach(self, 80, 16.5, 6000, 3, (380, 307)))

        self.airports.append(FTY)

    def build_mge(self):
        MGE = Airport(40, 40, (353, 184), "<NAME>", "MGE", 1069, (10, 20))

        MGE.add_runway(Runway(MGE, 290, 10002, 300, (0,0)))

        MGE.add_approach(Approach(self, 110, 5.5, 2900, 3, (278, 156)))
        MGE.add_approach(Approach(self, 290, 6.1, 3000, 3, (388, 198)))

        self.airports.append(MGE)

    def build_ryy(self):
        RYY = Airport(40, 40, (300, 102), "Cobb County International", "RYY", 1040, (10, 10))

        RYY.add_runway(Runway(RYY, 270, 6295, 100, (0,0)))

        RYY.add_approach(Approach(self, 270, 12.5, 3000, 3, (325, 102)))

        self.airports.append(RYY)

    def build_cvc(self):
        CVC = Airport(40, 40, (866, 439), "Covvington Municipal", "CVC", 820, (10, 10))

        CVC.add_runway(Runway(CVC, 280, 6000, 100, (0,0)))

        self.airports.append(CVC)

    def build_hmp(self):
        HMP = Airport(40, 40, (495,656), "Atlanta Speedway", "HMP", 882, (15, 15))

        HMP.add_runway(Runway(HMP, 240, 5509, 100, (10,10)))

        self.airports.append(HMP)

    def build_ffc(self):
        FFC = Airport(40, 40, (312,686), "Atlanta Regional Falcon Field", "FFC", 808, (0,20))

        FFC.add_runway(Runway(FFC, 310, 5768, 100, (0,0)))

        FFC.add_approach(Approach(self, 310, 5.1, 2500, 3, (329, 700)))

        self.airports.append(FFC)

    def build_cco(self):
        CCO = Airport(40, 40, (166,727), "Newnan Coweta County", "CCO", 970, (10,0))

        CCO.add_runway(Runway(CCO, 330, 5500, 100, (0,0)))

        CCO.add_approach(Approach(self, 330, 3.9, 2300, 3, (176, 745)))

        self.airports.append(CCO)

    def build_lzu(self):
        LZU = Airport(40, 40, (785,115), "Gwinnett County", "LZU", 1062, (10,20))

        LZU.add_runway(Runway(LZU, 250, 6001, 100, (0, 10)))

        LZU.add_approach(Approach(self, 250, 5.1, 2800, 3, (810, 115)))

        self.airports.append(LZU)

    def build_6a2(self):
        _6A2 = Airport(40, 40, (540,803), "Griffin-Spalding County", "6A2", 958, (10,20))

        _6A2.add_runway(Runway(_6A2, 320, 3701, 75, (6,6)))

        self.airports.append(_6A2)

    def build_puj(self):
        PUJ = Airport(40, 40, (46,184), "Paulding Northwest Atlanta", "PUJ", 1289, (0,20))

        PUJ.add_runway(Runway(PUJ, 310, 5505, 100, (6,6)))

        PUJ.add_approach(Approach(self, 310, 11, 3000, 3, (70, 205)))

        self.airports.append(PUJ)

    def draw_scope(self, auto):
        self.fill(BLACK)
        for plane in self.planes:
            if auto:
                plane.animate()
            else:
                plane.drawTail(False)
                plane.drawPlane()
        for airport in self.airports:
            airport.draw_airport()
            self.blit(airport, airport.location)
        if self.airspace_enabled:
            self.draw_airspace()
        self.draw_approaches()

    def draw_airspace(self):
        # ATL 7 NM
        pygame.draw.arc(self, GREEN, pygame.Rect(340, 333, 210, 210), -math.sqrt(2.32)/2, math.sqrt(2.3)/2)
        pygame.draw.arc(self, GREEN, pygame.Rect(340, 333, 210, 210), -math.sqrt(2.32)/2 + math.pi, math.sqrt(2.3)/2 + math.pi)
        # ATL 12 NM
        pygame.draw.arc(self, GREEN, pygame.Rect(265, 258, 360, 360), -0.82/2, 0.87/2)
        pygame.draw.arc(self, GREEN, pygame.Rect(265, 258, 360, 360), -0.82/2 + math.pi, 0.87/2 + math.pi)
        # ATL 4 NM Horizontals
        pygame.draw.line(self, GREEN, (130, 365), (760, 365), 1)
        pygame.draw.line(self, GREEN, (280, 510), (610, 510), 1)
        # ATL 21 NM Verticals
        pygame.draw.line(self, GREEN, (130, 305), (130, 570))
        pygame.draw.line(self, GREEN, (760, 305), (760, 570))
        # ATL 8 NM Horizontals
        pygame.draw.line(self, GREEN, (52, 305), (848, 305), 1)
        pygame.draw.line(self, GREEN, (130, 570), (760, 570), 1)
        #ATL 12 NM Horizontals
        pygame.draw.line(self, GREEN, (52, 245), (848, 245))
        pygame.draw.line(self, GREEN, (52, 630), (848, 630))
        # ATL 26.5 NM Veritcals
        pygame.draw.line(self, GREEN, (52, 230), (52, 643))
        pygame.draw.line(self, GREEN, (848, 230), (848, 643))
        # Bravo Outer Ring
        pygame.draw.arc(self, GREEN, pygame.Rect(-2, -20, 904, 900), math.sqrt(0.99)/2 + math.pi, -math.sqrt(0.97)/2)
        pygame.draw.arc(self, GREEN, pygame.Rect(-4, -4, 909, 900), math.sqrt(0.99)/2, -math.sqrt(0.97)/2 + math.pi)

        # PDK Class D
        pygame.draw.circle(self, GREEN, (526, 221), 60, 1)

        # RYY Class D
        pygame.draw.circle(self, GREEN, (307, 109), 60, 1)

        # MGE Class D
        pygame.draw.circle(self, GREEN, (368, 199), 83, 1)

        # FTY Class D
        pygame.draw.circle(self, GREEN, (359, 311), 60, 1)

        # LZU Class D
        pygame.draw.circle(self, GREEN, (790, 120), 68, 1)

    def draw_approaches(self):
        for airport in self.airports:
            airport.draw_approaches()

    def draw_waypoints(self):
        pass

    def draw_airways(self):
        pass

    def draw_jetways(self):
        pass