added image and website urls

This commit is contained in:
Helldragon67 2024-08-28 18:08:09 +02:00
parent a1fcc8d23b
commit 728b954643
2 changed files with 25 additions and 3 deletions
backend/src

@ -15,8 +15,11 @@ class Landmark(BaseModel) :
attractiveness : int
n_tags : int
image_url : Optional[str] = None # TODO future
website_url : Optional[str] = None
wikipedia_url : Optional[str] = None
description : Optional[str] = None # TODO future
duration : Optional[int] = 0 # TODO future
name_en : Optional[str] = None
# Unique ID of a given landmark
uuid: str = Field(default_factory=uuid4) # TODO implement this ASAP

@ -290,7 +290,10 @@ class LandmarkManager:
elem_type = landmarktype # Add the landmark type as 'sightseeing,
n_tags = len(elem.tags().keys()) # Add number of tags
score = n_tags**self.tag_exponent # Add score
website_url = None
wikpedia_url = None
image_url = None
name_en = None
# remove specific tags
skip = False
@ -304,7 +307,7 @@ class LandmarkManager:
if "wiki" in tag:
score += self.wikipedia_bonus # wikipedia entries count more
# if tag == "wikidata":
# Q = elem.tag('wikidata')
# site = Site("wikidata", "wikidata")
@ -331,6 +334,18 @@ class LandmarkManager:
if tag == "building" and elem.tag('building') in ['retail', 'supermarket', 'parking']:
skip = True
break
# Get additional information
# if tag == 'wikipedia' :
# wikpedia_url = elem.tag('wikipedia')
if tag in ['website', 'contact:website'] :
website_url = elem.tag(tag)
if tag == 'image' :
image_url = elem.tag('image')
if tag =='name:en' :
name_en = elem.tag('name:en')
if skip:
continue
@ -356,7 +371,11 @@ class LandmarkManager:
attractiveness=score,
must_do=False,
n_tags=int(n_tags),
duration = duration
duration = duration,
name_en=name_en,
image_url=image_url,
# wikipedia_url=wikpedia_url,
website_url=website_url
)
return_list.append(landmark)