fix: rename feature path functions and update global declarations (#1303)
Some checks are pending
Deploy static content to Pages / deploy (push) Waiting to run
Code quality / quality (push) Waiting to run

* fix: rename feature path functions and update global declarations

* chore: lint
This commit is contained in:
Marc Emmanuel 2026-02-03 16:59:08 +01:00 committed by GitHub
parent b73557d624
commit 86fc62da03
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View file

@ -9,6 +9,7 @@ declare global {
tolerance: number,
highestQuality?: boolean,
) => [number, number][];
var getFeaturePath: (feature: PackedGraphFeature) => string;
}
interface FeaturesHtml {
@ -34,7 +35,7 @@ const featuresRenderer = (): void => {
if (!feature || feature.type === "ocean") continue;
html.paths.push(
`<path d="${getFeaturePath(feature)}" id="feature_${feature.i}" data-f="${feature.i}"></path>`,
`<path d="${featurePathRenderer(feature)}" id="feature_${feature.i}" data-f="${feature.i}"></path>`,
);
if (feature.type === "lake") {
@ -81,7 +82,7 @@ const featuresRenderer = (): void => {
TIME && console.timeEnd("drawFeatures");
};
function getFeaturePath(feature: PackedGraphFeature): string {
function featurePathRenderer(feature: PackedGraphFeature): string {
const points: [number, number][] = feature.vertices.map(
(vertex: number) => pack.vertices.p[vertex],
);
@ -100,3 +101,4 @@ function getFeaturePath(feature: PackedGraphFeature): string {
}
window.drawFeatures = featuresRenderer;
window.getFeaturePath = featurePathRenderer;

View file

@ -17,6 +17,7 @@ interface Marker {
declare global {
var drawMarkers: () => void;
var drawMarker: (marker: Marker, rescale?: number) => string;
}
type PinShapeFunction = (fill: string, stroke: string) => string;
@ -56,7 +57,7 @@ const getPin = (shape = "bubble", fill = "#fff", stroke = "#000"): string => {
return shapeFunction(fill, stroke);
};
function drawMarker(marker: Marker, rescale = 1): string {
function markerRenderer(marker: Marker, rescale = 1): string {
const {
i,
icon,
@ -94,10 +95,11 @@ const markersRenderer = (): void => {
const markersData: Marker[] = pinned
? pack.markers.filter((m: Marker) => m.pinned)
: pack.markers;
const html = markersData.map((marker) => drawMarker(marker, rescale));
const html = markersData.map((marker) => markerRenderer(marker, rescale));
markers.html(html.join(""));
TIME && console.timeEnd("drawMarkers");
};
window.drawMarkers = markersRenderer;
window.drawMarker = markerRenderer;