#320 Export Urban and Rural populations (#321)

* Export Rural and Urban populations for states and provinces

Exactly what it says on the tin.

* Replaced Floor with round

For better accuracy, otherwise discrepancies of 1 or 2 may be present. Not really a big deal but still.

* Update for urbanization value
This commit is contained in:
Legendsmith 2019-10-08 23:46:56 +11:00 committed by Azgaar
parent ea4e5ce4c9
commit 40f4f30814
2 changed files with 10 additions and 4 deletions

View file

@ -761,9 +761,10 @@ function editProvinces() {
function downloadProvincesData() {
const unit = areaUnit.value === "square" ? distanceUnitInput.value + "2" : areaUnit.value;
let data = "Id,Province,Form,State,Color,Capital,Area "+unit+",Population\n"; // headers
let data = "Id,Province,Form,State,Color,Capital,Area "+unit+",Total Population,Rural Population,Urban Population\n"; // headers
body.querySelectorAll(":scope > div").forEach(function(el) {
let key = parseInt(el.dataset.id)
data += el.dataset.id + ",";
data += el.dataset.name + ",";
data += el.dataset.form + ",";
@ -771,7 +772,9 @@ function editProvinces() {
data += el.dataset.color + ",";
data += el.dataset.capital + ",";
data += el.dataset.area + ",";
data += el.dataset.population + "\n";
data += el.dataset.population + ",";
data += `${Math.round(pack.provinces[key].rural*populationRate.value)},`
data += `${Math.round(pack.provinces[key].urban*populationRate.value * urbanization.value)}\n`
});
const dataBlob = new Blob([data], {type: "text/plain"});

View file

@ -869,9 +869,10 @@ function editStates() {
function downloadStatesData() {
const unit = areaUnit.value === "square" ? distanceUnitInput.value + "2" : areaUnit.value;
let data = "Id,State,Color,Capital,Culture,Type,Expansionism,Cells,Burgs,Area "+unit+",Population\n"; // headers
let data = "Id,State,Color,Capital,Culture,Type,Expansionism,Cells,Burgs,Area "+unit+",Total Population,Rural Population,Urban Population\n"; // headers
body.querySelectorAll(":scope > div").forEach(function(el) {
let key = parseInt(el.dataset.id)
data += el.dataset.id + ",";
data += el.dataset.name + ",";
data += el.dataset.color + ",";
@ -882,7 +883,9 @@ function editStates() {
data += el.dataset.cells + ",";
data += el.dataset.burgs + ",";
data += el.dataset.area + ",";
data += el.dataset.population + "\n";
data += el.dataset.population + ",";
data += `${Math.round(pack.states[key].rural*populationRate.value)},`;
data += `${Math.round(pack.states[key].urban*populationRate.value * urbanization.value)}\n`;
});
const dataBlob = new Blob([data], {type: "text/plain"});