-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt ecoindex calcul (set scale between 0 and 100)
- Loading branch information
1 parent
10a2bb3
commit acc0334
Showing
2 changed files
with
41 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (C) 2019 [email protected] | ||
* Copyright (C) 2019 - 2022 [email protected] | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
|
@@ -15,6 +15,7 @@ | |
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
let quantiles_dom = [0, 47, 75, 159, 233, 298, 358, 417, 476, 537, 603, 674, 753, 843, 949, 1076, 1237, 1459, 1801, 2479, 594601]; | ||
let quantiles_req = [0, 2, 15, 25, 34, 42, 49, 56, 63, 70, 78, 86, 95, 105, 117, 130, 147, 170, 205, 281, 3920]; | ||
let quantiles_size = [0, 1.37, 144.7, 319.53, 479.46, 631.97, 783.38, 937.91, 1098.62, 1265.47, 1448.32, 1648.27, 1876.08, 2142.06, 2465.37, 2866.31, 3401.59, 4155.73, 5400.08, 8037.54, 223212.26]; | ||
|
@@ -30,28 +31,27 @@ const q_dom= computeQuantile(quantiles_dom,dom); | |
const q_req= computeQuantile(quantiles_req,req); | ||
const q_size= computeQuantile(quantiles_size,size); | ||
|
||
|
||
return 100 - 5 * (3*q_dom + 2*q_req + q_size)/6; | ||
} | ||
|
||
function computeQuantile(quantiles,value) | ||
{ | ||
for (let i=1;i<quantiles.length;i++) | ||
{ | ||
if (value<quantiles[i]) return (i + (value-quantiles[i-1])/(quantiles[i] -quantiles[i-1])); | ||
if (value<quantiles[i]) return (i -1 + (value-quantiles[i-1])/(quantiles[i] -quantiles[i-1])); | ||
} | ||
return quantiles.length; | ||
return quantiles.length -1; | ||
} | ||
|
||
|
||
function getEcoIndexGrade(ecoIndex) | ||
{ | ||
if (ecoIndex > 75) return "A"; | ||
if (ecoIndex > 65) return "B"; | ||
if (ecoIndex > 50) return "C"; | ||
if (ecoIndex > 35) return "D"; | ||
if (ecoIndex > 20) return "E"; | ||
if (ecoIndex > 5) return "F"; | ||
if (ecoIndex > 80) return "A"; | ||
if (ecoIndex > 70) return "B"; | ||
if (ecoIndex > 55) return "C"; | ||
if (ecoIndex > 40) return "D"; | ||
if (ecoIndex > 25) return "E"; | ||
if (ecoIndex > 10) return "F"; | ||
return "G"; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters