Skip to content

Commit 1e52f60

Browse files
bbestclaude
andcommitted
fix(h3t): render H3 hexagons crossing the antimeridian
H3 cells straddling ±180° rendered as a jagged tear/gap: h3-js `h3ToGeoBoundary()` returns their vertices split between +179 and -179, so the polygon spans ~358° of longitude and geojson-vt mis-tiles it. Two parts, in the bundled `h3j-h3t` cell builders (addH3TSource / addH3JSource / setH3JData): 1. fixTransmeridian (Nick Rabinowitz, https://observablehq.com/@nrabinowitz/mapbox-utils): a boundary ring with any arc > 180° lon has its negative-lon vertices shifted +360°, so it stays continuous near +180° instead of wrapping the globe. Complete for the non-tiled add_h3j_source / setH3JData. 2. For the tiled add_h3t_source, a crossing cell is fetched into more than one {z}/{x}/{y} tile; each cell is normalized by ±360° onto the side of the antimeridian the rendered tile sits on, so its halves draw in the correct tiles and meet seamlessly. Pairs with an antimeridian-aware tile filter on the h3t server that returns a crossing cell to both edge tiles. No extra libraries; non-crossing cells are untouched. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 07eaee0 commit 1e52f60

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
*
1313
* New `add_h3t_source()` adds a tiled H3 (h3t) source for MapLibre maps, fetching only the H3 cells in the current viewport from a `{z}/{x}/{y}` tile endpoint via the `h3tiles://` protocol — a scalable alternative to `add_h3j_source()` for large datasets. Works with multiple sources per map and on both sides of `compare()`. Bundled `h3j-h3t` library updated to 0.9.7 (#199, thanks to @bbest).
1414

15+
* Fixed H3 hexagons that cross the antimeridian (±180°) rendering as a jagged tear/gap for `add_h3t_source()`, `add_h3j_source()`, and `setH3JData()`. The bundled `h3j-h3t` cell-to-polygon builder now applies Nick Rabinowitz's [`fixTransmeridian`](https://observablehq.com/@nrabinowitz/mapbox-utils#fixTransmeridian) to each cell boundary — a ring with any arc spanning > 180° of longitude has its negative-longitude vertices shifted by +360° so it stays continuous instead of wrapping the globe. For the **tiled** `add_h3t_source()`, where a crossing cell is fetched into more than one `{z}/{x}/{y}` tile, each cell is additionally normalized (by ±360°) onto the side of the antimeridian that the tile being rendered is on, so its two halves are drawn in the correct tiles and meet seamlessly (this pairs with an antimeridian-aware tile filter on the h3t server that returns a crossing cell to both edge tiles).
16+
1517
* Update MapLibre GL JS to v5.24.0 and Mapbox GL JS to v3.24.0.
1618

1719
* Fixed `add_legend()` silently ignoring the `target` argument for MapLibre compare widgets: the compare dispatch checked for class `"maplibre_compare"` while the widget class is `"maplibregl_compare"`, so legends were attached as regular map legends instead of compare-level legends.

inst/htmlwidgets/lib/h3j-h3t/h3j_h3t.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)