Skip to content

Instantly share code, notes, and snippets.

@nmandery
nmandery / gnus-interference.rs
Created August 5, 2022 19:33 — forked from wiseman/gnus-interference.rs
Fix trans-antimeridian polygons
/// Fix geojson polygons that span the antimeridian and have arcs > 180
/// degrees. This is a workaround for a bug in the underlying H3 library:
/// <https://github.com/uber/h3/issues/561>
///
/// This code is based on nrabinowitz's code in
/// <https://observablehq.com/@nrabinowitz/mapbox-utils>
pub fn fix_trans_meridian_coordinate(coord: &mut geo_types::Coordinate<f64>) {
if coord.x < 0.0 {
coord.x += 360.0;