Compare commits

...

2 Commits

Author SHA1 Message Date
Tykayn 7999ad078a highlight missing hours in restaurants 2022-12-11 16:14:20 +01:00
Tykayn 3b37a33c63 style loaded elements 2022-12-11 15:57:14 +01:00
5 changed files with 7476 additions and 14 deletions

View File

@ -18,7 +18,11 @@ Chaque point dispose d'un lien dans une popup d'information, afin de modifier le
Toute la logique est dans js/main.js
Vous pouvez modifier les paramètres en entête de fichier pour choisir les tuiles de la carte, le lieu de départ, des données de points pré chargées...
# Exemple de requête overpass listant les restaurants
```
https://overpass-api.de/api/interpreter?data=[out:json][timeout:15];(%20%20%20%20%20%20node[amenity=cafe](48.41182300991387,1.154964091314268,48.85561940576297,2.8399921674861432);%20%20%20%20%20%20node[shop=bakery](48.41182300991387,1.154964091314268,48.85561940576297,2.8399921674861432);%20%20%20%20%20%20node[amenity=fast_food](48.41182300991387,1.154964091314268,48.85561940576297,2.8399921674861432);%20%20%20%20%20%20node[amenity=vending_machine](48.41182300991387,1.154964091314268,48.85561940576297,2.8399921674861432);%20%20%20%20%20%20node[amenity=restaurant](48.41182300991387,1.154964091314268,48.85561940576297,2.8399921674861432);%20%20%20%20%20%20node[amenity=pub](48.41182300991387,1.154964091314268,48.85561940576297,2.8399921674861432);%20%20%20%20%20%20node[amenity=bar](48.41182300991387,1.154964091314268,48.85561940576297,2.8399921674861432);%20%20%20%20%20%20node[amenity=drinking_water](48.41182300991387,1.154964091314268,48.85561940576297,2.8399921674861432);%20%20%20%20%20%20node[man_made=water_tap](48.41182300991387,1.154964091314268,48.85561940576297,2.8399921674861432);%20%20%20%20%20%20node[man_made=drinking_fountain](48.41182300991387,1.154964091314268,48.85561940576297,2.8399921674861432);%20%20%20%20%20%20way[amenity=pub](48.41182300991387,1.154964091314268,48.85561940576297,2.8399921674861432);%20%20%20%20%20%20way[amenity=bar](48.41182300991387,1.154964091314268,48.85561940576297,2.8399921674861432);%20%20%20%20%20%20way[amenity=cafe](48.41182300991387,1.154964091314268,48.85561940576297,2.8399921674861432);%20%20%20%20%20%20way[shop=bakery](48.41182300991387,1.154964091314268,48.85561940576297,2.8399921674861432);%20%20%20%20%20%20way[amenity=fast_food](48.41182300991387,1.154964091314268,48.85561940576297,2.8399921674861432);%20%20%20%20%20%20way[amenity=vending_machine](48.41182300991387,1.154964091314268,48.85561940576297,2.8399921674861432);%20%20%20%20%20%20way[amenity=restaurant](48.41182300991387,1.154964091314268,48.85561940576297,2.8399921674861432);%20%20%20%20%20%20);out%20body%20geom;
```
# licence
Gnu Affero 3+

View File

@ -33,7 +33,9 @@
</p >
</div >
<div id="success_load" class="could-be-visible hidden">
Données reçues
</div>
<div id='map' >
<div class='leaflet-control-container' >

File diff suppressed because one or more lines are too long

View File

