Last active
April 30, 2020 06:43
-
-
Save alexprengere/c54d706d659653049863355b8bb2ac3b to your computer and use it in GitHub Desktop.
Check airports not connected to a big city
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from neobase import NeoBase | |
N = NeoBase() | |
for key in N: | |
N.set(key, city_codes=set(N.get(key, "city_code_list"))) | |
for key in sorted(N): | |
if "A" not in N.get(key, "location_type"): | |
continue | |
if N.get(key, "page_rank") is None: # to speed things up, but this could be removed | |
continue | |
city_codes = N.get(key, "city_codes") | |
for dist, other in N.find_near(key, radius=60): | |
if "C" not in N.get(other, "location_type"): | |
continue | |
if N.get(other, "iata_code") in city_codes: | |
continue | |
if N.get(other, "page_rank") is None: | |
continue | |
if N.get(other, "page_rank") <= N.get(key, "page_rank") * 50: | |
continue | |
print( | |
"{0}[{1:.3f}] should have {2}[{3:.3f}] in its city list {4}:" | |
" dist {5:.1f}km -- {6}[{7}] => {8}[{9}]".format( | |
N.get(key, "iata_code"), | |
N.get(key, "page_rank"), | |
N.get(other, "iata_code"), | |
N.get(other, "page_rank"), | |
list(city_codes), | |
dist, | |
N.get(key, "name"), | |
N.get(key, "country_code"), | |
N.get(other, "name"), | |
N.get(other, "country_code"), | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment