osmnx does not behave

This commit is contained in:
Remy Moll 2024-07-17 12:00:40 +02:00
parent 25cc0fa300
commit 8d71cab8d5
5 changed files with 16 additions and 9 deletions

View File

@ -16,7 +16,9 @@ class LandmarkManager:
logger = logging.getLogger(__name__)
def __init__(self) -> None:
ox.config(cache_folder=constants.OSM_CACHE_DIR)
ox.settings.cache_folder = constants.OSM_CACHE_DIR
ox.settings.use_cache = True
ox.config(use_cache=True, cache_folder=constants.OSM_CACHE_DIR)
with constants.AMENITY_SELECTORS_PATH.open('r') as f:
self.amenity_selectors = yaml.safe_load(f)
with constants.LANDMARK_PARAMETERS_PATH.open('r') as f:
@ -36,21 +38,21 @@ class LandmarkManager:
# List for sightseeing
if preferences.sightseeing.score != 0:
score_func = lambda loc, n_tags: int((self.count_elements_within_radius(loc, self.parameters['radius_close_to']) + n_tags * self.parameters['tag_coeff']) * self.parameters['church_coeff'])
score_func = lambda loc, n_tags: int((10 + n_tags * self.parameters['tag_coeff']) * self.parameters['church_coeff'])
L1 = self.fetch_landmarks(self.amenity_selectors['sightseeing'], SIGHTSEEING, center_coordinates, self.parameters['city_bbox_side'], score_func)
self.correct_score(L1, preferences.sightseeing)
L += L1
# List for nature
if preferences.nature.score != 0:
score_func = lambda loc, n_tags: int((self.count_elements_within_radius(loc, self.parameters['radius_close_to']) + n_tags * self.parameters['tag_coeff']) * self.parameters['park_coeff'])
score_func = lambda loc, n_tags: int((10 + n_tags * self.parameters['tag_coeff']) * self.parameters['park_coeff'])
L2 = self.fetch_landmarks(self.amenity_selectors['nature'], NATURE, center_coordinates, self.parameters['city_bbox_side'], score_func)
self.correct_score(L2, preferences.nature)
L += L2
# List for shopping
if preferences.shopping.score != 0:
score_func = lambda loc, n_tags: self.count_elements_within_radius(loc, self.parameters['radius_close_to']) + n_tags * self.parameters['tag_coeff']
score_func = lambda loc, n_tags: int((10 + n_tags * self.parameters['tag_coeff']))
L3 = self.fetch_landmarks(self.amenity_selectors['shopping'], SHOPPING, center_coordinates, self.parameters['city_bbox_side'], score_func)
self.correct_score(L3, preferences.shopping)
L += L3
@ -115,6 +117,7 @@ class LandmarkManager:
dist = distance,
tags = amenity_selectors
)
self.logger.info(f'Fetched {len(landmarks)} landmarks around {center_coordinates}.')
# cleanup the list
# remove rows where name is None

View File

@ -1,3 +1,3 @@
detour_factor: 1.4
average_walking_speed: 4.8
max_landmarks: 10
max_landmarks: 40

View File

@ -3,7 +3,7 @@ kind: Deployment
metadata:
name: nav-backend
spec:
replicas: 3
replicas: 1
selector:
matchLabels:
app: nav-backend
@ -31,7 +31,10 @@ spec:
memory: 100Mi
limits:
cpu: 4
memory: 8Gi
memory: 10Gi
volumes:
- name: osm-cache
emptyDir: {}
persistentVolumeClaim:
claimName: osm-cache

View File

@ -5,6 +5,7 @@ kind: Kustomization
namespace: nav
resources:
- namespace.yaml
- pvc.yaml
- deployment.yaml
- service.yaml
- ingress.yaml

View File

@ -1,7 +1,7 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: cache
name: osm-cache
spec:
storageClassName: "nfs-client"
accessModes: