mirror of
https://forge.chapril.org/tykayn/libre-charge-map
synced 2025-06-20 01:34:43 +02:00
add filters for sockets
This commit is contained in:
parent
ebb2c87bcc
commit
edef80c926
5 changed files with 301 additions and 99 deletions
|
@ -342,7 +342,7 @@ function calculerPourcentage(partie, total, reduc) {
|
|||
return ((partie / total) * 100 * coef_reduction).toFixed(1)
|
||||
}
|
||||
|
||||
function displayStatsFromGeoJson(resultAsGeojson) {
|
||||
function displayStatsFromGeoJson(resultAsGeojson, stats) {
|
||||
let count = resultAsGeojson.features.length;
|
||||
let count_station_output = 0;
|
||||
let count_ref_eu = 0;
|
||||
|
@ -355,7 +355,6 @@ function displayStatsFromGeoJson(resultAsGeojson) {
|
|||
let count_estimated_type2combo = 0;
|
||||
let count_found_type2combo = 0;
|
||||
let count_found_type2 = 0;
|
||||
let count_hidden_by_filters = 0;
|
||||
|
||||
// Compter les filtres désactivés
|
||||
let disabledFilters = 0;
|
||||
|
@ -363,7 +362,7 @@ function displayStatsFromGeoJson(resultAsGeojson) {
|
|||
if (!lcm_config.filterConfigs[filterId]) disabledFilters++;
|
||||
});
|
||||
|
||||
$('#count_features_fond').html('⚡' + count + ' stations' + (disabledFilters > 0 ? ` (${disabledFilters} filtre${disabledFilters > 1 ? 's' : ''} désactivé${disabledFilters > 1 ? 's' : ''}, ${count_hidden_by_filters} masqué${count_hidden_by_filters > 1 ? 's' : ''})` : ''));
|
||||
$('#count_features_fond').html('⚡' + count + ' stations' + (disabledFilters > 0 ? ` (${disabledFilters} filtre${disabledFilters > 1 ? 's' : ''} désactivé${disabledFilters > 1 ? 's' : ''}, ${stats.count_hidden_by_filters} masqué${stats.count_hidden_by_filters > 1 ? 's' : ''})` : ''));
|
||||
|
||||
resultAsGeojson.features.map(feature => {
|
||||
let found_type2_combo = false;
|
||||
|
@ -501,7 +500,11 @@ function displayPointsFromApi(points, convert_to_osm_json) {
|
|||
geojsondata = osmtogeojson(points);
|
||||
}
|
||||
|
||||
displayStatsFromGeoJson(geojsondata);
|
||||
let stats = {
|
||||
count_hidden_by_filters: 0
|
||||
};
|
||||
|
||||
displayStatsFromGeoJson(geojsondata, stats);
|
||||
|
||||
let resultLayer = L.geoJson(geojsondata, {
|
||||
style: function (feature) {
|
||||
|
@ -523,7 +526,9 @@ function displayPointsFromApi(points, convert_to_osm_json) {
|
|||
supprimerMarqueurs();
|
||||
displayPointsFromApi();
|
||||
},
|
||||
onEachFeature: eachFeature,
|
||||
onEachFeature: function(feature, layer) {
|
||||
eachFeature(feature, layer, stats);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -569,7 +574,7 @@ function makePopupOfFeature(feature) {
|
|||
* @param feature
|
||||
* @param layer
|
||||
*/
|
||||
function eachFeature(feature, layer) {
|
||||
function eachFeature(feature, layer, stats) {
|
||||
let link_josm = createJOSMEditLink(feature);
|
||||
|
||||
let popupContent = makePopupOfFeature(feature);
|
||||
|
@ -581,32 +586,32 @@ function eachFeature(feature, layer) {
|
|||
|
||||
// Vérifier les filtres activés
|
||||
if (lcm_config.filterCCS && !feature.properties.tags['socket:type2_combo']) {
|
||||
count_hidden_by_filters++;
|
||||
stats.count_hidden_by_filters++;
|
||||
return;
|
||||
}
|
||||
|
||||
if (lcm_config.filterType2 && !feature.properties.tags['socket:type2']) {
|
||||
count_hidden_by_filters++;
|
||||
stats.count_hidden_by_filters++;
|
||||
return;
|
||||
}
|
||||
|
||||
if (lcm_config.filterDomestic && !feature.properties.tags['socket:typee']) {
|
||||
count_hidden_by_filters++;
|
||||
stats.count_hidden_by_filters++;
|
||||
return;
|
||||
}
|
||||
|
||||
if (lcm_config.filterChademo && !feature.properties.tags['socket:chademo']) {
|
||||
count_hidden_by_filters++;
|
||||
stats.count_hidden_by_filters++;
|
||||
return;
|
||||
}
|
||||
|
||||
if (lcm_config.filterType1 && !feature.properties.tags['socket:type1']) {
|
||||
count_hidden_by_filters++;
|
||||
stats.count_hidden_by_filters++;
|
||||
return;
|
||||
}
|
||||
|
||||
if (lcm_config.filterType3 && !feature.properties.tags['socket:type3']) {
|
||||
count_hidden_by_filters++;
|
||||
stats.count_hidden_by_filters++;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -619,7 +624,7 @@ function eachFeature(feature, layer) {
|
|||
}
|
||||
});
|
||||
if (!hasCableAttached) {
|
||||
count_hidden_by_filters++;
|
||||
stats.count_hidden_by_filters++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -631,7 +636,7 @@ function eachFeature(feature, layer) {
|
|||
feature.properties.tags['payment:none'] ||
|
||||
feature.properties.tags['opening_hours'];
|
||||
if (!hasQualityInfo) {
|
||||
count_hidden_by_filters++;
|
||||
stats.count_hidden_by_filters++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1316,11 +1321,11 @@ function init() {
|
|||
};
|
||||
|
||||
// Créer deux contrôles de couches séparés
|
||||
const baseLayerControl = L.control.layers(baseLayers, null, {
|
||||
collapsed: true,
|
||||
className: 'leaflet-control-layers base-layers',
|
||||
id: 'base-layers-control'
|
||||
}).addTo(map);
|
||||
// const baseLayerControl = L.control.layers(baseLayers, null, {
|
||||
// collapsed: true,
|
||||
// className: 'leaflet-control-layers base-layers',
|
||||
// id: 'base-layers-control'
|
||||
// }).addTo(map);
|
||||
|
||||
const overlayControl = L.control.layers(null, overlayMaps, {
|
||||
collapsed: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue