Command Palette

Search for a command to run...

Hectal
Phase 12: Big Data: Canvas, Hit-Testing and Performance
Data Visualization · Exercise 2 of 4 PreviousNext
Intermediate

The nearest station, with a reach

Build a quadtree of three stations and set window.nearest(x, y, reach).

It returns the name of the nearest station within reach, or null when there is none (too far, or a NaN position).

What Check tests

  1. Near Quay gives Quay
  2. Near Chapel gives Chapel
  3. Too far from every station gives null
  4. A NaN position gives null
  5. A huge reach still finds the nearest

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.