added geographic data to burgs CSV export

This commit is contained in:
Tom Vogt 2019-09-01 11:50:02 +02:00
parent ee70be134f
commit 2df9f02440

View file

@ -252,7 +252,7 @@ function editBurgs() {
}
function downloadBurgsData() {
let data = "Id,Burg,State,Culture,Population,Capital,Port\n"; // headers
let data = "Id,Burg,State,Culture,Population,Capital,Port,Longitude,Latitude,Elevation\n"; // headers
const valid = pack.burgs.filter(b => b.i && !b.removed); // all valid burgs
valid.forEach(b => {
@ -262,7 +262,12 @@ function editBurgs() {
data += pack.cultures[b.culture].name + ",";
data += rn(b.population * populationRate.value * urbanization.value) + ",";
data += b.capital ? "capital," : ",";
data += b.port ? "port\n" : "\n";
data += b.port ? "port," : ",";
// add geography data
data += (b.x / graphWidth) * mapCoordinates.lonT + mapCoordinates.lonW + ",";
data += (b.y / graphHeight) * mapCoordinates.latT + mapCoordinates.latS + ",";
data += parseInt(getFriendlyHeight(pack.cells.h[b.cell])) + "\n";
});
const dataBlob = new Blob([data], {type: "text/plain"});
@ -315,7 +320,7 @@ function editBurgs() {
}
});
}
fileReader.readAsText(fileToLoad, "UTF-8");
}
@ -339,4 +344,3 @@ function editBurgs() {
}
}