libre-charge-map/js/lcm_stats.js
2025-05-02 12:09:40 +02:00

78 lines
3.7 KiB
JavaScript

// source https://www.edf.fr/groupe-edf/comprendre/electricite-au-quotidien/usages/consommation-electricite-en-chiffres
const france_twh = 460
// source baromètre avere
const irve_monthly_consumption_gwh = 69
// info vue je ne sais plus où pour l'avere
const stations_avere = 40000
fetch('./js/stats.json')
.then(response => response.json())
.then(stats => {
annual_consumption_gwh = compute_annual_consumption_gwh(irve_monthly_consumption_gwh, france_twh)
// import * as stats from './stats.json' assert { type: 'json' };
console.log(stats);
document.getElementById('countStationsOSM').textContent = formatSpaceSeparator(stats.countStationsOSM);
document.getElementById('countStationsOpenData').textContent = formatSpaceSeparator(stats.count_unique_id_station_itinerance);
document.getElementById('countStationsAVERE').textContent = formatSpaceSeparator(stations_avere);
document.getElementById('countPointsDeChargeAVERE').textContent = formatSpaceSeparator(stats.countStationsAVERE);
document.getElementById('countPointsDeChargeOSM').textContent = formatSpaceSeparator(stats.countPointsDeChargeOSM);
document.getElementById('countPointsDeChargeOpenData').textContent = formatSpaceSeparator(stats.countPointsDeChargeOpenData);
document.getElementById('dateGeneration').textContent = stats.dateGeneration;
proportion_annual_consumption_gwh = compute_proportion_annual_consumption_gwh(annual_consumption_gwh, stats.countStationsAVERE)
stats.proportion_annual_consumption_gwh = proportion_annual_consumption_gwh;
console.log('estimation de la consommation annuelle des stations de recharge en France', annual_consumption_gwh, 'GWh sur ', france_twh * 1000, 'GWh')
console.log('proportion de la consommation annuelle par borne', proportion_annual_consumption_gwh)
// document.addEventListener('DOMContentLoaded', () => {
makeComparaisonAnalyse(stats);
// });
})
.catch(error => {
console.error('Erreur lors du chargement du fichier stats.json:', error);
});
function makeComparaisonAnalyse(stats) {
annual_consumption_gwh = compute_annual_consumption_gwh(irve_monthly_consumption_gwh, france_twh)
let analyse = document.getElementById('analyse_comparaison');
if (analyse) {
analyse.textContent = 'La consommation annuelle des stations de recharge en France est de ' + formatSpaceSeparator(annual_consumption_gwh) + 'GWh sur ' + formatSpaceSeparator(france_twh * 1000) + 'GWh. Soit ' + formatSpaceSeparator(stats.proportion_annual_consumption_gwh) + '% de la consommation annuelle en électricité de la France.';
let manqueOSM = stations_avere - stats.countStationsOSM;
let pourcentageManquant = ((manqueOSM / stations_avere) * 100).toFixed(1);
// let manquePointsDeChargeOSM = stats.countStationsOpenData - stats.countPointsDeChargeOSM;
// let pourcentagePointsDeChargeManquant = ((manquePointsDeChargeOSM / stats.countStationsOpenData) * 100).toFixed(1);
// analyse.innerHTML += `<br/> Il manque ${formatSpaceSeparator(manquePointsDeChargeOSM)} points de charge dans OSM par rapport aux données de l'OpenData, soit ${pourcentagePointsDeChargeManquant}% des points de charge.`;
analyse.innerHTML += `<br/> Il manque ${formatSpaceSeparator(manqueOSM)} stations dans OSM par rapport aux données de l'AVERE, soit ${pourcentageManquant}% des stations et de points de charge.`;
}
}
function compute_annual_consumption_gwh(irve_monthly_consumption_gwh, france_twh) {
return irve_monthly_consumption_gwh * 12;
}
function compute_proportion_annual_consumption_gwh(annual_consumption_gwh, countStationsAVERE) {
return (annual_consumption_gwh / countStationsAVERE).toFixed(2);
}
function formatSpaceSeparator(number) {
return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
}