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.
This commit is contained in:
Greger 2025-06-11 00:42:31 +02:00 committed by GitHub
parent a6f66e9828
commit 004097ef93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 8 additions and 11 deletions

View file

@ -8146,7 +8146,7 @@
<script defer src="modules/ui/rivers-overview.js?v=1.99.00"></script>
<script defer src="modules/ui/military-overview.js?v=1.108.5"></script>
<script defer src="modules/ui/regiments-overview.js?v=1.108.5"></script>
<script defer src="modules/ui/markers-overview.js?v=1.108.5"></script>
<script defer src="modules/ui/markers-overview.js?v=1.108.7"></script>
<script defer src="modules/ui/regiment-editor.js?v=1.108.5"></script>
<script defer src="modules/ui/battle-screen.js?v=1.108.5"></script>
<script defer src="modules/ui/emblems-editor.js?v=1.99.00"></script>
@ -8161,7 +8161,7 @@
<script defer src="modules/io/save.js?v=1.107.4"></script>
<script defer src="modules/io/load.js?v=1.108.0"></script>
<script defer src="modules/io/cloud.js?v=1.106.0"></script>
<script defer src="modules/io/export.js?v=1.100.00"></script>
<script defer src="modules/io/export.js?v=1.108.7"></script>
<script defer src="modules/renderers/draw-features.js?v=1.108.2"></script>
<script defer src="modules/renderers/draw-borders.js?v=1.104.0"></script>

View file

@ -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};
});

View file

@ -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");

View file

@ -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");
{