mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
v1.5.57 - fix when pole is required for province without cells
This commit is contained in:
parent
4c4caa6ff7
commit
4560c5d05d
2 changed files with 5 additions and 5 deletions
|
|
@ -316,7 +316,7 @@ function highlightEmblemElement(type, el) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const [x, y] = el.pole;
|
const [x, y] = el.pole || pack.cells.p[el.center];
|
||||||
const obj = type === "state" ? cells.state : cells.province;
|
const obj = type === "state" ? cells.state : cells.province;
|
||||||
const borderCells = cells.i.filter(id => obj[id] === i && cells.c[id].some(n => obj[n] !== i));
|
const borderCells = cells.i.filter(id => obj[id] === i && cells.c[id].some(n => obj[n] !== i));
|
||||||
const data = Array.from(borderCells).filter((c, i) => !(i%2)).map(i => cells.p[i]).map(i => [i[0], i[1], Math.hypot(i[0]-x, i[1]-y)]);
|
const data = Array.from(borderCells).filter((c, i) => !(i%2)).map(i => cells.p[i]).map(i => [i[0], i[1], Math.hypot(i[0]-x, i[1]-y)]);
|
||||||
|
|
|
||||||
|
|
@ -891,7 +891,7 @@ function drawProvinces() {
|
||||||
|
|
||||||
const labels = provs.append("g").attr("id", "provinceLabels");
|
const labels = provs.append("g").attr("id", "provinceLabels");
|
||||||
labels.style("display", `${labelsOn ? "block" : "none"}`);
|
labels.style("display", `${labelsOn ? "block" : "none"}`);
|
||||||
const labelData = provinces.filter(p => p.i && !p.removed);
|
const labelData = provinces.filter(p => p.i && !p.removed && p.pole);
|
||||||
labels.selectAll(".path").data(labelData).enter().append("text")
|
labels.selectAll(".path").data(labelData).enter().append("text")
|
||||||
.attr("x", d => d.pole[0]).attr("y", d => d.pole[1])
|
.attr("x", d => d.pole[0]).attr("y", d => d.pole[1])
|
||||||
.attr("id", d => "provinceLabel"+d.i).text(d => d.name);
|
.attr("id", d => "provinceLabel"+d.i).text(d => d.name);
|
||||||
|
|
@ -923,7 +923,7 @@ function getProvincesVertices() {
|
||||||
gap[p] += "M" + vertices.p[chain[0][0]] + chain.reduce((r,v,i,d) => !i ? r : !v[2] ? r + "L" + vertices.p[v[0]] : d[i+1] && !d[i+1][2] ? r + "M" + vertices.p[v[0]] : r, "");
|
gap[p] += "M" + vertices.p[chain[0][0]] + chain.reduce((r,v,i,d) => !i ? r : !v[2] ? r + "L" + vertices.p[v[0]] : d[i+1] && !d[i+1][2] ? r + "M" + vertices.p[v[0]] : r, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// find state visual center
|
// find province visual center
|
||||||
vArray.forEach((ar, i) => {
|
vArray.forEach((ar, i) => {
|
||||||
const sorted = ar.sort((a, b) => b.length - a.length); // sort by points number
|
const sorted = ar.sort((a, b) => b.length - a.length); // sort by points number
|
||||||
provinces[i].pole = polylabel(sorted, 1.0); // pole of inaccessibility
|
provinces[i].pole = polylabel(sorted, 1.0); // pole of inaccessibility
|
||||||
|
|
@ -1279,13 +1279,13 @@ function drawEmblems() {
|
||||||
const sizeProvinces = getProvinceEmblemsSize();
|
const sizeProvinces = getProvinceEmblemsSize();
|
||||||
const provinceCOAs = validProvinces.map(province => {
|
const provinceCOAs = validProvinces.map(province => {
|
||||||
if (!province.pole) getProvincesVertices();
|
if (!province.pole) getProvincesVertices();
|
||||||
const [x, y] = province.pole;
|
const [x, y] = province.pole || pack.cells.p[province.center];
|
||||||
return {type: "province", i: province.i, x, y, size: sizeProvinces};
|
return {type: "province", i: province.i, x, y, size: sizeProvinces};
|
||||||
});
|
});
|
||||||
|
|
||||||
const sizeStates = getStateEmblemsSize();
|
const sizeStates = getStateEmblemsSize();
|
||||||
const stateCOAs = validStates.map(state => {
|
const stateCOAs = validStates.map(state => {
|
||||||
const [x, y] = state.pole;
|
const [x, y] = state.pole || pack.cells.p[state.center];
|
||||||
return {type: "state", i: state.i, x, y, size: sizeStates};
|
return {type: "state", i: state.i, x, y, size: sizeStates};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue