cleanup files
This commit is contained in:
@@ -3,6 +3,10 @@ import json, os
|
||||
|
||||
from typing import List, Tuple, Optional
|
||||
from OSMPythonTools.overpass import Overpass, overpassQueryBuilder
|
||||
from pywikibot import ItemPage, Site
|
||||
from pywikibot import config
|
||||
config.put_throttle = 0
|
||||
config.maxlag = 0
|
||||
|
||||
from structs.landmarks import Landmark, LandmarkType
|
||||
from structs.preferences import Preferences, Preference
|
||||
@@ -244,7 +248,7 @@ def get_landmarks(list_amenity: list, landmarktype: LandmarkType, coordinates: T
|
||||
else :
|
||||
osm_type = elem.type() # Add type : 'way' or 'relation'
|
||||
osm_id = elem.id() # Add OSM id
|
||||
elem_type = landmarktype # Add the landmark type as 'sightseeing
|
||||
elem_type = landmarktype # Add the landmark type as 'sightseeing,
|
||||
n_tags = len(elem.tags().keys()) # Add number of tags
|
||||
|
||||
# remove specific tags
|
||||
@@ -252,13 +256,31 @@ def get_landmarks(list_amenity: list, landmarktype: LandmarkType, coordinates: T
|
||||
for tag in elem.tags().keys() :
|
||||
if "pay" in tag :
|
||||
n_tags -= 1 # discard payment options for tags
|
||||
|
||||
if "disused" in tag :
|
||||
skip = True
|
||||
skip = True # skip disused amenities
|
||||
break
|
||||
|
||||
if "wikipedia" in tag :
|
||||
n_tags += 3 # wikipedia entries count more
|
||||
|
||||
if tag == "wikidata" :
|
||||
Q = elem.tag('wikidata')
|
||||
site = Site("wikidata", "wikidata")
|
||||
item = ItemPage(site, Q)
|
||||
item.get()
|
||||
n_languages = len(item.labels)
|
||||
n_tags += n_languages/10
|
||||
|
||||
if elem_type != LandmarkType(landmark_type="nature") :
|
||||
if "leisure" in tag and elem.tag('leisure') == "park":
|
||||
elem_type = LandmarkType(landmark_type="nature")
|
||||
|
||||
if amenity not in ["'shop'='department_store'", "'shop'='mall'"] :
|
||||
if "shop" in tag :
|
||||
skip = True
|
||||
break
|
||||
|
||||
if tag == "building" and elem.tag('building') in ['retail', 'supermarket', 'parking']:
|
||||
skip = True
|
||||
break
|
||||
@@ -268,16 +290,17 @@ def get_landmarks(list_amenity: list, landmarktype: LandmarkType, coordinates: T
|
||||
|
||||
# Add score of given landmark based on the number of surrounding elements. Penalty for churches as there are A LOT
|
||||
if amenity == "'amenity'='place_of_worship'" :
|
||||
score = int((count_elements_within_radius(location, radius) + (n_tags*tag_coeff) )*church_coeff)
|
||||
#score = int((count_elements_within_radius(location, radius) + (n_tags*tag_coeff) )*church_coeff)
|
||||
score = int((count_elements_within_radius(location, radius) + ((n_tags**1.2)*tag_coeff) )*church_coeff)
|
||||
elif amenity == "'leisure'='park'" :
|
||||
score = int((count_elements_within_radius(location, radius) + (n_tags*tag_coeff) )*park_coeff)
|
||||
score = int((count_elements_within_radius(location, radius) + ((n_tags**1.2)*tag_coeff) )*park_coeff)
|
||||
else :
|
||||
score = count_elements_within_radius(location, radius) + (n_tags*tag_coeff)
|
||||
score = int(count_elements_within_radius(location, radius) + ((n_tags**1.2)*tag_coeff))
|
||||
|
||||
if score is not None :
|
||||
# Generate the landmark and append it to the list
|
||||
#print(f"There are {n_tags} tags on this Landmark. Total score : {score}\n")
|
||||
landmark = Landmark(name=name, type=elem_type, location=location, osm_type=osm_type, osm_id=osm_id, attractiveness=score, must_do=False, n_tags=n_tags)
|
||||
landmark = Landmark(name=name, type=elem_type, location=location, osm_type=osm_type, osm_id=osm_id, attractiveness=score, must_do=False, n_tags=int(n_tags))
|
||||
L.append(landmark)
|
||||
|
||||
return L
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"city bbox side" : 3,
|
||||
"city bbox side" : 5,
|
||||
"radius close to" : 50,
|
||||
"church coeff" : 0.9,
|
||||
"church coeff" : 0.8,
|
||||
"park coeff" : 1.2,
|
||||
"tag coeff" : 10,
|
||||
"N important" : 40
|
||||
|
@@ -35,7 +35,7 @@ def test4(coordinates: tuple[float, float]) -> List[Landmark]:
|
||||
nature=Preference(
|
||||
name='nature',
|
||||
type=LandmarkType(landmark_type='nature'),
|
||||
score = 5),
|
||||
score = 0),
|
||||
shopping=Preference(
|
||||
name='shopping',
|
||||
type=LandmarkType(landmark_type='shopping'),
|
||||
@@ -52,13 +52,13 @@ def test4(coordinates: tuple[float, float]) -> List[Landmark]:
|
||||
|
||||
# Generate the landmarks from the start location
|
||||
landmarks, landmarks_short = generate_landmarks(preferences=preferences, coordinates=start.location)
|
||||
#write_data(landmarks, "landmarks_Lyon.txt")
|
||||
#write_data(landmarks, "landmarks_Wien.txt")
|
||||
|
||||
# Insert start and finish to the landmarks list
|
||||
landmarks_short.insert(0, start)
|
||||
landmarks_short.append(finish)
|
||||
|
||||
max_walking_time = 480 # minutes
|
||||
max_walking_time = 180 # minutes
|
||||
detour = 0 # minutes
|
||||
|
||||
# First stage optimization
|
||||
@@ -75,5 +75,6 @@ def test4(coordinates: tuple[float, float]) -> List[Landmark]:
|
||||
#test4(tuple((48.8344400, 2.3220540))) # Café Chez César
|
||||
#test4(tuple((48.8375946, 2.2949904))) # Point random
|
||||
#test4(tuple((47.377859, 8.540585))) # Zurich HB
|
||||
test4(tuple((45.7576485, 4.8330241))) # Lyon Bellecour
|
||||
#test4(tuple((48.5848435, 7.7332974))) # Strasbourg Gare
|
||||
#test4(tuple((45.7576485, 4.8330241))) # Lyon Bellecour
|
||||
test4(tuple((48.5848435, 7.7332974))) # Strasbourg Gare
|
||||
#test4(tuple((48.2067858, 16.3692340))) # Vienne
|
Reference in New Issue
Block a user