Coverage for fmc/coordinates_of_ICAO.py: 11%

9 statements  

« prev     ^ index     » next       coverage.py v7.8.1, created at 2025-05-23 08:53 +0000

1#!/usr/bin/env python3 

2 

3# Define function ... 

4def coordinates_of_ICAO( 

5 airports, 

6 icao, 

7 /, 

8): 

9 """Find the longitude and latitude of an airport 

10 

11 Parameters 

12 ---------- 

13 airports : list 

14 the list of all of the airports 

15 icao : str 

16 the ICAO code of the desired airport 

17 

18 Returns 

19 ------- 

20 lon : float 

21 the longitude of the airport (in degrees) 

22 lat : float 

23 the latitude of the airport (in degrees) 

24 

25 Notes 

26 ----- 

27 Copyright 2016 Thomas Guymer [1]_ 

28 

29 References 

30 ---------- 

31 .. [1] FMC, https://github.com/Guymer/fmc 

32 """ 

33 

34 # ************************************************************************** 

35 

36 # Catch special cases ... 

37 if icao == "EDDT": # This airport closed on 4/May/2021. 

38 return +13.2877, +52.5597 

39 

40 # Loop over all airports ... 

41 for airport in airports: 

42 # Skip this airport if it does not have an ICAO code ... 

43 if "ICAO" not in airport: 

44 continue 

45 

46 # Check if this is the correct one and return it's coordinates ... 

47 if airport["ICAO"] == icao: 

48 return airport["lon"], airport["lat"] 

49 

50 # Return defaults if it was not found ... 

51 return 0.0, 0.0