changed bbox to meters

This commit is contained in:
Helldragon67 2024-07-17 12:30:47 +02:00
parent 87df2f70e9
commit b09ec2b083
3 changed files with 4 additions and 5 deletions

@ -182,14 +182,14 @@ def count_elements_within_radius(coordinates: Tuple[float, float], radius: int)
return 0 return 0
# Creates a bounding box around given coordinates # Creates a bounding box around given coordinates, side_length in meters
def create_bbox(coordinates: Tuple[float, float], side_length: int) -> Tuple[float, float, float, float]: def create_bbox(coordinates: Tuple[float, float], side_length: int) -> Tuple[float, float, float, float]:
lat = coordinates[0] lat = coordinates[0]
lon = coordinates[1] lon = coordinates[1]
# Half the side length in km (since it's a square bbox) # Half the side length in km (since it's a square bbox)
half_side_length_km = side_length / 2.0 half_side_length_km = side_length / 2 / 1000
# Convert distance to degrees # Convert distance to degrees
lat_diff = half_side_length_km / 111 # 1 degree latitude is approximately 111 km lat_diff = half_side_length_km / 111 # 1 degree latitude is approximately 111 km

@ -5,7 +5,6 @@ from typing import List, Tuple
from scipy.optimize import linprog from scipy.optimize import linprog
from collections import defaultdict, deque from collections import defaultdict, deque
from geopy.distance import geodesic from geopy.distance import geodesic
from shapely import Polygon
from structs.landmarks import Landmark from structs.landmarks import Landmark

@ -1,5 +1,5 @@
{ {
"city bbox side" : 5, "city bbox side" : 5000,
"radius close to" : 50, "radius close to" : 50,
"church coeff" : 0.8, "church coeff" : 0.8,
"park coeff" : 1.2, "park coeff" : 1.2,