It has a pretty serious flaw in that it "communicates" nearness. If the snapping distance is 1.1, with points a, b, c at 0, 1, 2; it will contract all of them into a single centroid at 1.
Instead, it should contract points (a, b) together and leave c alone, or leave a alone and contract (b, c).
Once that's done, it can be exposed in the public API as well.
I wrote
snap_nodes
a while ago: https://github.com/Deltares/xugrid/blob/63a58022401c10f087bf780c0d4502534779625c/xugrid/ugrid/snapping.py#L41Thinking it would come in handy.
It has a pretty serious flaw in that it "communicates" nearness. If the snapping distance is 1.1, with points a, b, c at 0, 1, 2; it will contract all of them into a single centroid at 1. Instead, it should contract points (a, b) together and leave c alone, or leave a alone and contract (b, c).
Once that's done, it can be exposed in the public API as well.