Skip to content

Commit b228a8f

Browse files
authored
Revert "Ice Layer Data Model (#1262)" (#1275)
This reverts commit e597d90.
1 parent e597d90 commit b228a8f

File tree

13 files changed

+118
-402
lines changed

13 files changed

+118
-402
lines changed

public/main.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,6 @@ async function generate(options) {
632632
Biomes.define();
633633
Features.defineGroups();
634634

635-
Ice.generate();
636-
637635
rankCells();
638636
Cultures.generate();
639637
Cultures.expand();

public/modules/dynamic/auto-update.js

Lines changed: 16 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ export function resolveVersionConflicts(mapVersion) {
253253
const source = findCell(s.x, s.y);
254254
const mouth = findCell(e.x, e.y);
255255
const name = Rivers.getName(mouth);
256-
const type = length < 25 ? rw({ Creek: 9, River: 3, Brook: 3, Stream: 1 }) : "River";
257-
pack.rivers.push({ i, parent: 0, length, source, mouth, basin: i, name, type });
256+
const type = length < 25 ? rw({Creek: 9, River: 3, Brook: 3, Stream: 1}) : "River";
257+
pack.rivers.push({i, parent: 0, length, source, mouth, basin: i, name, type});
258258
});
259259
}
260260

@@ -270,7 +270,7 @@ export function resolveVersionConflicts(mapVersion) {
270270
const era = Names.getBaseShort(P(0.7) ? 1 : rand(nameBases.length)) + " Era";
271271
const eraShort = era[0] + "E";
272272
const military = Military.getDefaultOptions();
273-
options = { winds, year, era, eraShort, military };
273+
options = {winds, year, era, eraShort, military};
274274

275275
// v1.3 added campaings data for all states
276276
States.generateCampaigns();
@@ -481,7 +481,7 @@ export function resolveVersionConflicts(mapVersion) {
481481
if (isOlderThan("1.65.0")) {
482482
// v1.65 changed rivers data
483483
d3.select("#rivers").attr("style", null); // remove style to unhide layer
484-
const { cells, rivers } = pack;
484+
const {cells, rivers} = pack;
485485
const defaultWidthFactor = rn(1 / (pointsInput.dataset.cells / 10000) ** 0.25, 2);
486486

487487
for (const river of rivers) {
@@ -497,8 +497,8 @@ export function resolveVersionConflicts(mapVersion) {
497497

498498
for (let i = 0; i <= segments; i++) {
499499
const shift = increment * i;
500-
const { x: x1, y: y1 } = node.getPointAtLength(length + shift);
501-
const { x: x2, y: y2 } = node.getPointAtLength(length - shift);
500+
const {x: x1, y: y1} = node.getPointAtLength(length + shift);
501+
const {x: x2, y: y2} = node.getPointAtLength(length - shift);
502502
const x = rn((x1 + x2) / 2, 1);
503503
const y = rn((y1 + y2) / 2, 1);
504504

@@ -565,7 +565,7 @@ export function resolveVersionConflicts(mapVersion) {
565565
const fill = circle && circle.getAttribute("fill");
566566
const stroke = circle && circle.getAttribute("stroke");
567567

568-
const marker = { i, icon, type, x, y, size, cell };
568+
const marker = {i, icon, type, x, y, size, cell};
569569
if (size && size !== 30) marker.size = size;
570570
if (!isNaN(px) && px !== 12) marker.px = px;
571571
if (!isNaN(dx) && dx !== 50) marker.dx = dx;
@@ -631,21 +631,21 @@ export function resolveVersionConflicts(mapVersion) {
631631

632632
if (isOlderThan("1.88.0")) {
633633
// v1.87 may have incorrect shield for some reason
634-
pack.states.forEach(({ coa }) => {
634+
pack.states.forEach(({coa}) => {
635635
if (coa?.shield === "state") delete coa.shield;
636636
});
637637
}
638638

639639
if (isOlderThan("1.91.0")) {
640640
// from 1.91.00 custom coa is moved to coa object
641641
pack.states.forEach(state => {
642-
if (state.coa === "custom") state.coa = { custom: true };
642+
if (state.coa === "custom") state.coa = {custom: true};
643643
});
644644
pack.provinces.forEach(province => {
645-
if (province.coa === "custom") province.coa = { custom: true };
645+
if (province.coa === "custom") province.coa = {custom: true};
646646
});
647647
pack.burgs.forEach(burg => {
648-
if (burg.coa === "custom") burg.coa = { custom: true };
648+
if (burg.coa === "custom") burg.coa = {custom: true};
649649
});
650650

651651
// from 1.91.00 emblems don't have transform attribute
@@ -747,7 +747,7 @@ export function resolveVersionConflicts(mapVersion) {
747747
const skip = terrs.attr("skip");
748748
const relax = terrs.attr("relax");
749749

750-
const curveTypes = { 0: "curveBasisClosed", 1: "curveLinear", 2: "curveStep" };
750+
const curveTypes = {0: "curveBasisClosed", 1: "curveLinear", 2: "curveStep"};
751751
const curve = curveTypes[terrs.attr("curve")] || "curveBasisClosed";
752752

753753
terrs
@@ -882,7 +882,7 @@ export function resolveVersionConflicts(mapVersion) {
882882
const secondCellId = points[1][2];
883883
const feature = pack.cells.f[secondCellId];
884884

885-
pack.routes.push({ i: pack.routes.length, group, feature, points });
885+
pack.routes.push({i: pack.routes.length, group, feature, points});
886886
}
887887
}
888888
routes.selectAll("path").remove();
@@ -914,7 +914,7 @@ export function resolveVersionConflicts(mapVersion) {
914914
const type = this.dataset.type;
915915
const color = this.getAttribute("fill");
916916
const cells = this.dataset.cells.split(",").map(Number);
917-
pack.zones.push({ i, name, type, cells, color });
917+
pack.zones.push({i, name, type, cells, color});
918918
});
919919
zones.style("display", null).selectAll("*").remove();
920920
if (layerIsOn("toggleZones")) drawZones();
@@ -975,7 +975,7 @@ export function resolveVersionConflicts(mapVersion) {
975975

976976
if (isOlderThan("1.109.0")) {
977977
// v1.109.0 added customizable burg groups and icons
978-
options.burgs = { groups: [] };
978+
options.burgs = {groups: []};
979979

980980
burgIcons.selectAll("circle, use").each(function () {
981981
const group = this.parentNode.id;
@@ -987,7 +987,7 @@ export function resolveVersionConflicts(mapVersion) {
987987
burgIcons.selectAll("g").each(function (_el, index) {
988988
const name = this.id;
989989
const isDefault = name === "towns";
990-
options.burgs.groups.push({ name, active: true, order: index + 1, isDefault, preview: "watabou-city" });
990+
options.burgs.groups.push({name, active: true, order: index + 1, isDefault, preview: "watabou-city"});
991991
if (!this.dataset.icon) this.dataset.icon = "#icon-circle";
992992

993993
const size = Number(this.getAttribute("size") || 2) * 2;
@@ -1036,74 +1036,4 @@ export function resolveVersionConflicts(mapVersion) {
10361036
delete options.showMFCGMap;
10371037
delete options.villageMaxPopulation;
10381038
}
1039-
1040-
if (isOlderThan("1.111.0")) {
1041-
// v1.111.0 moved ice data from SVG to data model
1042-
// Migrate old ice SVG elements to new pack.ice structure
1043-
if (!pack.ice) {
1044-
pack.ice = [];
1045-
let iceId = 0;
1046-
1047-
const iceLayer = document.getElementById("ice");
1048-
if (iceLayer) {
1049-
// Migrate glaciers (type="iceShield")
1050-
iceLayer.querySelectorAll("polygon[type='iceShield']").forEach(polygon => {
1051-
// Parse points string "x1,y1 x2,y2 x3,y3 ..." into array [[x1,y1], [x2,y2], ...]
1052-
const points = [...polygon.points].map(svgPoint => [svgPoint.x, svgPoint.y]);
1053-
1054-
const transform = polygon.getAttribute("transform");
1055-
const iceElement = {
1056-
i: iceId++,
1057-
points,
1058-
type: "glacier"
1059-
};
1060-
if (transform) {
1061-
iceElement.offset = parseTransform(transform);
1062-
}
1063-
pack.ice.push(iceElement);
1064-
});
1065-
1066-
// Migrate icebergs
1067-
iceLayer.querySelectorAll("polygon:not([type])").forEach(polygon => {
1068-
const cellId = +polygon.getAttribute("cell");
1069-
const size = +polygon.getAttribute("size");
1070-
1071-
// points string must exist, cell attribute must be present, and size must be non-zero
1072-
if (polygon.getAttribute("cell") === null || !size) return;
1073-
1074-
// Parse points string "x1,y1 x2,y2 x3,y3 ..." into array [[x1,y1], [x2,y2], ...]
1075-
const points = [...polygon.points].map(svgPoint => [svgPoint.x, svgPoint.y]);
1076-
1077-
const transform = polygon.getAttribute("transform");
1078-
const iceElement = {
1079-
i: iceId++,
1080-
points,
1081-
type: "iceberg",
1082-
cellId,
1083-
size
1084-
};
1085-
if (transform) {
1086-
iceElement.offset = parseTransform(transform);
1087-
}
1088-
pack.ice.push(iceElement);
1089-
});
1090-
1091-
// Clear old SVG elements
1092-
iceLayer.querySelectorAll("*").forEach(el => el.remove());
1093-
} else {
1094-
// If ice layer element doesn't exist, create it
1095-
ice = viewbox.insert("g", "#coastline").attr("id", "ice");
1096-
ice
1097-
.attr("opacity", null)
1098-
.attr("fill", "#e8f0f6")
1099-
.attr("stroke", "#e8f0f6")
1100-
.attr("stroke-width", 1)
1101-
.attr("filter", "url(#dropShadow05)");
1102-
}
1103-
1104-
// Re-render ice from migrated data
1105-
if (layerIsOn("toggleIce")) drawIce();
1106-
}
1107-
1108-
}
11091039
}

public/modules/ice.js

Lines changed: 0 additions & 170 deletions
This file was deleted.

public/modules/io/load.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,6 @@ async function parseLoadedData(data, mapVersion) {
406406
pack.cells.province = data[27] ? Uint16Array.from(data[27].split(",")) : new Uint16Array(pack.cells.i.length);
407407
// data[28] had deprecated cells.crossroad
408408
pack.cells.routes = data[36] ? JSON.parse(data[36]) : {};
409-
pack.ice = data[39] ? JSON.parse(data[39]) : [];
410409

411410
if (data[31]) {
412411
const namesDL = data[31].split("/");
@@ -450,7 +449,7 @@ async function parseLoadedData(data, mapVersion) {
450449
if (isVisible(routes) && hasChild(routes, "path")) turnOn("toggleRoutes");
451450
if (hasChildren(temperature)) turnOn("toggleTemperature");
452451
if (hasChild(population, "line")) turnOn("togglePopulation");
453-
if (isVisible(ice)) turnOn("toggleIce");
452+
if (hasChildren(ice)) turnOn("toggleIce");
454453
if (hasChild(prec, "circle")) turnOn("togglePrecipitation");
455454
if (isVisible(emblems) && hasChild(emblems, "use")) turnOn("toggleEmblems");
456455
if (isVisible(labels)) turnOn("toggleLabels");

0 commit comments

Comments
 (0)