polylabel
1.0.1, released 5 years ago by beroso.dev
Fast algorithm to find a polygon's pole of inaccessibility for optimal label placement
WASM-readySingle maintainer
What it does
Polylabel computes the point inside a polygon that is farthest from its edges, returning that point and its distance. It is useful for placing text labels or markers centrally within irregular shapes.
AI-written summary of version 1.0.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to place a label or marker at the most central point of a polygon
- You want a fast, pure Dart implementation without external dependencies
Skip it when
- You need a full GIS library or advanced spatial queries
- You require integration with Flutter widgets or UI components
Strengths
- Pure Dart, no native code or platform-specific dependencies
- Fast and lightweight algorithm
- Simple API with unit tests
Weaknesses
- Only supports 2D polygons, no 3D or complex geometry support
- No built-in Flutter widget integration
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
import 'package:polylabel/polylabel.dart';
final polygon = [[Point(0, 0), Point(1, 0), Point(1, 1), Point(0, 1), Point(0, 0)]];
final result = polylabel(polygon); // PolylabelResult(Point(0.5, 0.5), distance: 0.5)Alternatives
Packages that do the same job and could replace polylabel.
- algorithmic
A collection of searching, sorting, and string metric algorithms.
45Compare