@ -896,16 +896,17 @@ function buildOverpassApiUrl(map, overpassQuery) {
if (overrideQuery) {
query = `?data=[out:json][timeout:15];(
node[amenity=cafe](${bounds});
node[shop=bakery](${bounds});
node[amenity=bar](${bounds});
node[amenity=cafe](${bounds});
node[amenity=fast_food](${bounds});
node[amenity=vending_machine](${bounds});
node[amenity=restaurant](${bounds});
node[amenity=pub](${bounds});
node[amenity=bar](${bounds});
node[amenity=vending_machine](${bounds});
node[amenity=drinking_water](${bounds});
node[man_made=water_tap](${bounds});
node[man_made=drinking_fountain](${bounds});
way[amenity=microwave](${bounds});
way[amenity=pub](${bounds});
way[amenity=bar](${bounds});
way[amenity=cafe](${bounds});
@ -922,10 +923,11 @@ function buildOverpassApiUrl(map, overpassQuery) {
}
resultUrl = baseUrl + query;
console.log("query url" ,resultUrl)
return resultUrl;
}
const UseLocalJson = true;
const UseLocalJson = false;
const loadQueryPoints = () => {
@ -936,7 +938,13 @@ const loadQueryPoints = () => {
}
};
function loadedSuccess(){
document.querySelector('#success_load').classList.add('visible')
setTimeout(function(){
document.querySelector('#success_load').classList.remove('visible')
},1000)
$('#spinning_icon').fadeOut();
}
function displayPointsFromApi(points) {
var resultAsGeojson = osmtogeojson(points);
@ -975,14 +983,14 @@ function displayPointsFromApi(points) {
}
let icon, cuisine, rest_name = '';
if (feature.properties.tags['name']) {
if (feature.properties.tags['name'] !== undefined) {
rest_name = feature.properties.tags['name'];
} else {
rest_name = '? ';
rest_name = 'nom ? ';
}
if (typeof feature.properties.tags['cuisine'] !== typeof undefined && feature.properties.tags['cuisine'].length) {
cuisine = ' - ' + feature.properties.tags['cuisine'];
cuisine = ' - cuisine: ' + (feature.properties.tags['cuisine'] | '');
}
let html = '<a href="https://www.openstreetmap.org/' + feature.id + '"> ' + rest_name + ' ' + cuisine + '</a>' +
@ -1040,9 +1048,38 @@ function makeCssClassFromTags(tags) {
listOfClasses.push('tag-' + element + '_' + tags[element].replace(':', '--'));
});
getIsOpenFromOpeningHours(tags)
if(tags['opening_hours']){
listOfClasses.push('tag-has-opening-hours')
}else{
listOfClasses.push('tag-no-opening-hours')
}
return listOfClasses.join(' ');
}
/**
* trouver si un magasin est actuellement ouvert, ou si les infos de opening_hours sont absentes
* exemple: Mo 06:30-20:00; Tu 06:30-20:00; We off; Th 06:30-20:00;
* Fr 06:30-20:00; Sa 06:30-20:00; Su 06:30-13:30
* @param tags
* @returns {string}
*/
function getIsOpenFromOpeningHours(tags){
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()];
if(tags['opening_hours'] ){
// trouver les sections séparées par des points virgule
// séparer les sections d'ouverture par un espace entre la plage de jour et les heures
}
console.log(tags['opening_hours'], isOpen )
return isOpen;
}
function getIconFromTags(tags) {
let iconFileName = 'icon_restaurant.png';
if (tags['man_made']) {
@ -1111,7 +1148,8 @@ function loadOverpassQuery() {
$.get(overpassApiUrl, function (geoDataPointsFromApi) {
displayPointsFromApi(geoDataPointsFromApi);
$('#spinning_icon').fadeOut();
loadedSuccess();
isLoading = false;
}); // end of the getting from overpass API
}

View File

@ -50,6 +50,30 @@ p{
h2{
font-weight: normal;
}
#success_load{
text-align: center;
font-weight: 400;
position: fixed;
top: 1em;
height: 3em;
background: mediumseagreen;
z-index: 100;
width: 100vw;
color: white;
padding-right: 1em;
display: block;
box-sizing: border-box;
line-height: 2em;
}
.could-be-visible{
transition: opacity 0.5s;
}
.hidden {
opacity: 0;
}
.visible{
opacity: 1;
}
#overpass-api-controls {
position: fixed;
@ -73,11 +97,11 @@ img.leaflet-marker-icon{
border: solid 1px #ccc;
margin-left: -20px;
margin-top: -20px;
box-shadow: 0 0 3em green;
box-shadow: 0 0 0.5em green;
}
img.leaflet-marker-icon.tag-amenity_drinking_water{
box-shadow: 0 0 3em cornflowerblue;
box-shadow: 0 0 1em cornflowerblue;
}
img.leaflet-marker-icon.diet--vegetarian_yes{
@ -109,7 +133,12 @@ img.leaflet-marker-icon.diet--vegetarian_yes{
.pull-left{
float:left;
}
/**
mettre en valeur les restaurants qui n'ont pas renseigné leurs horaires d'ouverture
*/
.tag-no-opening-hours.tag-amenity_restaurant{
background: #333333 !important;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(359deg); }