fix: clip by bbox

This commit is contained in:
Azgaar 2022-07-07 02:09:13 +03:00
parent 392cc24f7c
commit 9bd90e51d9
6 changed files with 7 additions and 19 deletions

View file

@ -37,10 +37,7 @@ export function drawCoastline() {
let vchain = connectVertices(start, type);
if (features[f].type === "lake") relax(vchain, 1.2);
used[f] = 1;
let points = clipPoly(
vchain.map(v => vertices.p[v]),
1
);
let points = clipPoly(vchain.map(v => vertices.p[v]));
const area = d3.polygonArea(points); // area with lakes/islands
if (area > 0 && features[f].type === "lake") {
points = points.reverse();

View file

@ -34,10 +34,7 @@ window.OceanLayers = (function () {
const relax = 1 + t * -2; // select only n-th point
const relaxed = chain.filter((v, i) => !(i % relax) || vertices.c[v].some(c => c >= pointsN));
if (relaxed.length < 4) continue;
const points = clipPoly(
relaxed.map(v => vertices.p[v]),
1
);
const points = clipPoly(relaxed.map(v => vertices.p[v]));
chains.push([t, points]);
}

View file

@ -90,10 +90,7 @@ export function editCoastline(node = d3.event.target) {
function redrawCoastline() {
const f = +elSelected.attr("data-f");
const vertices = pack.features[f].vertices;
const points = clipPoly(
vertices.map(v => pack.vertices.p[v]),
1
);
const points = clipPoly(vertices.map(v => pack.vertices.p[v]));
const d = round(lineGen(points));
elSelected.attr("d", d);
defs.select("mask#land > path#land_" + f).attr("d", d); // update land mask