refactor: submap - restore lake names

This commit is contained in:
Azgaar 2024-10-20 02:04:17 +02:00
parent b00c968091
commit 431a5aa3e9

View file

@ -47,9 +47,9 @@ window.Submap = (function () {
restoreProvinces(parentMap);
restoreMarkers(parentMap, projection);
restoreZones(parentMap, projection, options);
restoreFeatureDetails(parentMap, inverse);
Rivers.specify();
Features.specify();
showStatistics();
}
@ -277,6 +277,21 @@ window.Submap = (function () {
});
}
function restoreFeatureDetails(parentMap, inverse) {
pack.features.forEach(feature => {
if (!feature) return;
const [x, y] = pack.cells.p[feature.firstCell];
const [parentX, parentY] = inverse(x, y);
const parentCell = parentMap.pack.cells.q.find(parentX, parentY, Infinity)[2];
if (parentCell === undefined) return;
const parentFeature = parentMap.pack.features[parentMap.pack.cells.f[parentCell]];
if (parentFeature.group) feature.group = parentFeature.group;
if (parentFeature.name) feature.name = parentFeature.name;
if (parentFeature.height) feature.height = parentFeature.height;
});
}
function groupCellsByType(graph) {
return graph.cells.p.reduce(
(acc, [x, y], cellId) => {