Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
lat1, lon1, a12 = radians(lat1), radians(lon1), radians(a12)
if abs(lat1) > pi / 2:
raise ValueError("-90 <= latitude <= 90")
if rng < 0:
raise ValueError("ground distance must be >= 0")
# compute rectifying sphere latitude and radius
reclat = geodetic2rectifying(lat1, ell, deg=False)
# compute the new points
cosaz = cos(a12)
lat2 = reclat + (rng / rsphere_rectifying(ell)) * cosaz # compute rectifying latitude
lat2 = rectifying2geodetic(lat2, ell, deg=False) # transform to geodetic latitude
newiso = geodetic2isometric(lat2, ell, deg=False)
iso = geodetic2isometric(lat1, ell, deg=False)
dlon = tan(a12) * (newiso - iso)
lon2 = lon1 + dlon
if deg:
lat2, lon2 = degrees(lat2), degrees(lon2)
return lat2, lon2
if abs(lat1) > pi / 2:
raise ValueError("-90 <= latitude <= 90")
if rng < 0:
raise ValueError("ground distance must be >= 0")
# compute rectifying sphere latitude and radius
reclat = geodetic2rectifying(lat1, ell, deg=False)
# compute the new points
cosaz = cos(a12)
lat2 = reclat + (rng / rsphere_rectifying(ell)) * cosaz # compute rectifying latitude
lat2 = rectifying2geodetic(lat2, ell, deg=False) # transform to geodetic latitude
newiso = geodetic2isometric(lat2, ell, deg=False)
iso = geodetic2isometric(lat1, ell, deg=False)
dlon = tan(a12) * (newiso - iso)
lon2 = lon1 + dlon
if deg:
lat2, lon2 = degrees(lat2), degrees(lon2)
return lat2, lon2
def loxodrome_inverse_point(
lat1: float, lon1: float, lat2: float, lon2: float, ell: Ellipsoid = None, deg: bool = True
) -> typing.Tuple[float, float]:
if deg:
lat1, lon1, lat2, lon2 = radians(lat1), radians(lon1), radians(lat2), radians(lon2)
# compute changes in isometric latitude and longitude between points
disolat = geodetic2isometric(lat2, deg=False, ell=ell) - geodetic2isometric(lat1, deg=False, ell=ell)
dlon = lon2 - lon1
# compute azimuth
az12 = atan2(dlon, disolat)
cosaz12 = cos(az12)
# compute distance along loxodromic curve
if abs(cosaz12) < 1e-9: # straight east or west
dist = departure(lon2, lon1, lat1, ell, deg=False)
else:
dist = meridian_arc(lat2, lat1, deg=False, ell=ell) / abs(cos(az12))
if deg:
az12 = degrees(az12) % 360.0
return dist, az12