What does a Voronoi diagram have to do with a flow network? Some years ago I was...
Simon Tatham @simontatham@hachyderm.io
What does a Voronoi diagram have to do with a flow network?
Some years ago I was trying to make 3D-printable models of Britain for a friend. (Both the whole of Great Britain as a single model, and also zooming in to model individual mountains.) Our source material was the Ordnance Survey OpenData, which provides 10m contour lines plus an outline for the coast itself.
The data was in the form of XML files, each covering a 10km × 10km square of the OS national grid, describing segments of whichever outlines intersect that square, each as a sequence of (x,y) points. (No clear specification of how the points are supposed to be connected; for simplicity I just assumed a straight line between each pair of points.)
The coast outline, unfortunately, was not a closed curve. Partly that was because the segments in adjacent grid-square files didn't always match up exactly – apparently nobody had checked the endpoints of line segments were consistent across grid-square boundaries. But also, I think they'd deliberately decided not to bother with rivers: the coast outline would just stop, on one side of a river mouth, and resume on the other. That saved them having to decide how much of the river itself to include, but also left a gap in the outline.
I needed a properly closed loop, in order to determine what was inside it and what was outside it. So I had to close all those gaps. But the data was too huge and detailed to go round the coast by hand with Inkscape or the like. It'd have taken forever. It had to be automated.
So, the problem: given a _mostly_ complete outline of a polygon, fill in the gaps, in some way that looks minimal, such as 'smallest total length of the line segments you add'.
The idea I hit on was to combine two algorithms I already knew about, but hadn't ever considered using together.
(1/5)