Proximity detection and the Voronoi geom
A Voronoi geom (found in the d3-voronoi
package) chops a geographic shape into discrete regions around points, such that no section overlaps and the entirety of the area is covered. Anything within a particular point's section is closer to that point than any other point. It's effectively another layout, but it's used more for utility than for display -- for instance, a grid of Voronoi regions is often used to increase the mouseover area of data in a chart so that your cursor will always be highlighting the nearest point. We will use the Voronoi geom to figure out what the closest major airport is to your current location, which we'll supply via the HTML5 Location API.
Replace the last line we wrote with the following:
async function renderView(ctx, next) { if (ctx.method === 'GET') { ctx.body = `<!doctype html> <html> <head> <title>Find your nearest airport!</title> </head> <body> <...