Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_unit(lat, lon, srange, az, lato, lono):
lat1, lon1 = vincenty.vreckon(lat, lon, srange, az)
assert lat1 == approx(lato)
assert lon1 == approx(lono, rel=0.001)
def test_az_vector():
pytest.importorskip("numpy")
a, b = vincenty.vreckon(*ll0, sr1[0], az1)
assert a == approx(lat2)
assert b == approx(lon2)
def test_both_vector():
pytest.importorskip("numpy")
a, b = vincenty.vreckon(10, 20, sr1, az1)
assert a == approx(lat3)
assert b == approx(lon3)
def test_identity(lat, lon, slantrange, az):
lat1, lon1 = vincenty.vreckon(lat, lon, slantrange, az)
dist, az1 = vincenty.vdist(lat, lon, lat1, lon1)
assert dist == approx(slantrange)
assert az1 == approx(az)
def bench_vreckon(N: int) -> float:
sr = np.random.random(N)
az = np.random.random(N)
tic = time.monotonic()
a, b = vreckon(*ll0, sr, az)
return time.monotonic() - tic
def main():
p = ArgumentParser(description="Given starting latitude, longitude: find final lat,lon for distance and azimuth")
p.add_argument("lat", help="latitude WGS-84 [degrees]", type=float)
p.add_argument("lon", help="longitude WGS-84 [degrees]", type=float)
p.add_argument("range", help="range from start point [meters]", type=float)
p.add_argument("azimuth", help="clockwise from north: azimuth to start [degrees]", type=float)
P = p.parse_args()
lat2, lon2 = vreckon(P.lat, P.lon, P.range, P.azimuth)
print("lat, lon = ({:.4f}, {:.4f})".format(lat2, lon2))