feat: render states - separate pole detection from layer render

This commit is contained in:
Azgaar 2024-09-02 03:23:05 +02:00
parent 093014088c
commit c66e6e4645
5 changed files with 45 additions and 24 deletions

View file

@ -991,18 +991,14 @@ function drawStates() {
TIME && console.time("drawStates");
const {cells, states} = pack;
const renderHalo = shapeRendering.value === "geometricPrecision";
const paths = getVertexPaths({
getType: cellId => cells.state[cellId],
options: {fill: true, waterGap: true, halo: renderHalo}
});
const maxLength = states.length - 1;
const bodyPaths = new Array(maxLength);
const clipPaths = new Array(maxLength);
const haloPaths = new Array(maxLength);
for (const [index, {fill, waterGap, halo}] of paths) {
const renderHalo = shapeRendering.value === "geometricPrecision";
const isolines = getIsolines(cellId => cells.state[cellId], {fill: true, waterGap: true, halo: renderHalo});
for (const [index, {fill, waterGap, halo}] of isolines) {
const color = states[index].color;
bodyPaths.push(
@ -1022,11 +1018,6 @@ function drawStates() {
byId("statePaths").innerHTML = renderHalo ? clipPaths.join("") : "";
byId("statesHalo").innerHTML = renderHalo ? haloPaths.join("") : "";
// vArray.forEach((ar, i) => {
// const sorted = ar.sort((a, b) => b.length - a.length); // sort by points number
// states[i].pole = polylabel(sorted, 1.0); // pole of inaccessibility
// });
TIME && console.timeEnd("drawStates");
}

View file

@ -152,6 +152,7 @@ function regenerateStates() {
pack.states = newStates;
BurgsAndStates.expandStates();
BurgsAndStates.normalizeStates();
BurgsAndStates.getPoles();
BurgsAndStates.collectStatistics();
BurgsAndStates.assignColors();
BurgsAndStates.generateCampaigns();