followup service refacto
This commit is contained in:
parent
1c2c3575f9
commit
0611b28172
7 changed files with 341 additions and 596 deletions
|
@ -15,34 +15,16 @@
|
|||
<hr>
|
||||
<h3>Suivi par thématique</h3>
|
||||
<div class="row">
|
||||
{% set themes = [
|
||||
'fire_hydrant', 'charging_station', 'toilets', 'bus_stop', 'defibrillator', 'camera', 'recycling', 'substation', 'laboratory', 'school', 'police', 'healthcare', 'places'
|
||||
] %}
|
||||
{% set theme_icons = {
|
||||
'fire_hydrant': 'bi-droplet',
|
||||
'charging_station': 'bi-lightning-charge',
|
||||
'toilets': 'bi-toilet',
|
||||
'bus_stop': 'bi-bus-front',
|
||||
'defibrillator': 'bi-heart-pulse',
|
||||
'camera': 'bi-camera-video',
|
||||
'recycling': 'bi-recycle',
|
||||
'substation': 'bi-plug',
|
||||
'laboratory': 'bi-beaker',
|
||||
'school': 'bi-mortarboard',
|
||||
'police': 'bi-shield-lock',
|
||||
'healthcare': 'bi-hospital',
|
||||
'places': 'bi-geo-alt'
|
||||
} %}
|
||||
{% for theme in themes %}
|
||||
{% for type, label in followup_labels %}
|
||||
<div class="col-md-6 mb-4">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">
|
||||
<i class="bi {{ theme_icons[theme]|default('bi-question-circle') }}"></i>
|
||||
{{ theme|replace({'_': ' '})|title }}
|
||||
<i class="bi {{ followup_icons[type]|default('bi-question-circle') }}"></i>
|
||||
{{ label }}
|
||||
</h5>
|
||||
<canvas id="chart-{{ theme }}-count" height="60"></canvas>
|
||||
<canvas id="chart-{{ theme }}-completion" height="60"></canvas>
|
||||
<canvas id="chart-{{ type }}-count" height="60"></canvas>
|
||||
<canvas id="chart-{{ type }}-completion" height="60"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -87,7 +69,7 @@ new Chart(ctxSummary, {
|
|||
}
|
||||
});
|
||||
// Graphes par thème
|
||||
const themes = {{ themes|json_encode|raw }};
|
||||
const themes = {{ followup_labels|keys|json_encode|raw }};
|
||||
themes.forEach(theme => {
|
||||
// Count
|
||||
const countData = (series[theme + '_count'] || []).map(e => ({x: e.date, y: e.value}));
|
||||
|
|
|
@ -17,37 +17,11 @@
|
|||
</a>
|
||||
</div>
|
||||
<p>Historique des objets suivis (nombre et complétion).</p>
|
||||
{% set type_labels = {
|
||||
'fire_hydrant': 'Bornes incendie',
|
||||
'charging_station': 'Bornes de recharge',
|
||||
'toilets': 'Toilettes publiques',
|
||||
'bus_stop': 'Arrêts de bus',
|
||||
'defibrillator': 'Défibrillateurs',
|
||||
'camera': 'Caméras de surveillance',
|
||||
'recycling': 'Points de recyclage',
|
||||
'substation': 'Sous-stations électriques',
|
||||
'laboratory': "Laboratoires d'analyse",
|
||||
'school': 'Écoles',
|
||||
'police': 'Commissariats',
|
||||
'healthcare': 'Lieux de santé'
|
||||
} %}
|
||||
{% for type in type_labels|keys %}
|
||||
<h2 id="title-{{ type }}">{{ type_labels[type] }}</h2>
|
||||
{% for type, label in followup_labels %}
|
||||
<h2 id="title-{{ type }}"><i class="bi {{ followup_icons[type]|default('bi-question-circle') }}"></i> {{ label }}</h2>
|
||||
<canvas id="{{ type }}Chart" width="600" height="300"></canvas>
|
||||
<div class="mb-3">
|
||||
{% set overpass_queries = {
|
||||
'fire_hydrant': 'nwr["emergency"="fire_hydrant"](area.searchArea);',
|
||||
'charging_station': 'nwr["amenity"="charging_station"](area.searchArea);',
|
||||
'toilets': 'nwr["amenity"="toilets"](area.searchArea);',
|
||||
'bus_stop': 'nwr["highway"="bus_stop"](area.searchArea);',
|
||||
'defibrillator': 'nwr["emergency"="defibrillator"](area.searchArea);',
|
||||
'camera': 'nwr["man_made"="surveillance"](area.searchArea);',
|
||||
'recycling': 'nwr["amenity"="recycling"](area.searchArea);',
|
||||
'substation': 'nwr["power"="substation"](area.searchArea);',
|
||||
'laboratory': 'nwr["healthcare"="laboratory"](area.searchArea);',
|
||||
'school': 'nwr["amenity"="school"](area.searchArea);'
|
||||
} %}
|
||||
{% set overpass_query = '[out:json][timeout:60];\narea["ref:INSEE"="' ~ stats.zone ~ '"]->.searchArea;\n(' ~ overpass_queries[type]|default('') ~ ');\n\n(._;>;);\n\nout meta;\n>;' %}
|
||||
{% set overpass_query = '[out:json][timeout:60];\narea["ref:INSEE"="' ~ stats.zone ~ '"]->.searchArea;\n(' ~ followup_overpass[type]|default('') ~ ');\n\n(._;>;);\n\nout meta;\n>;' %}
|
||||
<a href="https://overpass-turbo.eu/?Q={{ overpass_query|url_encode }}" target="_blank" class="btn btn-sm btn-outline-primary me-2">
|
||||
<i class="bi bi-geo"></i> Voir sur Overpass Turbo
|
||||
</a>
|
||||
|
|
|
@ -146,7 +146,7 @@
|
|||
'healthcare': 'bi-hospital',
|
||||
'places': 'bi-geo-alt'
|
||||
} %}
|
||||
{% set type_labels = {
|
||||
{% set followup_labels = {
|
||||
'fire_hydrant': 'Bornes incendie',
|
||||
'charging_station': 'Bornes de recharge',
|
||||
'toilets': 'Toilettes publiques',
|
||||
|
@ -197,7 +197,7 @@
|
|||
<div class="card-body p-2">
|
||||
<span class="completion-badge {{ completion_class }}"></span><br>
|
||||
<i class="bi {{ followup_icons[type]|default('bi-question-circle') }} fs-2 mb-1"></i><br>
|
||||
<a href="http://127.0.0.1:8111/import?url=https://overpass-api.de/api/interpreter?data={{ overpass_query|url_encode }}" target="_blank" class="fw-bold text-decoration-underline text-dark" title="Charger dans JOSM">{{ type_labels[type]|default(type|capitalize) }}</a><br>
|
||||
<a href="http://127.0.0.1:8111/import?url=https://overpass-api.de/api/interpreter?data={{ overpass_query|url_encode }}" target="_blank" class="fw-bold text-decoration-underline text-dark" title="Charger dans JOSM">{{ followup_labels[type]|default(type|capitalize) }}</a><br>
|
||||
<span title="Nombre"> {{ data.count is defined ? data.count.getMeasure() : '?' }}</span><br>
|
||||
<span title="Complétion"> {{ completion is not null ? completion : '?' }}%</span>
|
||||
</div>
|
||||
|
@ -209,7 +209,7 @@
|
|||
<div class="card-body p-2">
|
||||
<span class="completion-badge" style="background:#eee;"></span><br>
|
||||
<i class="bi bi-question-circle fs-2 mb-1"></i><br>
|
||||
<span class="fw-bold">{{ type_labels[type]|default(type|capitalize) }}</span><br>
|
||||
<span class="fw-bold">{{ followup_labels[type]|default(type|capitalize) }}</span><br>
|
||||
<span title="Nombre">N = ?</span><br>
|
||||
<span title="Complétion">?%</span>
|
||||
</div>
|
||||
|
@ -629,13 +629,18 @@
|
|||
const place_relations = [];
|
||||
const places = {{ geojson|raw }}.features;
|
||||
places.forEach(place => {
|
||||
if (place.properties.getOsmKind() === 'node') {
|
||||
if (
|
||||
place.properties.getOsmKind() === 'node'
|
||||
) {
|
||||
place_nodes.push(place.properties.id.split('/')[1]);
|
||||
} elseif (place.properties.getOsmKind() === 'way') {
|
||||
} else if (
|
||||
place.properties.getOsmKind() === 'way'
|
||||
) {
|
||||
place_ways.push(place.properties.id.split('/')[1]);
|
||||
} elseif (place.properties.getOsmKind() === 'relation') {
|
||||
place_relations.push(place.properties.id.split('/')[1]);
|
||||
}
|
||||
// elseif (place.properties.getOsmKind() === 'relation') {
|
||||
// place_relations.push(place.properties.id.split('/')[1]);
|
||||
// }
|
||||
});
|
||||
const overpass_josm_query = '[out:xml][timeout:60];\n' +
|
||||
(place_nodes.length > 0 ? 'node(id:' + place_nodes.join(',') + ');\n' : '') +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue