mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-18 10:01:23 +01:00
export of marker data (#305)
* export of marker data fixed elevation in burgs and cells export fixed population in cells export * exporting type (island, lake, etc.) as well now * bugfix in burgs export
This commit is contained in:
parent
d5ec72b6b8
commit
93b6b60f0c
2 changed files with 40 additions and 10 deletions
|
|
@ -240,6 +240,7 @@ function saveGeoJSON() {
|
||||||
Cells: saveGeoJSON_Cells,
|
Cells: saveGeoJSON_Cells,
|
||||||
Routes: saveGeoJSON_Roads,
|
Routes: saveGeoJSON_Roads,
|
||||||
Rivers: saveGeoJSON_Rivers,
|
Rivers: saveGeoJSON_Rivers,
|
||||||
|
Markers: saveGeoJSON_Markers,
|
||||||
Close: function() {$(this).dialog("close");}
|
Close: function() {$(this).dialog("close");}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -430,12 +431,13 @@ function saveGeoJSON_Cells() {
|
||||||
data += "["+x+","+y+"]";
|
data += "["+x+","+y+"]";
|
||||||
data += "]] },\n \"properties\": {\n";
|
data += "]] },\n \"properties\": {\n";
|
||||||
|
|
||||||
let height = parseInt(getFriendlyHeight(cells.h[i]));
|
let height = parseInt(getFriendlyHeight([cells.p[i][0],cells.p[i][1]]));
|
||||||
|
|
||||||
data += " \"id\": \""+i+"\",\n";
|
data += " \"id\": \""+i+"\",\n";
|
||||||
data += " \"height\": \""+height+"\",\n";
|
data += " \"height\": \""+height+"\",\n";
|
||||||
data += " \"biome\": \""+cells.biome[i]+"\",\n";
|
data += " \"biome\": \""+cells.biome[i]+"\",\n";
|
||||||
data += " \"population\": \""+cells.pop[i]+"\",\n";
|
data += " \"type\": \""+pack.features[cells.f[i]].type+"\",\n";
|
||||||
|
data += " \"population\": \""+getFriendlyPopulation(i)+"\",\n";
|
||||||
data += " \"state\": \""+cells.state[i]+"\",\n";
|
data += " \"state\": \""+cells.state[i]+"\",\n";
|
||||||
data += " \"province\": \""+cells.province[i]+"\",\n";
|
data += " \"province\": \""+cells.province[i]+"\",\n";
|
||||||
data += " \"culture\": \""+cells.culture[i]+"\",\n";
|
data += " \"culture\": \""+cells.culture[i]+"\",\n";
|
||||||
|
|
@ -456,6 +458,34 @@ function saveGeoJSON_Cells() {
|
||||||
window.setTimeout(function() {window.URL.revokeObjectURL(url);}, 2000);
|
window.setTimeout(function() {window.URL.revokeObjectURL(url);}, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function saveGeoJSON_Markers() {
|
||||||
|
|
||||||
|
let data = "{ \"type\": \"FeatureCollection\", \"features\": [\n";
|
||||||
|
|
||||||
|
markers._groups[0][0].childNodes.forEach(n => {
|
||||||
|
let x = mapCoordinates.lonW + (n.dataset.x / graphWidth) * mapCoordinates.lonT;
|
||||||
|
let y = mapCoordinates.latN - (n.dataset.y / graphHeight) * mapCoordinates.latT; // this is inverted in QGIS otherwise
|
||||||
|
|
||||||
|
data += "{\n \"type\": \"Feature\",\n \"geometry\": { \"type\": \"Point\", \"coordinates\": ["+x+", "+y+"]";
|
||||||
|
data += " },\n \"properties\": {\n";
|
||||||
|
data += " \"id\": \""+n.id+"\",\n";
|
||||||
|
data += " \"type\": \""+n.dataset.id.substring(8)+"\"\n";
|
||||||
|
data +=" }\n},\n";
|
||||||
|
|
||||||
|
});
|
||||||
|
data = data.substring(0, data.length - 2)+"\n"; // remove trailing comma
|
||||||
|
data += "]}";
|
||||||
|
|
||||||
|
const dataBlob = new Blob([data], {type: "application/json"});
|
||||||
|
const url = window.URL.createObjectURL(dataBlob);
|
||||||
|
const link = document.createElement("a");
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.download = getFileName("Markers") + ".geojson";
|
||||||
|
link.href = url;
|
||||||
|
link.click();
|
||||||
|
window.setTimeout(function() {window.URL.revokeObjectURL(url);}, 2000);
|
||||||
|
}
|
||||||
|
|
||||||
function uploadFile(file, callback) {
|
function uploadFile(file, callback) {
|
||||||
uploadFile.timeStart = performance.now();
|
uploadFile.timeStart = performance.now();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -259,7 +259,7 @@ function editBurgs() {
|
||||||
data += b.name + ",";
|
data += b.name + ",";
|
||||||
const province = pack.cells.province[b.cell];
|
const province = pack.cells.province[b.cell];
|
||||||
data += province ? pack.provinces[province].fullName + "," : ",";
|
data += province ? pack.provinces[province].fullName + "," : ",";
|
||||||
data += b.state ? pack.states[b.state].fullName : pack.states[b.state].name + ",";
|
data += b.state ? pack.states[b.state].fullName +"," : pack.states[b.state].name + ",";
|
||||||
data += pack.cultures[b.culture].name + ",";
|
data += pack.cultures[b.culture].name + ",";
|
||||||
data += pack.religions[pack.cells.religion[b.cell]].name + ",";
|
data += pack.religions[pack.cells.religion[b.cell]].name + ",";
|
||||||
data += rn(b.population * populationRate.value * urbanization.value) + ",";
|
data += rn(b.population * populationRate.value * urbanization.value) + ",";
|
||||||
|
|
@ -267,11 +267,11 @@ function editBurgs() {
|
||||||
// add geography data
|
// add geography data
|
||||||
data += mapCoordinates.lonW + (b.x / graphWidth) * mapCoordinates.lonT + ",";
|
data += mapCoordinates.lonW + (b.x / graphWidth) * mapCoordinates.lonT + ",";
|
||||||
data += mapCoordinates.latN - (b.y / graphHeight) * mapCoordinates.latT + ","; // this is inverted in QGIS otherwise
|
data += mapCoordinates.latN - (b.y / graphHeight) * mapCoordinates.latT + ","; // this is inverted in QGIS otherwise
|
||||||
data += parseInt(getHeight(pack.cells.h[b.cell])) + ",";
|
data += parseInt(getFriendlyHeight([b.x,b.y])) + ",";
|
||||||
|
|
||||||
// add status data
|
// add status data
|
||||||
data += b.capital ? "capital," : ",";
|
data += b.capital ? "true," : "false,";
|
||||||
data += b.port ? "port\n" : "\n";
|
data += b.port ? "true\n" : "false\n";
|
||||||
});
|
});
|
||||||
|
|
||||||
const dataBlob = new Blob([data], {type: "text/plain"});
|
const dataBlob = new Blob([data], {type: "text/plain"});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue