diff --git a/minimap.py b/minimap.py index 9ced0c1..92a8e4a 100644 --- a/minimap.py +++ b/minimap.py @@ -76,34 +76,6 @@ def update_location(): import math -def haversine(coord1, coord2): - """ - Calculate the great-circle distance between two points on the Earth - specified in decimal degrees (latitude and longitude). - - Parameters: - coord1 (tuple): (latitude, longitude) for point 1 - coord2 (tuple): (latitude, longitude) for point 2 - - Returns: - float: distance in kilometers between the two points - """ - - # Convert latitude and longitude from degrees to radians - lat1, lon1 = map(math.radians, coord1) - lat2, lon2 = map(math.radians, coord2) - - # Haversine formula - dlon = lon2 - lon1 - dlat = lat2 - lat1 - a = math.sin(dlat / 2)**2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon / 2)**2 - c = 2 * math.asin(math.sqrt(a)) - - # Radius of Earth in kilometers (mean radius) - r = 6371.0 - - return c * r - def haver_dist(coord1, coord2): lati1 = math.radians(coord1[0]) long1 = math.radians(coord1[1]) @@ -143,11 +115,11 @@ def update_display(): print(l) - d = location_avg() + lavg = location_avg() for (name,val), i in zip(l['points'].items(), range(len(l['points']))): if len(val) > 0: - d = haver_dist(d, (val[0][0],val[0][1])) - b = bearing(d, (val[0][0],val[0][1])) + d = haver_dist(lavg, (val[0][0],val[0][1])) + b = bearing(lavg, (val[0][0],val[0][1])) else: d = float('inf') b = float('NaN')