lister les cuisines dans un set

This commit is contained in:
Tykayn 2024-02-26 17:27:39 +01:00 committed by tykayn
parent 104e4fa9d3
commit 00c1154a1f
3 changed files with 481 additions and 314 deletions

127
cuisines.md Normal file
View File

@ -0,0 +1,127 @@
# Sortes de cuisines fréquentes
- afghan
- african
- american
- antilles
- arab
- argentinian
- asian
- asian_fusion
- bagel
- barbecue
- basque
- bistro
- brasilian
- brasserie
- brazilian
- brunch
- bubble_tea
- burge
- burger
- cafe
- cafeteria
- cake
- cambodian
- cameroonian
- caribbean
- chicken
- chinese
- coffee_shop
- colombian
- corean
- couscous
- creole
- crepe
- cuisine_nissarde
- djiboutian
- donut
- ethiopian
- falafel
- fish
- fish_and_chips
- french
- fried_chicken
- friture
- fusion
- gabonese
- georgian
- greek
- grill
- hawaiian
- hot_dog
- ice_cream
- indian
- international
- italian
- italian_pizza
- japanese
- japonais
- juice
- kebab
- korean
- kque
- kurdish
- lao
- laotian
- latin_american
- lebanese
- maghreb
- maghrébine
- malaysian
- mauritian
- meat
- mediterranean
- Mésopotamie_et_Anatolie
- mexican
- mexico
- middle_eastern
- moroccan
- nepalese
- noodle
- organic
- oriental
- paella
- pakistani
- pancake
- pasta
- pâtes
- persian
- peruvian
- pizza
- poke
- polish
- portugese
- portuguese
- ramen
- regional
- romanian
- Roumaine
- russian
- salad
- sandwich
- Savoie
- savory_pancakes
- seafood
- seasonal
- Sénégal
- serbian
- sichuan
- spanish
- steak_house
- street_food
- sushi
- syrian
- taiwan
- taiwanese
- tapas
- thai
- thaï
- tibetan
- tunisian
- turkish
- vegan
- vietnam
- vietnamese
- wrap
- 火鍋

BIN
img/miss_hour.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@ -1,5 +1,8 @@
//import * as geoDataPointsFromApi from './data.json';
// liste des cuisines uniques
let cuisineSet = ['pizza', 'italian', 'japanese', 'thai', 'thaï', 'lebanese','portugese']
// Filtre pour afficher seulement les cafés
// Appliquer/retirer le filtre quand on clique sur le bouton
export function toggleFilter(objectAmenity) {
@ -134,6 +137,9 @@ function loadedSuccess() {
}
let counterFeatures = 0;
let counterFeaturesHourMissing = 0;
let counterFeaturesCuisineMissing = 0;
function displayPointsFromApi(points) {
var resultAsGeojson = osmtogeojson(points);
@ -151,6 +157,7 @@ function displayPointsFromApi(points) {
return true;
},
onEachFeature: function (feature, layer) {
counterFeatures++
var popupContent = '';
popupContent = popupContent + '<dt>@id</dt><dd>' + feature.properties.type + '/' + feature.properties.id + '</dd>';
var keys = Object.keys(feature.properties.tags);
@ -179,7 +186,7 @@ function displayPointsFromApi(points) {
let cooklist = feature.properties.tags['cuisine']
// console.log('feature.properties.tags[\'cuisine\']', feature.properties.tags['cuisine'])
if(cooklist){
if (cooklist) {
cuisine = `
- cuisine:
${cooklist}`;
@ -187,29 +194,30 @@ function displayPointsFromApi(points) {
}
if(!cuisine){
if (!cuisine) {
cuisine = ' ';
counterFeaturesCuisineMissing++
}
let isOpen = false;
let opening, hours = '';
// let isOpen = getIsOpenFromOpeningHours(feature.properties.tags)
if(feature.properties.tags.opening_hours){
if (feature.properties.tags.opening_hours) {
isOpen = isLocationOpenNow(feature.properties.tags.opening_hours)
}
if(feature.properties.tags.opening_hours){
if (feature.properties.tags.opening_hours) {
hours = feature.properties.tags.opening_hours
}
if(hours){
if (hours) {
if(isOpen){
if (isOpen) {
isOpen = 'ouvert'
} else {
isOpen = 'fermé'
}
}else{
} else {
isOpen = 'horaires non renseignées'
}
if(isOpen){
if (isOpen) {
opening = `
<span class="open">${isOpen}</span>
<span class="hours">
@ -248,6 +256,7 @@ function displayPointsFromApi(points) {
});
let regular_marker = L.marker(layer._latlng, {title: rest_name, icon: myIcon}).addTo(map);
regular_marker.bindPopup(html);
@ -263,9 +272,40 @@ function displayPointsFromApi(points) {
this.openPopup();
},
});
// regular_marker.fire('mouseover');
/**
* ajout d'icone pour chaque restaurant où il manque l'horaire
*/
if (!feature.properties.tags.opening_hours) {
counterFeaturesHourMissing++
var missingHour = L.icon({
iconUrl: '/img/miss_hour.png',
iconSize: [iconSiZePx/3, iconSiZePx/3],
iconAnchor: [iconSiZePx / 2, iconSiZePx / 2],
className: makeCssClassFromTags(feature.properties.tags),
});
L.marker(
{
lat: layer._latlng.lat + 0.00002,
lng: layer._latlng.lng + 0.00001
},
{
title: "horaire manquante",
icon: missingHour
}
).addTo(map);
}
},
});
console.log('counterFeatures', counterFeatures)
console.log('counterFeatures hour missing', counterFeaturesHourMissing)
console.log('counterFeatures cuisine missing', counterFeaturesCuisineMissing)
}
function makeCssClassFromTags(tags) {
@ -286,7 +326,7 @@ function makeCssClassFromTags(tags) {
} else {
listOfClasses.push('tag-no-opening-hours')
}
listOfClasses.push('is-open-today-'+isOpen)
listOfClasses.push('is-open-today-' + isOpen)
return listOfClasses.join(' ');
}
@ -345,7 +385,7 @@ function getIsOpenFromOpeningHours(tags) {
* @param {string} openingHours The value of the 'opening_hours' tag.
*/
function isLocationOpenNow(openingHours) {
if(openingHours === '24/7'){
if (openingHours === '24/7') {
return true;
}
const regex = /MO(\d+)-(\d+)|TU(\d+)-(\d+)|WE(\d+)-(\d+)|TH(\d+)-(\d+)|FR(\d+)-(\d+)|SA(\d+)-(\d+)|SU(\d+)-(\d+)/g;
@ -365,17 +405,19 @@ function isLocationOpenNow(openingHours) {
return false;
}
function getIconFromTags(tags) {
let iconFileName = 'icon_restaurant.png';
if(!tags['cuisine']){
if (!tags['cuisine']) {
return iconFileName;
}
let firstCuisine = tags['cuisine'].split(';')[0];
if(!firstCuisine){
if (!firstCuisine) {
firstCuisine = tags['cuisine']
}
if(cuisineSet.indexOf(firstCuisine) === -1) {
cuisineSet.push(firstCuisine)
}
if (tags['man_made']) {
@ -422,14 +464,11 @@ function getIconFromTags(tags) {
iconFileName = 'vending_machine.png';
} else if (tags['amenity'] === 'drinking_water') {
iconFileName = 'fountain.png';
}
else if (tags['amenity'] === 'pub') {
} else if (tags['amenity'] === 'pub') {
iconFileName = 'beer.jpg';
}
else if (tags['amenity'] === 'bar') {
} else if (tags['amenity'] === 'bar') {
iconFileName = 'beer.jpg';
}
else if (tags['amenity'] === 'fast_food') {
} else if (tags['amenity'] === 'fast_food') {
iconFileName = 'burger.png';
if (firstCuisine === 'pizza') {
iconFileName = 'pizza.png';
@ -460,6 +499,7 @@ function loadOverpassQuery() {
removeOlderPoints()
displayPointsFromApi(geoDataPointsFromApi);
console.log('cuisineSet', new Set(cuisineSet))
loadedSuccess();
isLoading = false;
}); // end of the getting from overpass API