add details to rivers json export

This commit is contained in:
Azgaar 2021-12-29 23:23:27 +03:00
parent 8efce5dcd9
commit f08b77bd6a

View file

@ -405,8 +405,8 @@ function saveGeoJSON_Cells() {
json.features.push(feature); json.features.push(feature);
}); });
const name = getFileName("Cells") + ".geojson"; const fileName = getFileName("Cells") + ".geojson";
downloadFile(JSON.stringify(json), name, "application/json"); downloadFile(JSON.stringify(json), fileName, "application/json");
} }
function saveGeoJSON_Routes() { function saveGeoJSON_Routes() {
@ -421,30 +421,25 @@ function saveGeoJSON_Routes() {
json.features.push(feature); json.features.push(feature);
}); });
const name = getFileName("Routes") + ".geojson"; const fileName = getFileName("Routes") + ".geojson";
downloadFile(JSON.stringify(json), name, "application/json"); downloadFile(JSON.stringify(json), fileName, "application/json");
} }
function saveGeoJSON_Rivers() { function saveGeoJSON_Rivers() {
const json = {type: "FeatureCollection", features: []}; const json = {type: "FeatureCollection", features: []};
rivers.selectAll("path").each(function () { rivers.selectAll("path").each(function () {
const coordinates = getRiverPoints(this); const river = pack.rivers.find(r => r.i === +this.id.slice(5));
const id = this.id; if (!river) return;
const width = +this.dataset.increment;
const increment = +this.dataset.increment;
const river = pack.rivers.find(r => r.i === +id.slice(5));
const name = river ? river.name : "";
const type = river ? river.type : "";
const i = river ? river.i : "";
const basin = river ? river.basin : "";
const feature = {type: "Feature", geometry: {type: "LineString", coordinates}, properties: {id, i, basin, name, type, width, increment}}; const coordinates = getRiverPoints(this);
const properties = {...river, id: this.id};
const feature = {type: "Feature", geometry: {type: "LineString", coordinates}, properties};
json.features.push(feature); json.features.push(feature);
}); });
const name = getFileName("Rivers") + ".geojson"; const fileName = getFileName("Rivers") + ".geojson";
downloadFile(JSON.stringify(json), name, "application/json"); downloadFile(JSON.stringify(json), fileName, "application/json");
} }
function saveGeoJSON_Markers() { function saveGeoJSON_Markers() {