* feat(region-routing): P1 tagging + region_routes primitive + read/write API + preview launcher - config.py: add Coverage.region_tagging (bool=False); add RegionRouteMatrix dataclass (enabled, cells) above NotificationsConfig; add region_routes field to NotificationsConfig; add explicit hydration branch for region_routes in _dict_to_dataclass mirroring destinations pattern. - coverage_area.py: add MonitoringArea.name (str|None=None, frozen); update areas_from_config to preserve name; refactor inline geom extraction from classify_event_areas into shared _event_geom_json helper; add matching_area_names(geom_json, areas)->list[str] (additive, all named matches, config-order, deduped; gate unchanged); add event_region_names convenience wrapper. - coverage_filter.py: add region_tagging ctor kwarg; stamp event.region/ regions before the gate when region_tagging=True and areas non-empty and not event.regions (never clobbers satpass preset). - pipeline/__init__.py: wire region_tagging into CoverageFilter construction. - notification_routes.py: add GET /notifications/regions (named coverage area names, config-order, deduped); GET /notifications/region-routing (matrix as JSON); POST /notifications/region-routing (explicit RMW — only region_routes changes, toggles/rules/destinations survive). - scripts/preview_dashboard.py: mesh-free launcher — dashboard API only, no mesh connector, no broadcast loop; vite runs separately. All 87 coverage tests pass; 300 total pass; 6 pre-existing failures unchanged (adapter config count mismatch + MeshCore EventType.NEW_CONTACT). * feat(region-routing): manual region x family matrix editor page Adds RegionRoutingMatrix.tsx — a plain editor over the region_routes config primitive. Rows = families (via useFamilies()), cols = regions (from GET /api/notifications/regions). Each cell exposes MT channel (ChannelPicker single + includeDisabled), MC channel name (text input), min_severity select (routine/priority/critical/immediate), and an enabled checkbox. Only cells where MT or MC is set are included in the sparse POST payload. Master enable toggle maps to top-level enabled. MT budget guard warns when more than 7 distinct MT indices are in use. Sticky family column; horizontal scroll for wide region sets. Registers route /region-routing in App.tsx and adds "Region Routing" nav entry (Map icon) under the Meshtastic section in Layout.tsx, immediately after Routing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(region-routing): regions endpoint reads saved (disk) coverage so routing columns are dynamic without a bot restart; preview reloads config after writes * feat(routing): unify MT/MC routing into per-family cards; region routing as an in-card expand; remove rules/destinations UI + standalone page * refactor(routing): move Meshtastic Routing from /notifications to /meshtastic/routing (mirror /meshcore/routing); redirect legacy path * feat(region-routing): dispatcher honors region_routes matrix (authoritative-on-match, per-region cooldown, per-channel dedup); non-matrix path unchanged Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(region-routing): matrix dedup key must match boot-restore 2-tuple form (prevents restart re-broadcast flood); regression test --------- Co-authored-by: Matt Johnson <mj@k7zvx.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| delaunator.js | ||
| delaunator.min.js | ||
| index.d.ts | ||
| index.js | ||
| LICENSE | ||
| package.json | ||
| README.md | ||
Delaunator

