diff --git a/package-lock.json b/package-lock.json
index e942cb93..661694af 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,7 +9,6 @@
"version": "1.113.5",
"license": "MIT",
"dependencies": {
- "@types/lineclip": "^2.0.0",
"alea": "^1.0.1",
"d3": "^7.9.0",
"delaunator": "^5.0.1",
@@ -21,6 +20,7 @@
"@playwright/test": "^1.57.0",
"@types/d3": "^7.4.3",
"@types/delaunator": "^5.0.3",
+ "@types/lineclip": "^2.0.0",
"@types/node": "^25.0.10",
"@types/polylabel": "^1.1.3",
"@vitest/browser": "^4.0.18",
@@ -1353,6 +1353,7 @@
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@types/lineclip/-/lineclip-2.0.0.tgz",
"integrity": "sha512-LsPRWfV5kC41YgraYhnAMNSNhdJwFlCsUPueSw7sG5UvMqSMxMcaOA9LWN8mZiCUe9jVIAKnLfsNiXpvnd7gKQ==",
+ "dev": true,
"license": "MIT"
},
"node_modules/@types/node": {
diff --git a/package.json b/package.json
index 0c00978a..269a8db2 100644
--- a/package.json
+++ b/package.json
@@ -28,6 +28,7 @@
"@playwright/test": "^1.57.0",
"@types/d3": "^7.4.3",
"@types/delaunator": "^5.0.3",
+ "@types/lineclip": "^2.0.0",
"@types/node": "^25.0.10",
"@types/polylabel": "^1.1.3",
"@vitest/browser": "^4.0.18",
@@ -38,7 +39,6 @@
"vitest": "^4.0.18"
},
"dependencies": {
- "@types/lineclip": "^2.0.0",
"alea": "^1.0.1",
"d3": "^7.9.0",
"delaunator": "^5.0.1",
diff --git a/src/modules/cultures-generator.ts b/src/modules/cultures-generator.ts
index 91f4690d..e90b7d61 100644
--- a/src/modules/cultures-generator.ts
+++ b/src/modules/cultures-generator.ts
@@ -1304,7 +1304,7 @@ class CulturesModule {
cells.culture[cellId] = 0;
}
} else {
- cells.culture = new Uint16Array(cells.i.length) as unknown as number[];
+ cells.culture = new Uint16Array(cells.i.length);
}
for (const culture of cultures) {
diff --git a/src/modules/features.ts b/src/modules/features.ts
index 06984af6..6a948c31 100644
--- a/src/modules/features.ts
+++ b/src/modules/features.ts
@@ -234,6 +234,8 @@ class FeatureModule {
const [startCell, featureVertices] = getCellsData(type, firstCell);
const points = clipPoly(
featureVertices.map((vertex: number) => vertices.p[vertex]),
+ graphWidth,
+ graphHeight,
);
const area = polygonArea(points); // feature perimiter area
const absArea = Math.abs(rn(area));
diff --git a/src/modules/resample.ts b/src/modules/resample.ts
index a588423e..a5e31c0f 100644
--- a/src/modules/resample.ts
+++ b/src/modules/resample.ts
@@ -59,14 +59,12 @@ class Resampler {
grid.cells.temp = new Int8Array(grid.points.length);
grid.cells.prec = new Uint8Array(grid.points.length);
- const parentPackQ = quadtree(parentMap.pack.cells.p.map(([x, y], i) => [x, y, i]));
+ const parentPackQ = quadtree(
+ parentMap.pack.cells.p.map(([x, y], i) => [x, y, i]),
+ );
grid.points.forEach(([x, y]: [number, number], newGridCell: number) => {
const [parentX, parentY] = inverse(x, y);
- const parentPackCell = parentPackQ.find(
- parentX,
- parentY,
- Infinity,
- )?.[2];
+ const parentPackCell = parentPackQ.find(parentX, parentY, Infinity)?.[2];
if (parentPackCell === undefined) return;
const parentGridCell = parentMap.pack.cells.g[parentPackCell];
@@ -441,16 +439,14 @@ class Resampler {
parentMap: ParentMapDefinition,
inverse: (x: number, y: number) => [number, number],
) {
- const parentPackQ = quadtree(parentMap.pack.cells.p.map(([x, y], i) => [x, y, i]));
+ const parentPackQ = quadtree(
+ parentMap.pack.cells.p.map(([x, y], i) => [x, y, i]),
+ );
pack.features.forEach((feature) => {
if (!feature) return;
const [x, y] = pack.cells.p[feature.firstCell];
const [parentX, parentY] = inverse(x, y);
- const parentCell = parentPackQ.find(
- parentX,
- parentY,
- Infinity,
- )?.[2];
+ const parentCell = parentPackQ.find(parentX, parentY, Infinity)?.[2];
if (parentCell === undefined) return;
const parentFeature =
parentMap.pack.features[parentMap.pack.cells.f[parentCell]];
diff --git a/src/renderers/draw-features.ts b/src/renderers/draw-features.ts
index 5a6801d8..dbbb079c 100644
--- a/src/renderers/draw-features.ts
+++ b/src/renderers/draw-features.ts
@@ -92,7 +92,7 @@ function featurePathRenderer(feature: PackedGraphFeature): string {
}
const simplifiedPoints = simplify(points, 0.3);
- const clippedPoints = clipPoly(simplifiedPoints, graphWidth, graphHeight, 1);
+ const clippedPoints = clipPoly(simplifiedPoints, graphWidth, graphHeight);
const lineGen = line().curve(curveBasisClosed);
const path = `${round(lineGen(clippedPoints) || "")}Z`;
diff --git a/src/renderers/draw-state-labels.ts b/src/renderers/draw-state-labels.ts
index 24528d45..78a5b878 100644
--- a/src/renderers/draw-state-labels.ts
+++ b/src/renderers/draw-state-labels.ts
@@ -1,4 +1,5 @@
import { curveNatural, line, max, select } from "d3";
+import type { TypedArray } from "../types/PackedGraph";
import {
drawPath,
drawPoint,
@@ -400,7 +401,7 @@ const stateLabelsRenderer = (list?: number[]): void => {
angleRad: number,
halfwidth: number,
halfheight: number,
- stateIds: number[],
+ stateIds: TypedArray,
stateId: number,
): boolean {
const bbox = textElement.getBBox();
diff --git a/src/types/PackedGraph.ts b/src/types/PackedGraph.ts
index de02b708..df84be86 100644
--- a/src/types/PackedGraph.ts
+++ b/src/types/PackedGraph.ts
@@ -8,7 +8,7 @@ import type { Route } from "../modules/routes-generator";
import type { State } from "../modules/states-generator";
import type { Zone } from "../modules/zones-generator";
-type TypedArray =
+export type TypedArray =
| Uint8Array
| Uint16Array
| Uint32Array
diff --git a/src/utils/commonUtils.ts b/src/utils/commonUtils.ts
index 651c2a79..2da6d8d9 100644
--- a/src/utils/commonUtils.ts
+++ b/src/utils/commonUtils.ts
@@ -9,7 +9,6 @@ import { rand } from "./probabilityUtils";
* @param points - Array of points [[x1, y1], [x2, y2], ...]
* @param graphWidth - Width of the graph
* @param graphHeight - Height of the graph
- * @param secure - Secure clipping to avoid edge artifacts
* @returns Clipped polygon points
*/
export const clipPoly = (
diff --git a/src/utils/index.ts b/src/utils/index.ts
index cd5581f8..75a62a13 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -228,8 +228,8 @@ import {
wiki,
} from "./commonUtils";
-window.clipPoly = (points: [number, number][], secure?: number) =>
- clipPoly(points, graphWidth, graphHeight, secure);
+window.clipPoly = (points: [number, number][]) =>
+ clipPoly(points, graphWidth, graphHeight);
window.getSegmentId = getSegmentId;
window.debounce = debounce;
window.throttle = throttle;
diff --git a/tests/e2e/layers.spec.ts-snapshots/ocean.html b/tests/e2e/layers.spec.ts-snapshots/ocean.html
index b950e1a7..83139b5f 100644
--- a/tests/e2e/layers.spec.ts-snapshots/ocean.html
+++ b/tests/e2e/layers.spec.ts-snapshots/ocean.html
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file