
Security News
Potemkin Understanding in LLMs: New Study Reveals Flaws in AI Benchmarks
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
The polylabel npm package is used to find the pole of inaccessibility of a polygon, which is the most distant internal point from the polygon's edges. This is useful for placing labels on polygons in a way that maximizes readability and avoids overlap with the edges.
Finding the pole of inaccessibility
This feature allows you to find the pole of inaccessibility for a given polygon. The code sample demonstrates how to use the polylabel function to find the optimal label position within a square polygon.
const polylabel = require('polylabel');
const polygon = [[[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]];
const precision = 1.0;
const labelPosition = polylabel(polygon, precision);
console.log(labelPosition); // Outputs: [5, 5]
Turf is a powerful geospatial analysis library for JavaScript. It provides a wide range of spatial operations, including finding the centroid of a polygon, which can be used for label placement. However, Turf does not specifically focus on finding the pole of inaccessibility like polylabel does.
D3-geo is a module of the D3.js library that provides geographic projections and related utilities. It can be used to calculate the centroid of a polygon, which is useful for label placement. Unlike polylabel, d3-geo does not specifically target the pole of inaccessibility.
A fast algorithm for finding polygon pole of inaccessibility, the most distant internal point from the polygon outline (not to be confused with centroid), implemented as a JavaScript library. Useful for optimal placement of a text label on a polygon.
It's an iterative grid algorithm, inspired by paper by Garcia-Castellanos & Lombardo, 2007. Unlike the one in the paper, this algorithm:
Given polygon coordinates in
GeoJSON-like format
and precision (1.0
by default),
Polylabel returns the pole of inaccessibility coordinate in [x, y]
format.
var p = polylabel(polygon, 1.0);
This is an iterative grid-based algorithm, which starts by covering the polygon with big square cells and then iteratively splitting them in the order of the most promising ones, while aggressively pruning uninteresting cells.
cell_size * sqrt(2) / 2
).cell_max - best_dist > precision
),
split it into 4 children cells and put them in the queue.TypeScript type definitions
are available via npm install --save @types/polylabel
.
FAQs
A JS library for finding optimal label position inside a polygon
The npm package polylabel receives a total of 222,137 weekly downloads. As such, polylabel popularity was classified as popular.
We found that polylabel demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.