2025-05-26 23:51:46 +02:00
|
|
|
{% extends 'base.html.twig' %}
|
|
|
|
|
|
|
|
{% block title %}{{ 'display.stats'|trans }}{% endblock %}
|
|
|
|
|
2025-06-01 19:52:56 +02:00
|
|
|
{% block stylesheets %}
|
|
|
|
{{ parent() }}
|
|
|
|
<link href='https://cdn.jsdelivr.net/npm/maplibre-gl@3.6.2/dist/maplibre-gl.css' rel='stylesheet' />
|
|
|
|
{% endblock %}
|
|
|
|
|
2025-05-26 23:51:46 +02:00
|
|
|
{% block body %}
|
|
|
|
<div class="container">
|
2025-05-29 16:50:25 +02:00
|
|
|
<div class="mt-4 p-4">
|
|
|
|
<h1 class="title">{{ 'display.stats'|trans }}</h1>
|
2025-05-26 23:51:46 +02:00
|
|
|
<p>
|
|
|
|
{{ stats.zone }}
|
|
|
|
</p>
|
|
|
|
{{ stats.getCompletionPercent() }} % complété sur les critères donnés.
|
|
|
|
<br>
|
2025-05-29 16:50:25 +02:00
|
|
|
<i class="bi bi-building"></i> {{ stats.getPlacesCount() }} commerces dans la zone.
|
2025-05-26 23:51:46 +02:00
|
|
|
<br>
|
2025-05-29 16:50:25 +02:00
|
|
|
<i class="bi bi-clock"></i> {{ stats.getAvecHoraires() }} commerces avec horaires.
|
2025-05-26 23:51:46 +02:00
|
|
|
<br>
|
2025-05-29 16:50:25 +02:00
|
|
|
<i class="bi bi-map"></i> {{ stats.getAvecAdresse() }} commerces avec adresse.
|
2025-05-26 23:51:46 +02:00
|
|
|
<br>
|
2025-05-29 16:50:25 +02:00
|
|
|
<i class="bi bi-globe"></i> {{ stats.getAvecSite() }} commerces avec site web renseigné.
|
2025-05-26 23:51:46 +02:00
|
|
|
<br>
|
2025-05-29 16:50:25 +02:00
|
|
|
<i class="bi bi-wheelchair"></i> {{ stats.getAvecAccessibilite() }} commerces avec accessibilité renseignée.
|
2025-05-26 23:51:46 +02:00
|
|
|
<br>
|
2025-05-29 16:50:25 +02:00
|
|
|
<i class="bi bi-chat-dots"></i> {{ stats.getAvecNote() }} commerces avec note renseignée.
|
2025-05-26 23:51:46 +02:00
|
|
|
<br>
|
|
|
|
</div>
|
2025-06-01 19:52:56 +02:00
|
|
|
<div id="map" style="height: 400px;"></div>
|
2025-05-26 23:51:46 +02:00
|
|
|
<div class="card mt-4">
|
2025-06-01 19:52:56 +02:00
|
|
|
<h1 class="card-title">Tableau des lieux</h1>
|
2025-05-26 23:51:46 +02:00
|
|
|
<table class="table table-bordered">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Nom ({{ stats.getPlacesCount() }})</th>
|
2025-06-01 23:35:15 +02:00
|
|
|
<th>Type</th>
|
2025-05-26 23:51:46 +02:00
|
|
|
<th>Adresse ({{ stats.getAvecAdresse() }} / {{ stats.getPlacesCount() }})</th>
|
|
|
|
<th>Site web ({{ stats.getAvecSite() }} / {{ stats.getPlacesCount() }})</th>
|
|
|
|
<th>Accessibilité ({{ stats.getAvecAccessibilite() }} / {{ stats.getPlacesCount() }})</th>
|
|
|
|
<th>Note ({{ stats.getAvecNote() }} / {{ stats.getPlacesCount() }})</th>
|
2025-06-01 23:35:15 +02:00
|
|
|
<th>Note ({{ stats.getAvecNote() }} / {{ stats.getPlacesCount() }})</th>
|
2025-05-26 23:51:46 +02:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for commerce in stats.places %}
|
|
|
|
<tr>
|
2025-05-28 16:24:34 +02:00
|
|
|
<td style="background-color: {{ commerce.hasAddress() ? 'yellowgreen' : 'transparent' }};">
|
2025-06-01 19:52:56 +02:00
|
|
|
<a href="{{ path('app_admin_commerce', {'id': commerce.id}) }}">{{ commerce.name }}</a>
|
2025-05-28 16:24:34 +02:00
|
|
|
</td>
|
2025-06-01 23:35:15 +02:00
|
|
|
<td style="background-color: {{ commerce.mainTag ? 'yellowgreen' : 'transparent' }};">{{ commerce.mainTag }}</td>
|
2025-05-26 23:51:46 +02:00
|
|
|
<td style="background-color: {{ commerce.hasAddress() ? 'yellowgreen' : 'transparent' }};">{{ commerce.address }}</td>
|
|
|
|
<td style="background-color: {{ commerce.hasWebsite() ? 'yellowgreen' : 'transparent' }};">{{ commerce.website }}</td>
|
|
|
|
<td style="background-color: {{ commerce.hasWheelchair() ? 'yellowgreen' : 'transparent' }};">{{ commerce.wheelchair }}</td>
|
2025-06-01 23:35:15 +02:00
|
|
|
<td style="background-color: {{ commerce.hasNote() ? 'yellowgreen' : 'transparent' }};">{{ commerce.note }}</td>
|
|
|
|
<td style="background-color: {{ commerce.hasNote() ? 'yellowgreen' : 'transparent' }};">{{ commerce.noteContent }}</td>
|
2025-05-26 23:51:46 +02:00
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
2025-06-01 18:56:01 +02:00
|
|
|
|
2025-06-01 19:52:56 +02:00
|
|
|
<script src='https://cdn.jsdelivr.net/npm/maplibre-gl@3.6.2/dist/maplibre-gl.js'></script>
|
|
|
|
<script>
|
|
|
|
const request = `[out:json][timeout:25];
|
2025-06-01 18:56:01 +02:00
|
|
|
area["postal_code"="{{ zip_code }}"]->.searchArea;
|
|
|
|
(
|
2025-06-01 19:52:56 +02:00
|
|
|
nw["amenity"]["cafe|bar|restaurant|library|cinema|fast_food"]["name"~"."](area.searchArea);
|
|
|
|
nw["shop"]["name"~"."](area.searchArea);
|
|
|
|
nw["tourism"="museum|hotel|chalet|apartment"]["name"~"."](area.searchArea);
|
|
|
|
nw["office"]["name"~"."](area.searchArea);
|
2025-06-01 18:56:01 +02:00
|
|
|
);
|
|
|
|
out center;
|
|
|
|
>;
|
|
|
|
out skel qt;
|
|
|
|
`;
|
|
|
|
|
2025-06-01 19:52:56 +02:00
|
|
|
async function fetchland() {
|
|
|
|
const encodedRequest = encodeURIComponent(request);
|
|
|
|
const overpassUrl = `https://overpass-api.de/api/interpreter?data=${encodedRequest}`;
|
|
|
|
const response = await fetch(overpassUrl);
|
|
|
|
const data = await response.json();
|
2025-06-01 18:56:01 +02:00
|
|
|
|
2025-06-01 19:52:56 +02:00
|
|
|
const map = new maplibregl.Map({
|
|
|
|
container: 'map',
|
|
|
|
style: 'https://api.maptiler.com/maps/basic-v2/style.json?key={{ maptiler_token }}',
|
|
|
|
center: [2.3488, 48.8534],
|
|
|
|
zoom: 12
|
|
|
|
});
|
2025-06-01 18:56:01 +02:00
|
|
|
|
2025-06-01 19:52:56 +02:00
|
|
|
map.on('load', () => {
|
2025-06-01 23:35:15 +02:00
|
|
|
console.log('map chargé',data.elements);
|
2025-06-01 19:52:56 +02:00
|
|
|
data.elements.forEach(element => {
|
2025-06-01 23:35:15 +02:00
|
|
|
if(element.tags){
|
|
|
|
|
|
|
|
console.log('element', element.tags['name'] , element);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (element.lat && element.lon && element.tags && element.tags['name']) {
|
|
|
|
|
2025-06-01 19:52:56 +02:00
|
|
|
const el = document.createElement('div');
|
|
|
|
el.className = 'marker';
|
|
|
|
el.style.width = '20px';
|
|
|
|
el.style.height = '20px';
|
|
|
|
el.style.borderRadius = '50%';
|
|
|
|
el.style.backgroundColor = '#ff0000';
|
|
|
|
let tagstable = '<table class="table table-bordered"><tr><th>Clé</th><th>Valeur</th></tr>';
|
|
|
|
if (element.tags) {
|
|
|
|
for (const tag in element.tags) {
|
|
|
|
tagstable += `<tr><td>${tag}</td><td>${element.tags[tag]}</td></tr>`;
|
|
|
|
}
|
2025-06-01 18:56:01 +02:00
|
|
|
}
|
2025-06-01 19:52:56 +02:00
|
|
|
tagstable += '</table>';
|
|
|
|
|
2025-06-01 23:35:15 +02:00
|
|
|
// Créer un élément div pour le texte du nom
|
|
|
|
const nameDiv = document.createElement('div');
|
|
|
|
nameDiv.className = 'marker-name';
|
|
|
|
nameDiv.style.position = 'absolute';
|
|
|
|
nameDiv.style.backgroundColor = 'white';
|
|
|
|
nameDiv.style.padding = '2px 5px';
|
|
|
|
nameDiv.style.borderRadius = '3px';
|
|
|
|
nameDiv.style.fontSize = '12px';
|
|
|
|
nameDiv.style.whiteSpace = 'nowrap';
|
|
|
|
nameDiv.style.transform = 'translate(-50%, -150%)';
|
|
|
|
nameDiv.textContent = element.tags?.name || 'Sans nom';
|
|
|
|
el.appendChild(nameDiv);
|
|
|
|
|
2025-06-01 19:52:56 +02:00
|
|
|
new maplibregl.Marker(el)
|
|
|
|
.setLngLat([element.lon, element.lat])
|
|
|
|
.setPopup(new maplibregl.Popup({ offset: 25 })
|
2025-06-01 23:35:15 +02:00
|
|
|
.setHTML(
|
|
|
|
`<a href="/admin/placeType/${element.type}/${element.id}" ><h3>${element.tags?.name || 'Sans nom'}</h3></a> <br><a href="https://openstreetmap.org/${element.type}/${element.id}" target="_blank">OSM</a> ${tagstable}`
|
|
|
|
)
|
|
|
|
)
|
2025-06-01 19:52:56 +02:00
|
|
|
.addTo(map);
|
2025-06-01 18:56:01 +02:00
|
|
|
}
|
2025-06-01 19:52:56 +02:00
|
|
|
});
|
|
|
|
});
|
2025-06-01 18:56:01 +02:00
|
|
|
|
2025-06-01 19:52:56 +02:00
|
|
|
// Calculer les limites (bounds) à partir des marqueurs
|
|
|
|
const bounds = new maplibregl.LngLatBounds();
|
|
|
|
data.elements.forEach(element => {
|
|
|
|
if (element.lat && element.lon) {
|
|
|
|
bounds.extend([element.lon, element.lat]);
|
2025-05-28 16:24:34 +02:00
|
|
|
}
|
2025-06-01 19:52:56 +02:00
|
|
|
});
|
2025-05-28 16:24:34 +02:00
|
|
|
|
2025-06-01 19:52:56 +02:00
|
|
|
// Centrer et zoomer la carte pour inclure tous les marqueurs
|
|
|
|
if (!bounds.isEmpty()) {
|
|
|
|
map.fitBounds(bounds, {
|
|
|
|
padding: 50 // Ajoute une marge autour des marqueurs
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2025-06-01 18:56:01 +02:00
|
|
|
|
2025-06-01 19:52:56 +02:00
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
const headers = document.querySelectorAll('th');
|
|
|
|
headers.forEach(header => {
|
|
|
|
const text = header.textContent;
|
|
|
|
const match = text.match(/\((\d+)\s*\/\s*(\d+)\)/);
|
|
|
|
if (match) {
|
|
|
|
const [_, completed, total] = match;
|
|
|
|
const ratio = completed / total;
|
|
|
|
const alpha = ratio.toFixed(2);
|
|
|
|
header.style.backgroundColor = `rgba(154, 205, 50, ${alpha})`;
|
2025-06-01 18:56:01 +02:00
|
|
|
}
|
2025-06-01 19:52:56 +02:00
|
|
|
});
|
2025-06-01 18:56:01 +02:00
|
|
|
|
|
|
|
fetchland();
|
2025-06-01 19:52:56 +02:00
|
|
|
|
|
|
|
sortTable();
|
|
|
|
});
|
|
|
|
</script>
|
2025-05-26 23:51:46 +02:00
|
|
|
{% endblock %}
|