Last active
July 16, 2021 10:43
-
-
Save PawaritL/dc610f1e120447b94b22a44748e61351 to your computer and use it in GitHub Desktop.
Checks if two provided longitude coordinates crosses the antimeridian (180th meridian)
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
def check_crossing(lon1: float, lon2: float, validate: bool = False, dlon_threshold: float = 180.0): | |
""" | |
Assuming a minimum travel distance between two provided longitude coordinates, | |
checks if the 180th meridian (antimeridian) is crossed. | |
""" | |
if validate and any([abs(x) > 180.0 for x in [lon1, lon2]]): | |
raise ValueError("longitudes must be in degrees [-180.0, 180.0]") | |
return abs(lon2 - lon1) > dlon_threshold |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment