liens de complétion de rue overpass
This commit is contained in:
parent
5490453764
commit
b771aea541
1 changed files with 20 additions and 8 deletions
|
@ -30,13 +30,14 @@
|
|||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="missing-streets-block" class="mt-5">
|
||||
<h2>Rues sans lieu associé (données OSM)</h2>
|
||||
<div id="missing-streets-loading">Chargement des rues OSM…</div>
|
||||
<ul id="missing-streets-list" class="list-group"></ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
function buildOverpassAroundUrl(street, bbox) {
|
||||
|
@ -94,31 +95,32 @@ out tags;
|
|||
})
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
const allStreets = new Set();
|
||||
const allStreets = new Map();
|
||||
(data.elements || []).forEach(el => {
|
||||
if (el.tags && el.tags.name) {
|
||||
allStreets.add(el.tags.name);
|
||||
allStreets.set(el.tags.name, el.id);
|
||||
}
|
||||
});
|
||||
// Filtrer les rues qui n'ont pas de lieu associé
|
||||
const missing = Array.from(allStreets).filter(nom => !ruesConnues.has(nom));
|
||||
const missing = Array.from(allStreets.entries()).filter(([nom]) => !ruesConnues.has(nom));
|
||||
const ul = document.getElementById('missing-streets-list');
|
||||
ul.innerHTML = '';
|
||||
if (missing.length === 0) {
|
||||
ul.innerHTML = '<li class="list-group-item text-success">Toutes les rues OSM ont au moins un lieu associé.</li>';
|
||||
} else {
|
||||
missing.sort((a, b) => a.localeCompare(b, 'fr'));
|
||||
missing.forEach(nom => {
|
||||
missing.sort((a, b) => a[0].localeCompare(b[0], 'fr'));
|
||||
missing.forEach(([nom, wayId]) => {
|
||||
const li = document.createElement('li');
|
||||
li.className = 'list-group-item d-flex justify-content-between align-items-center';
|
||||
li.setAttribute('data-street-name', nom);
|
||||
li.setAttribute('data-way-id', wayId);
|
||||
li.textContent = nom;
|
||||
const buttons = document.createElement('span');
|
||||
buttons.innerHTML = `
|
||||
<a href="#" class="btn btn-outline-secondary btn-sm osm-link" title="Voir la rue sur OpenStreetMap" target="_blank" data-street="${nom}">
|
||||
<a href="https://www.openstreetmap.org/way/${wayId}" class="btn btn-outline-secondary btn-sm osm-link" title="Voir la rue sur OpenStreetMap" target="_blank" data-way-id="${wayId}">
|
||||
<i class="bi bi-globe"></i>
|
||||
</a>
|
||||
<a href="#" class="btn btn-outline-primary btn-sm overpass-link ms-1" title="Lieux possibles sur Overpass" target="_blank" data-street="${nom}">
|
||||
<a href="#" class="btn btn-outline-primary btn-sm overpass-link ms-1" title="Lieux possibles sur Overpass" target="_blank" data-way-id="${wayId}">
|
||||
<i class="bi bi-ev-station"></i>
|
||||
</a>
|
||||
`;
|
||||
|
@ -127,6 +129,16 @@ out tags;
|
|||
});
|
||||
}
|
||||
document.getElementById('missing-streets-loading').style.display = 'none';
|
||||
// Ajout des listeners pour les nouveaux boutons
|
||||
document.querySelectorAll('.overpass-link').forEach(function(a) {
|
||||
a.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
const wayId = this.getAttribute('data-way-id');
|
||||
const overpassQ = `[out:json][timeout:25];\nway(${wayId});\nnw(around.way:10)[shop];\nnw(around.way:10)[amenity];\nout body;\n>;
|
||||
out skel qt;`;
|
||||
window.open(`https://overpass-turbo.eu/?Q=${encodeURIComponent(overpassQ)}`, '_blank');
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(e => {
|
||||
document.getElementById('missing-streets-loading').textContent = 'Erreur lors de la récupération des rues OSM.';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue