Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@mapbox/polylabel
Advanced tools
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:
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.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);
TypeScript type definitions
are available via npm install --save @types/polylabel
.
It is recommended to install polylabel via mason. You will also need to install its dependencies: geometry.hpp and variant.
#include <mapbox/polylabel.hpp>
int main() {
mapbox::geometry::polygon<double> polygon = readPolygon(); // Get polygon data from somewhere.
mapbox::geometry::point<double> p = mapbox::polylabel(polygon, 1.0);
return 0;
}
FAQs
A JS library for finding optimal label position inside a polygon
The npm package @mapbox/polylabel receives a total of 0 weekly downloads. As such, @mapbox/polylabel popularity was classified as not popular.
We found that @mapbox/polylabel demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.