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
« prev ^ index » next coverage.py v7.8.1, created at 2025-05-23 08:53 +0000
1#!/usr/bin/env python3
3# Define function ...
4def coordinates_of_ICAO(
5 airports,
6 icao,
7 /,
8):
9 """Find the longitude and latitude of an airport
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
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)
25 Notes
26 -----
27 Copyright 2016 Thomas Guymer [1]_
29 References
30 ----------
31 .. [1] FMC, https://github.com/Guymer/fmc
32 """
34 # **************************************************************************
36 # Catch special cases ...
37 if icao == "EDDT": # This airport closed on 4/May/2021.
38 return +13.2877, +52.5597
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
46 # Check if this is the correct one and return it's coordinates ...
47 if airport["ICAO"] == icao:
48 return airport["lon"], airport["lat"]
50 # Return defaults if it was not found ...
51 return 0.0, 0.0