An incredibly fast and robust JavaScript library for Delaunay triangulation of 2D points.
Projects based on Delaunator
- d3-delaunay for Voronoi diagrams, search, traversal and rendering (a part of D3).
- d3-geo-voronoi for Delaunay triangulations and Voronoi diagrams on a sphere (e.g. for geographic locations).
Example
const coords = [377,479, 453,434, 326,387, 444,359, 511,389,
586,429, 470,315, 622,493, 627,367, 570,314];
const delaunay = new Delaunator(coords);
console.log(delaunay.triangles);
// [4,3,1, 4,6,3, 1,5,4, 4,9,6, 2,0,1, 1,7,5,
// 5,9,4, 6,2,3, 3,2,1, 5,8,9, 0,7,1, 5,7,8]
Install
Install with NPM (npm install delaunator) or Yarn (yarn add delaunator), then import as an ES module:
import Delaunator from 'delaunator';
To use as a module in a browser:
<script type="module">
import Delaunator from 'https://cdn.skypack.dev/delaunator@5.0.0';
</script>
Or use a browser UMD build that exposes a Delaunator global variable:
<script src="https://unpkg.com/delaunator@5.0.0/delaunator.min.js"></script>
API Reference
new Delaunator(coords)
Constructs a delaunay triangulation object given an array of point coordinates of the form:
[x0, y0, x1, y1, ...] (use a typed array for best performance).
Delaunator.from(points[, getX, getY])
Constructs a delaunay triangulation object given an array of points ([x, y] by default).
getX and getY are optional functions of the form (point) => value for custom point formats.
Duplicate points are skipped.
delaunay.triangles
A Uint32Array array of triangle vertex indices (each group of three numbers forms a triangle).
All triangles are directed counterclockwise.
To get the coordinates of all triangles when using Delaunator.from(points), use:
for (let i = 0; i < triangles.length; i += 3) {
coordinates.push([
points[triangles[i]],
points[triangles[i + 1]],
points[triangles[i + 2]]
]);
}
To get the coordinates of all triangles when using new Delaunator(coords), use:
for (let i = 0; i < triangles.length; i += 3) {
coordinates.push([
[coords[2 * triangles[i]], coords[2 * triangles[i] + 1]],
[coords[2 * triangles[i + 1]], coords[2 * triangles[i + 1] + 1]],
[coords[2 * triangles[i + 2]], coords[2 * triangles[i + 2] + 1]]
]);
}
delaunay.halfedges
A Int32Array array of triangle half-edge indices that allows you to traverse the triangulation.
i-th half-edge in the array corresponds to vertex triangles[i] the half-edge is coming from.
halfedges[i] is the index of a twin half-edge in an adjacent triangle
(or -1 for outer half-edges on the convex hull).
The flat array-based data structures might be counterintuitive, but they're one of the key reasons this library is fast.
delaunay.hull
A Uint32Array array of indices that reference points on the convex hull of the input data, counter-clockwise.
delaunay.coords
An array of input coordinates in the form [x0, y0, x1, y1, ....],
of the type provided in the constructor (or Float64Array if you used Delaunator.from).
delaunay.update()
Updates the triangulation if you modified delaunay.coords values in place, avoiding expensive memory allocations.
Useful for iterative relaxation algorithms such as Lloyd's.
Performance
Benchmark results against other Delaunay JS libraries
(npm run bench on Macbook Pro Retina 15" 2017, Node v10.10.0):
| uniform 100k | gauss 100k | grid 100k | degen 100k | uniform 1 million | gauss 1 million | grid 1 million | degen 1 million | |
|---|---|---|---|---|---|---|---|---|
| delaunator | 82ms | 61ms | 66ms | 25ms | 1.07s | 950ms | 830ms | 278ms |
| faster‑delaunay | 473ms | 411ms | 272ms | 68ms | 4.27s | 4.62s | 4.3s | 810ms |
| incremental‑delaunay | 547ms | 505ms | 172ms | 528ms | 5.9s | 6.08s | 2.11s | 6.09s |
| d3‑voronoi | 972ms | 909ms | 358ms | 720ms | 15.04s | 13.86s | 5.55s | 11.13s |
| delaunay‑fast | 3.8s | 4s | 12.57s | timeout | 132s | 138s | 399s | timeout |
| delaunay | 4.85s | 5.73s | 15.05s | timeout | 156s | 178s | 326s | timeout |
| delaunay‑triangulate | 2.24s | 2.04s | OOM | 1.51s | OOM | OOM | OOM | OOM |
| cdt2d | 45s | 51s | 118s | 17s | timeout | timeout | timeout | timeout |
Papers
The algorithm is based on ideas from the following papers:
- A simple sweep-line Delaunay triangulation algorithm, 2013, Liu Yonghe, Feng Jinming and Shao Yuehong
- S-hull: a fast radial sweep-hull routine for Delaunay triangulation, 2010, David Sinclair
- A faster circle-sweep Delaunay triangulation algorithm, 2011, Ahmad Biniaz and Gholamhossein Dastghaibyfard
Robustness
Delaunator should produce valid output even on highly degenerate input. It does so by depending on robust-predicates, a modern port of Jonathan Shewchuk's robust geometric predicates, an industry standard in computational geometry.
Ports to other languages
- delaunator-rs (Rust)
- fogleman/delaunay (Go)
- delaunator-cpp (C++)
- delaunator-sharp (C#)
- delaunator-ruby (Ruby)
- Delaunator-Python (Python)
- torch-delaunay (Python/Torch)
- ricardomatias/delaunator (Kotlin)
- delaunator-java (Java)
- delaunay-Stata (Stata/Mata)
- Delaunator.jl (Julia)