From 004097ef93b8f7a6d003c0fd70ebc9b9afd81260 Mon Sep 17 00:00:00 2001 From: Greger Date: Wed, 11 Jun 2025 00:42:31 +0200 Subject: [PATCH] Make id field in exports more consistent. (#1210) The id field for geojson export was not consistent with csv exports. Removes the prefix on routes, rivers and markers geojson, and on markers csv, to make them all use only an integer as id. This makes it easier to import and do joins in other software. --- index.html | 4 ++-- modules/io/export.js | 9 +++------ modules/ui/markers-overview.js | 4 ++-- versioning.js | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index c8a93c8a..92c2b35e 100644 --- a/index.html +++ b/index.html @@ -8146,7 +8146,7 @@ - + @@ -8161,7 +8161,7 @@ - + diff --git a/modules/io/export.js b/modules/io/export.js index 92d31e50..fa816bb2 100644 --- a/modules/io/export.js +++ b/modules/io/export.js @@ -485,11 +485,10 @@ function saveGeoJsonCells() { function saveGeoJsonRoutes() { const features = pack.routes.map(({i, points, group, name = null}) => { const coordinates = points.map(([x, y]) => getCoordinates(x, y, 4)); - const id = `route${i}`; return { type: "Feature", geometry: {type: "LineString", coordinates}, - properties: {id, group, name} + properties: {id: i, group, name} }; }); const json = {type: "FeatureCollection", features}; @@ -504,11 +503,10 @@ function saveGeoJsonRivers() { if (!cells || cells.length < 2) return; const meanderedPoints = Rivers.addMeandering(cells, points); const coordinates = meanderedPoints.map(([x, y]) => getCoordinates(x, y, 4)); - const id = `river${i}`; return { type: "Feature", geometry: {type: "LineString", coordinates}, - properties: {id, source, mouth, parent, basin, widthFactor, sourceWidth, discharge, name, type} + properties: {id: i, source, mouth, parent, basin, widthFactor, sourceWidth, discharge, name, type} }; } ); @@ -522,9 +520,8 @@ function saveGeoJsonMarkers() { const features = pack.markers.map(marker => { const {i, type, icon, x, y, size, fill, stroke} = marker; const coordinates = getCoordinates(x, y, 4); - const id = `marker${i}`; const note = notes.find(note => note.id === id); - const properties = {id, type, icon, x, y, ...note, size, fill, stroke}; + const properties = {id: i, type, icon, x, y, ...note, size, fill, stroke}; return {type: "Feature", geometry: {type: "Point", coordinates}, properties}; }); diff --git a/modules/ui/markers-overview.js b/modules/ui/markers-overview.js index bcb2efb0..648de18c 100644 --- a/modules/ui/markers-overview.js +++ b/modules/ui/markers-overview.js @@ -214,7 +214,7 @@ function overviewMarkers() { const body = pack.markers.map(marker => { const {i, type, icon, x, y} = marker; - const id = `marker${i}`; + const note = notes.find(note => note.id === id); const name = note ? quote(note.name) : "Unknown"; const legend = note ? quote(note.legend) : ""; @@ -222,7 +222,7 @@ function overviewMarkers() { const lat = getLatitude(y, 2); const lon = getLongitude(x, 2); - return [id, type, icon, name, legend, x, y, lat, lon].join(","); + return [i, type, icon, name, legend, x, y, lat, lon].join(","); }); const data = headers + body.join("\n"); diff --git a/versioning.js b/versioning.js index d638fc6d..6713f019 100644 --- a/versioning.js +++ b/versioning.js @@ -13,7 +13,7 @@ * Example: 1.102.2 -> Major version 1, Minor version 102, Patch version 2 */ -const VERSION = "1.108.6"; +const VERSION = "1.108.7"; if (parseMapVersion(VERSION) !== VERSION) alert("versioning.js: Invalid format or parsing function"); {