From d5dc94903de4276b1669991b4b00dc2b080ae0bb Mon Sep 17 00:00:00 2001 From: "Fabian P. Schmidt" Date: Wed, 6 Jan 2016 00:06:27 +0100 Subject: [PATCH] utils: Remove unused wgs84_to_sphere Use an external package[1] instead. [1]: eg. https://pypi.python.org/pypi/haversine --- ogn/utils.py | 14 -------------- tests/test_utils.py | 18 +----------------- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/ogn/utils.py b/ogn/utils.py index 10648c6..a29b3b4 100644 --- a/ogn/utils.py +++ b/ogn/utils.py @@ -1,7 +1,6 @@ import requests import csv from io import StringIO -from math import sin, cos, asin, atan2, sqrt, pi from .model import Device, AddressOrigin @@ -9,8 +8,6 @@ from geopy.geocoders import Nominatim DDB_URL = "http://ddb.glidernet.org/download" -deg2rad = pi/180 -rad2deg = 1/deg2rad address_prefixes = {'F':'FLR', 'O':'OGN', @@ -63,14 +60,3 @@ def get_country_code(latitude, longitude): except KeyError: country_code = None return country_code - - -def wgs84_to_sphere(lat1, lat2, lon1, lon2, alt1, alt2): - lat1 = lat1*deg2rad - lat2 = lat2*deg2rad - lon1 = lon1*deg2rad - lon2 = lon2*deg2rad - radius = 6366000*2*asin(sqrt((sin((lat1-lat2)/2))**2 + cos(lat1)*cos(lat2)*(sin((lon1-lon2)/2))**2)) - theta = atan2(alt2-alt1, radius)*rad2deg - phi = atan2(sin(lon2-lon1)*cos(lat2), cos(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(lon2-lon1))*rad2deg - return radius, theta, phi diff --git a/tests/test_utils.py b/tests/test_utils.py index 0dbaa0c..8b2d03c 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,6 +1,6 @@ import unittest -from ogn.utils import get_ddb, get_trackable, get_country_code, wgs84_to_sphere +from ogn.utils import get_ddb, get_trackable, get_country_code from ogn.model import AddressOrigin @@ -43,19 +43,3 @@ class TestStringMethods(unittest.TestCase): longitude = -0.0009119 country_code = get_country_code(latitude, longitude) self.assertEqual(country_code, None) - - def test_wgs84_to_sphere(self): - # receiver - lat1 = 48.865 - lon1 = 9.2225 - alt1 = 574 - - # aircraft beacon - lat2 = 48.74435 - lon2 = 9.578 - alt2 = 929 - - [radius, theta, phi] = wgs84_to_sphere(lat1, lat2, lon1, lon2, alt1, alt2) - self.assertAlmostEqual(radius, 29265.6035812215, 5) - self.assertAlmostEqual(theta, 0.694979846308314, 5) - self.assertAlmostEqual(phi, 117.1275408121, 5)