Fix rural population calculation to only count small burgs

Rural population now correctly counted only from burgs with ≤100 people.
Eliminates double-counting and ensures consistent statistics across
charts and CSV exports.
This commit is contained in:
barrulus 2025-08-13 23:35:26 +01:00
parent e669549390
commit 8ec53293b7
2 changed files with 17 additions and 6 deletions

View file

@ -672,7 +672,14 @@ function getUrbanPopulation(cellId) {
}
function getRuralPopulation(cellId) {
return pack.cells.pop[cellId] * populationRate;
const burgId = pack.cells.burg[cellId];
if (!burgId) return 0; // No burg = no rural population
const burgPopulation = pack.burgs[burgId].population;
if (burgPopulation > 0.1) return 0; // Burg has >100 people = no rural population
// Small burg (≤100 people) = count the burg's actual population as rural
return burgPopulation * 1000 * populationRate;
}
function sortData(data, sorting) {