From 00c1154a1f6f5bcc942e8658d8931d10eb55cc73 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Mon, 26 Feb 2024 17:27:39 +0100 Subject: [PATCH] lister les cuisines dans un set --- cuisines.md | 127 +++++++++ img/miss_hour.png | Bin 0 -> 6983 bytes js/main.js | 668 ++++++++++++++++++++++++---------------------- 3 files changed, 481 insertions(+), 314 deletions(-) create mode 100644 cuisines.md create mode 100644 img/miss_hour.png diff --git a/cuisines.md b/cuisines.md new file mode 100644 index 0000000..e5c2e34 --- /dev/null +++ b/cuisines.md @@ -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 +- 火鍋 diff --git a/img/miss_hour.png b/img/miss_hour.png new file mode 100644 index 0000000000000000000000000000000000000000..c2329ae08a60d4454b2a7823cc6a263324fa614c GIT binary patch literal 6983 zcmeHMX;f2Lwmu0%C@cciq972^vdf{BK`CX1!ilm(P=rV!9D1;MFga12lg zXrZDBgdl^2@j3u%7>d>lK}Nvp0urWoV!eLry|v!^(d+%~tOZHV-Dlsk&))mo z@B4D)n1h{)vX(LcK;`g{2b=)F!;g5NqzK<;&%TqwH+ky5!!Anj6|Z#iGW`Bk#E&Pa z01#iw{&2T<5VhgphUkOt(azyP(XoC}fgmeWkUHqmW&TrbNrIf2^8zX<=jeq*(Z9i#0sN&>R6~-JY<5$Gw zPTN`hvhQi5jeqP_nL@(H%z~fSX64?IrqMF=SYWupV(iX$AU1nxuW@DBe3H|fb zdLQG#ygIu{j{n_R+#PjTq?HbD#?H(E=WVG%< zQB;Vg%dIT4!xo;}_;}k44F<1KXGo|qG+T)k8sM?sk8w0QKqA5<=nj^Rp7y0)C(zZ> z?Y8n}YOe(#mz8~J#^m`9ZGr*DW zyE15Hu7v!c`bg9>-J-VRAxIOKqaEo)99L1dKZ-vTXGh3McLwa(M(hT5tJ4;Ay>#=4 zk>hBRPHu?-x5JM>q3K?0(i@^= zg!71ub;kgC%o@%JWt77i7w}y3t(io?#ff&CBRka@D9rLEBwMckMdR?6~ z1)7cQMRtjt>g&zJqtzJCtdCihNwM*b<;Owuf|NPq9h^qQ8@xHX>%iC7t zg55H0-XB9a^X<&B+dAoNR)=eriv~GM@65KU0=!Y?7`b!<3GW_fT3-bmH=G-Zd*jxF~<>kC-u>y(kdsx!{T zpOIOA4)BvX;%Lbn`D&6Fr~sZqJE-w`Xmq6G1 zvGUK3`*GR)F*^e2`X%7y0d)q?%i0`pyL2{h`4zMttR)beclm#-jCff?cmEs~7Q#h^ zwEcM@o|l}m@M;_sXN-YX;XCZeLSM4Qd*A-bnxJSk@(Uv3)o_CypDec+x_vWdf`tFQ*C(}9FA{w}|L%E+C8y>O9aowZv&YB9`6p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GrMh7+s!S@?Th9}`l2~4nb+;;mGS;=8NfL?TWLT1K zBols3%WJ|VHZl<$wnki#5S9JB<^0TK#>ewCrm>TrI$6ON%G&KjGVS= zcmP0zT_)Q=i{!t4K!NL_kp?BaW}VG$KjPd=p!y5Hz~)En@8I3@;#}M^pxQp_Pzv=t ze?_RNk0ry__@Z7zZMtRcDj>F%MID49w^`yBk$d=0k-No$izBvePIfzhbI*ff2@rs+ z45HDRSX^=Y6*P-I0-rbT&L%EJ1JjL@Mix+G_m*kcpi5BuDc#GWabO&& zOsNz(Czu!EK-knp2#3cM$FeWNkfk%&I;cSv-^&UV`)-F`Vh7<50R~V?DZWzbqIzm! z^Obcy7UoE5L*MkBi5WY1&$X*}rG-!hF9d0kk+dMmILwdYq9fXBES zzHY@-&~lkpmvf!Oh@5k6JdsDXih+FCbG5V)|!KU0+ ze-&!J+Ng}s&xT6|Jq9#Czlt|NMAZF~8yF$#*`P;+3L-UQOLO(dnsjr!mE>|KE;3sd z8ye_=q8Z;EaGpg2{f8slO-s-upBC~wN92}>NxWeqt^mX+fz&gsNN;zTYh_Rygy!Y~Rvaq~NHvRBHhXb5_l=J@q)X8L8 literal 0 HcmV?d00001 diff --git a/js/main.js b/js/main.js index d44a136..37a99df 100644 --- a/js/main.js +++ b/js/main.js @@ -1,53 +1,56 @@ //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) { - const filterExpression = ['==', ['get', 'amenity'], objectAmenity]; - let visibility = map.getLayoutProperty('points', 'visibility') - console.log('visibility', visibility) + const filterExpression = ['==', ['get', 'amenity'], objectAmenity]; + let visibility = map.getLayoutProperty('points', 'visibility') + console.log('visibility', visibility) - if (map.getLayoutProperty('points', 'visibility') === 'visible') { - console.log('cacher les aménités', objectAmenity) - map.setFilter('points', ['!=', 'amenity', objectAmenity]); - map.setLayoutProperty('points', 'visibility', 'none'); - } else { - console.log('montrer les aménités', objectAmenity) - map.setFilter('points', filterExpression); - map.setLayoutProperty('points', 'visibility', 'visible'); - } + if (map.getLayoutProperty('points', 'visibility') === 'visible') { + console.log('cacher les aménités', objectAmenity) + map.setFilter('points', ['!=', 'amenity', objectAmenity]); + map.setLayoutProperty('points', 'visibility', 'none'); + } else { + console.log('montrer les aménités', objectAmenity) + map.setFilter('points', filterExpression); + map.setLayoutProperty('points', 'visibility', 'visible'); + } } const geoDataJsonMock = { - 'version': 0.6, - 'generator': 'Overpass API 0.7.57 93a4d346', - 'osm3s': { - 'timestamp_osm_base': '2021-12-05T21:05:09Z', - 'copyright': 'The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.', + 'version': 0.6, + 'generator': 'Overpass API 0.7.57 93a4d346', + 'osm3s': { + 'timestamp_osm_base': '2021-12-05T21:05:09Z', + 'copyright': 'The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.', + }, + 'elements': [{ + 'type': 'node', + 'id': 598729945, + 'lat': 48.6727029, + 'lon': 2.0690276, + 'tags': {'amenity': 'restaurant', 'cuisine': 'crepe', 'name': 'Le Chat Botté'}, + }, { + 'type': 'node', + 'id': 963824814, + 'lat': 48.6735834, + 'lon': 2.1704756, + 'tags': { + 'addr:city': 'Saint-Jean-de-Beauregard', + 'addr:housenumber': '5', + 'addr:postcode': '91940', + 'addr:street': 'Grande Rue', + 'amenity': 'restaurant', + 'cuisine': 'french', + 'name': 'L\'Atelier Gourmand', + 'phone': '+33 1 60 12 31 01', + 'website': 'https://lateliergourmand-restaurant.fr/', }, - 'elements': [{ - 'type': 'node', - 'id': 598729945, - 'lat': 48.6727029, - 'lon': 2.0690276, - 'tags': {'amenity': 'restaurant', 'cuisine': 'crepe', 'name': 'Le Chat Botté'}, - }, { - 'type': 'node', - 'id': 963824814, - 'lat': 48.6735834, - 'lon': 2.1704756, - 'tags': { - 'addr:city': 'Saint-Jean-de-Beauregard', - 'addr:housenumber': '5', - 'addr:postcode': '91940', - 'addr:street': 'Grande Rue', - 'amenity': 'restaurant', - 'cuisine': 'french', - 'name': 'L\'Atelier Gourmand', - 'phone': '+33 1 60 12 31 01', - 'website': 'https://lateliergourmand-restaurant.fr/', - }, - }], + }], }; const overrideQuery = true; @@ -60,8 +63,8 @@ const osmMention = '© OpenStr const tileServer = "https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png" var map = L.map('map').setView([48.6410, 2.1307], initialZoom); L.tileLayer(tileServer, { - maxZoom: 19, - attribution: osmMention, + maxZoom: 19, + attribution: osmMention, }).addTo(map); // if (overrideQuery) { @@ -70,12 +73,12 @@ L.tileLayer(tileServer, { function buildOverpassApiUrl(map, overpassQuery) { - var baseUrl = 'https://overpass-api.de/api/interpreter'; - var bounds = map.getBounds().getSouth() + ',' + map.getBounds().getWest() + ',' + map.getBounds().getNorth() + ',' + map.getBounds().getEast(); - var resultUrl, query = ''; + var baseUrl = 'https://overpass-api.de/api/interpreter'; + var bounds = map.getBounds().getSouth() + ',' + map.getBounds().getWest() + ',' + map.getBounds().getNorth() + ',' + map.getBounds().getEast(); + var resultUrl, query = ''; - if (overrideQuery) { - query = `?data=[out:json][timeout:15];( + if (overrideQuery) { + query = `?data=[out:json][timeout:15];( node[shop=bakery](${bounds}); node[amenity=fast_food](${bounds}); node[amenity=restaurant](${bounds}); @@ -94,131 +97,136 @@ function buildOverpassApiUrl(map, overpassQuery) { way[amenity=restaurant](${bounds}); );out body geom;`; - let not_used_query = ` + let not_used_query = ` node[man_made=water_tap](${bounds}); node[man_made=drinking_fountain](${bounds}); node[amenity=vending_machine](${bounds}); node[amenity=bar](${bounds}); node[amenity=cafe](${bounds}); ` - } else { - var nodeQuery = 'node[' + overpassQuery + '](' + bounds + ');'; - var wayQuery = 'way[' + overpassQuery + '](' + bounds + ');'; - var relationQuery = 'relation[' + overpassQuery + '](' + bounds + ');'; - query = '?data=[out:json][timeout:15];(' + nodeQuery + wayQuery + relationQuery + ');out body geom;'; + } else { + var nodeQuery = 'node[' + overpassQuery + '](' + bounds + ');'; + var wayQuery = 'way[' + overpassQuery + '](' + bounds + ');'; + var relationQuery = 'relation[' + overpassQuery + '](' + bounds + ');'; + query = '?data=[out:json][timeout:15];(' + nodeQuery + wayQuery + relationQuery + ');out body geom;'; - } - resultUrl = baseUrl + query; - // console.log("query url", resultUrl) - return resultUrl; + } + resultUrl = baseUrl + query; + // console.log("query url", resultUrl) + return resultUrl; } const UseLocalJson = false; const loadQueryPoints = () => { - if (UseLocalJson) { - displayPointsFromApi(geoDataJsonMock); - } else { - loadOverpassQuery(); - } + if (UseLocalJson) { + displayPointsFromApi(geoDataJsonMock); + } else { + loadOverpassQuery(); + } }; function loadedSuccess() { - document.querySelector('#success_load').classList.add('visible') - setTimeout(function () { - document.querySelector('#success_load').classList.remove('visible') - }, 1000) - $('#spinning_icon').fadeOut(); + document.querySelector('#success_load').classList.add('visible') + setTimeout(function () { + document.querySelector('#success_load').classList.remove('visible') + }, 1000) + $('#spinning_icon').fadeOut(); } +let counterFeatures = 0; +let counterFeaturesHourMissing = 0; +let counterFeaturesCuisineMissing = 0; function displayPointsFromApi(points) { - var resultAsGeojson = osmtogeojson(points); - var resultLayer = L.geoJson(resultAsGeojson, { - style: function (feature) { - return {color: '#ff0000'}; - }, - filter: function (feature, layer) { - var isPolygon = (feature.geometry) && (feature.geometry.type !== undefined) && (feature.geometry.type === 'Polygon'); - if (isPolygon) { - feature.geometry.type = 'Point'; - var polygonCenter = L.latLngBounds(feature.geometry.coordinates[0]).getCenter(); - feature.geometry.coordinates = [polygonCenter.lat, polygonCenter.lng]; - } - return true; - }, - onEachFeature: function (feature, layer) { - var popupContent = ''; - popupContent = popupContent + '
@id
' + feature.properties.type + '/' + feature.properties.id + '
'; - var keys = Object.keys(feature.properties.tags); - keys.forEach(function (key) { - popupContent = popupContent + '
' + key + '
' + feature.properties.tags[key] + '
'; - }); - popupContent = popupContent + ''; - layer.bindPopup(popupContent); + var resultAsGeojson = osmtogeojson(points); + var resultLayer = L.geoJson(resultAsGeojson, { + style: function (feature) { + return {color: '#ff0000'}; + }, + filter: function (feature, layer) { + var isPolygon = (feature.geometry) && (feature.geometry.type !== undefined) && (feature.geometry.type === 'Polygon'); + if (isPolygon) { + feature.geometry.type = 'Point'; + var polygonCenter = L.latLngBounds(feature.geometry.coordinates[0]).getCenter(); + feature.geometry.coordinates = [polygonCenter.lat, polygonCenter.lng]; + } + return true; + }, + onEachFeature: function (feature, layer) { + counterFeatures++ + var popupContent = ''; + popupContent = popupContent + '
@id
' + feature.properties.type + '/' + feature.properties.id + '
'; + var keys = Object.keys(feature.properties.tags); + keys.forEach(function (key) { + popupContent = popupContent + '
' + key + '
' + feature.properties.tags[key] + '
'; + }); + popupContent = popupContent + ''; + layer.bindPopup(popupContent); - let iconSiZePx = 20; + let iconSiZePx = 20; - if (feature.properties.tags['amenity'] && feature.properties.tags['amenity'] === 'restaurant' || - feature.properties.tags['amenity'] === 'fast_food' - ) { - iconSiZePx = 40; - } + if (feature.properties.tags['amenity'] && feature.properties.tags['amenity'] === 'restaurant' || + feature.properties.tags['amenity'] === 'fast_food' + ) { + iconSiZePx = 40; + } - let icon, cuisine, rest_name = ''; - if (feature.properties.tags['name'] !== undefined) { - rest_name = feature.properties.tags['name']; - } else { - rest_name = ` Nom inconnu, ${feature.properties.tags['amenity']}`; - } + let icon, cuisine, rest_name = ''; + if (feature.properties.tags['name'] !== undefined) { + rest_name = feature.properties.tags['name']; + } else { + rest_name = ` Nom inconnu, ${feature.properties.tags['amenity']}`; + } - if (typeof feature.properties.tags['cuisine'] !== typeof undefined && feature.properties.tags['cuisine'].length) { + if (typeof feature.properties.tags['cuisine'] !== typeof undefined && feature.properties.tags['cuisine'].length) { - let cooklist = feature.properties.tags['cuisine'] - // console.log('feature.properties.tags[\'cuisine\']', feature.properties.tags['cuisine']) - if(cooklist){ - cuisine = ` + let cooklist = feature.properties.tags['cuisine'] + // console.log('feature.properties.tags[\'cuisine\']', feature.properties.tags['cuisine']) + if (cooklist) { + cuisine = ` - cuisine: ${cooklist}`; - } + } - } + } - if(!cuisine){ - cuisine = ' '; - } - let isOpen = false; - let opening, hours = ''; - // let isOpen = getIsOpenFromOpeningHours(feature.properties.tags) - if(feature.properties.tags.opening_hours){ - isOpen = isLocationOpenNow(feature.properties.tags.opening_hours) - } - if(feature.properties.tags.opening_hours){ - hours = feature.properties.tags.opening_hours - } - if(hours){ + if (!cuisine) { + cuisine = ' '; + counterFeaturesCuisineMissing++ + } + let isOpen = false; + let opening, hours = ''; + // let isOpen = getIsOpenFromOpeningHours(feature.properties.tags) + if (feature.properties.tags.opening_hours) { + isOpen = isLocationOpenNow(feature.properties.tags.opening_hours) + } + if (feature.properties.tags.opening_hours) { + hours = feature.properties.tags.opening_hours + } + if (hours) { - if(isOpen){ - isOpen = 'ouvert' - } else { - isOpen = 'fermé' - } - }else{ - isOpen = 'horaires non renseignées' - } - if(isOpen){ - opening = ` + if (isOpen) { + isOpen = 'ouvert' + } else { + isOpen = 'fermé' + } + } else { + isOpen = 'horaires non renseignées' + } + if (isOpen) { + opening = ` ${isOpen} ${hours} ` - } + } - let html = ` + let html = `
✏️ @@ -230,65 +238,97 @@ function displayPointsFromApi(points) {
`; - L.marker(layer._latlng, { - icon: L.divIcon({ - iconUrl: 'https://www.cipherbliss.com/ou-manger/img/' + getIconFromTags(feature.properties.tags), - className: 'label ' + makeCssClassFromTags(feature.properties.tags), - // html : html, - iconSize: ['auto', 'auto'], - }), - }).addTo(map); + L.marker(layer._latlng, { + icon: L.divIcon({ + iconUrl: 'https://www.cipherbliss.com/ou-manger/img/' + getIconFromTags(feature.properties.tags), + className: 'label ' + makeCssClassFromTags(feature.properties.tags), + // html : html, + iconSize: ['auto', 'auto'], + }), + }).addTo(map); - var myIcon = L.icon({ - iconUrl: 'https://www.cipherbliss.com/ou-manger/img/' + getIconFromTags(feature.properties.tags), - iconSize: [iconSiZePx, iconSiZePx], - iconAnchor: [iconSiZePx / 2, iconSiZePx / 2], - popupAnchor: [iconSiZePx / 2, iconSiZePx / 2], - className: makeCssClassFromTags(feature.properties.tags), + var myIcon = L.icon({ + iconUrl: 'https://www.cipherbliss.com/ou-manger/img/' + getIconFromTags(feature.properties.tags), + iconSize: [iconSiZePx, iconSiZePx], + iconAnchor: [iconSiZePx / 2, iconSiZePx / 2], + popupAnchor: [iconSiZePx / 2, iconSiZePx / 2], + className: makeCssClassFromTags(feature.properties.tags), - }); + }); - let regular_marker = L.marker(layer._latlng, {title: rest_name, icon: myIcon}).addTo(map); - regular_marker.bindPopup(html); + let regular_marker = L.marker(layer._latlng, {title: rest_name, icon: myIcon}).addTo(map); - regular_marker.on({ - mouseover: function () { - this.openPopup(); - }, - mouseout: function () { - setTimeout(() => this.closePopup(), 3000); - }, - click: function () { - this.openPopup(); - }, - }); - // regular_marker.fire('mouseover'); + regular_marker.bindPopup(html); + + regular_marker.on({ + mouseover: function () { + this.openPopup(); }, - }); + mouseout: function () { + setTimeout(() => this.closePopup(), 3000); + }, + click: function () { + this.openPopup(); + }, + }); + + + + /** + * 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) { - let tagKeys = Object.keys(tags); - if (!tags) { - return ''; - } - let listOfClasses = []; + let tagKeys = Object.keys(tags); + if (!tags) { + return ''; + } + let listOfClasses = []; - tagKeys.forEach((element) => { - listOfClasses.push('tag-' + element + '_' + tags[element].replace(':', '--')); - }); + tagKeys.forEach((element) => { + listOfClasses.push('tag-' + element + '_' + tags[element].replace(':', '--')); + }); - let isOpen = getIsOpenFromOpeningHours(tags) + let isOpen = getIsOpenFromOpeningHours(tags) - if (tags['opening_hours']) { - listOfClasses.push('tag-has-opening-hours') - } else { - listOfClasses.push('tag-no-opening-hours') - } - listOfClasses.push('is-open-today-'+isOpen) + if (tags['opening_hours']) { + listOfClasses.push('tag-has-opening-hours') + } else { + listOfClasses.push('tag-no-opening-hours') + } + listOfClasses.push('is-open-today-' + isOpen) - return listOfClasses.join(' '); + return listOfClasses.join(' '); } /** @@ -299,45 +339,45 @@ function makeCssClassFromTags(tags) { * @returns {string} */ function getIsOpenFromOpeningHours(tags) { - let isOpen = 'has-no-opening-hours'; + let isOpen = 'has-no-opening-hours'; - let currentDay = new Date(); - let daysArray = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'] - let todayInLetters = daysArray[currentDay.getDay()]; - let todayInHour = daysArray[currentDay.getHours()]; + let currentDay = new Date(); + let daysArray = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'] + let todayInLetters = daysArray[currentDay.getDay()]; + let todayInHour = daysArray[currentDay.getHours()]; - if (tags['opening_hours']) { - let opening_hours = tags['opening_hours'].trim(); + if (tags['opening_hours']) { + let opening_hours = tags['opening_hours'].trim(); // trouver les sections séparées par des points virgule - let sections = opening_hours.split(' ') - // séparer les sections d'ouverture par un espace entre la plage de jour et les heures - sections.map(part => { - // prendre en compte les périodes de plusieurs jours Mo-Sa - // prise en compte d'un seul jour à la fois - if (part.indexOf(todayInLetters)) { + let sections = opening_hours.split(' ') + // séparer les sections d'ouverture par un espace entre la plage de jour et les heures + sections.map(part => { + // prendre en compte les périodes de plusieurs jours Mo-Sa + // prise en compte d'un seul jour à la fois + if (part.indexOf(todayInLetters)) { - // voir si le jour actuel est inclus dans la section - // voir si les horaires de ce jour sont dans le futur - // dans ce cas le restaurant est ouvert, YES! - isOpen = 'is-open-this-day' - let splitDay = part.split('-') - if (splitDay.length) { - let start = splitDay[0] - let end = splitDay[1] - if (start.substring(0, 2) < todayInHour) { - //sera ouvert aujourd'hui - } else { - //était ouvert aujourd'hui - } - } + // voir si le jour actuel est inclus dans la section + // voir si les horaires de ce jour sont dans le futur + // dans ce cas le restaurant est ouvert, YES! + isOpen = 'is-open-this-day' + let splitDay = part.split('-') + if (splitDay.length) { + let start = splitDay[0] + let end = splitDay[1] + if (start.substring(0, 2) < todayInHour) { + //sera ouvert aujourd'hui + } else { + //était ouvert aujourd'hui + } + } - } - }) - } - // console.log(tags['opening_hours'], isOpen) - return isOpen; + } + }) + } + // console.log(tags['opening_hours'], isOpen) + return isOpen; } /** @@ -345,125 +385,125 @@ function getIsOpenFromOpeningHours(tags) { * @param {string} openingHours The value of the 'opening_hours' tag. */ function isLocationOpenNow(openingHours) { - 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; - const matches = Array.from(openingHours.matchAll(regex)).flat(); + 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; + const matches = Array.from(openingHours.matchAll(regex)).flat(); - const dayOfWeek = new Date().getDay(); - const startTime = parseInt(matches[(dayOfWeek - 1) * 2]); - const closeTime = parseInt(matches[(dayOfWeek - 1) * 2 + 1]); + const dayOfWeek = new Date().getDay(); + const startTime = parseInt(matches[(dayOfWeek - 1) * 2]); + const closeTime = parseInt(matches[(dayOfWeek - 1) * 2 + 1]); - const now = new Date(); - const openAt = new Date(now.getFullYear(), now.getMonth(), now.getDate(), startTime); - const closeAt = new Date(now.getFullYear(), now.getMonth(), now.getDate(), closeTime); + const now = new Date(); + const openAt = new Date(now.getFullYear(), now.getMonth(), now.getDate(), startTime); + const closeAt = new Date(now.getFullYear(), now.getMonth(), now.getDate(), closeTime); - if (now >= openAt && now <= closeAt) { - return true; - } - return false; + if (now >= openAt && now <= closeAt) { + return true; + } + return false; } - - function getIconFromTags(tags) { - let iconFileName = 'icon_restaurant.png'; + let iconFileName = 'icon_restaurant.png'; - if(!tags['cuisine']){ - return iconFileName; - } - let firstCuisine = tags['cuisine'].split(';')[0]; - if(!firstCuisine){ - firstCuisine = tags['cuisine'] - } - - if (tags['man_made']) { - iconFileName = 'fountain.png'; - } else if (tags['shop']) { - iconFileName = 'croissant.png'; - } else if (tags['amenity']) { - if (tags['amenity'] === 'restaurant') { - - - if (firstCuisine === 'pizza') { - iconFileName = 'pizza.png'; - } - if (firstCuisine === 'italian') { - iconFileName = 'pizza.png'; - } - - if (firstCuisine === 'japanese') { - iconFileName = 'asian_food.png'; - } - if (firstCuisine === 'thai') { - iconFileName = 'pad-thai.png'; - } - if (firstCuisine === 'thaï') { - iconFileName = 'pad-thai.png'; - } - if (firstCuisine === 'crepe') { - iconFileName = 'crepe.png'; - } - if (firstCuisine === 'crepes') { - iconFileName = 'crepe.png'; - } - if (firstCuisine === 'sushi') { - iconFileName = 'asian_food.png'; - } - if (firstCuisine === 'asian') { - iconFileName = 'asian_food.png'; - } - if (firstCuisine === 'chinese') { - iconFileName = 'asian_food.png'; - } - - } else if (tags['amenity'] === 'vending_machine') { - iconFileName = 'vending_machine.png'; - } else if (tags['amenity'] === 'drinking_water') { - iconFileName = 'fountain.png'; - } - else if (tags['amenity'] === 'pub') { - iconFileName = 'beer.jpg'; - } - else if (tags['amenity'] === 'bar') { - iconFileName = 'beer.jpg'; - } - else if (tags['amenity'] === 'fast_food') { - iconFileName = 'burger.png'; - if (firstCuisine === 'pizza') { - iconFileName = 'pizza.png'; - } - } - } + if (!tags['cuisine']) { return iconFileName; + } + let firstCuisine = tags['cuisine'].split(';')[0]; + if (!firstCuisine) { + firstCuisine = tags['cuisine'] + + } + if(cuisineSet.indexOf(firstCuisine) === -1) { + cuisineSet.push(firstCuisine) + } + + if (tags['man_made']) { + iconFileName = 'fountain.png'; + } else if (tags['shop']) { + iconFileName = 'croissant.png'; + } else if (tags['amenity']) { + if (tags['amenity'] === 'restaurant') { + + + if (firstCuisine === 'pizza') { + iconFileName = 'pizza.png'; + } + if (firstCuisine === 'italian') { + iconFileName = 'pizza.png'; + } + + if (firstCuisine === 'japanese') { + iconFileName = 'asian_food.png'; + } + if (firstCuisine === 'thai') { + iconFileName = 'pad-thai.png'; + } + if (firstCuisine === 'thaï') { + iconFileName = 'pad-thai.png'; + } + if (firstCuisine === 'crepe') { + iconFileName = 'crepe.png'; + } + if (firstCuisine === 'crepes') { + iconFileName = 'crepe.png'; + } + if (firstCuisine === 'sushi') { + iconFileName = 'asian_food.png'; + } + if (firstCuisine === 'asian') { + iconFileName = 'asian_food.png'; + } + if (firstCuisine === 'chinese') { + iconFileName = 'asian_food.png'; + } + + } else if (tags['amenity'] === 'vending_machine') { + iconFileName = 'vending_machine.png'; + } else if (tags['amenity'] === 'drinking_water') { + iconFileName = 'fountain.png'; + } else if (tags['amenity'] === 'pub') { + iconFileName = 'beer.jpg'; + } else if (tags['amenity'] === 'bar') { + iconFileName = 'beer.jpg'; + } else if (tags['amenity'] === 'fast_food') { + iconFileName = 'burger.png'; + if (firstCuisine === 'pizza') { + iconFileName = 'pizza.png'; + } + } + } + return iconFileName; } let isLoading = false; function removeOlderPoints() { - // L.clearLayers() + // L.clearLayers() } function loadOverpassQuery() { - // ne pas charger si on recherche déjà - if (!isLoading) { - isLoading = true; - $('#spinning_icon').fadeIn(); - var queryTextfieldValue = $('#query-textfield').val(); - var overpassApiUrl = buildOverpassApiUrl(map, queryTextfieldValue); + // ne pas charger si on recherche déjà + if (!isLoading) { + isLoading = true; + $('#spinning_icon').fadeIn(); + var queryTextfieldValue = $('#query-textfield').val(); + var overpassApiUrl = buildOverpassApiUrl(map, queryTextfieldValue); - $.get(overpassApiUrl, function (geoDataPointsFromApi) { + $.get(overpassApiUrl, function (geoDataPointsFromApi) { - removeOlderPoints() - displayPointsFromApi(geoDataPointsFromApi); + removeOlderPoints() + displayPointsFromApi(geoDataPointsFromApi); - loadedSuccess(); - isLoading = false; - }); // end of the getting from overpass API - } + console.log('cuisineSet', new Set(cuisineSet)) + loadedSuccess(); + isLoading = false; + }); // end of the getting from overpass API + } } console.log('loadQueryPoints', loadQueryPoints); @@ -475,14 +515,14 @@ $('#spinning_icon').hide(); */ $('#query-button').click(function () { - loadOverpassQuery(); + loadOverpassQuery(); }); $('#toggle_cafe').click(function () { - toggleFilter('cafe'); + toggleFilter('cafe'); }); $('#toggle_restaurant').click(function () { - toggleFilter('restaurant'); + toggleFilter('restaurant'); }); $('#toggle_fast_food').click(function () { - toggleFilter('fast_food'); + toggleFilter('fast_food'); }); \ No newline at end of file