Cry Wolf — a circle-vs-polygon geofencing sandbox
A geofencing sandbox

CRY WOLF

Circle geofences fire arrival events from the freeway. Polygon fences fire at the property line. Run a truck past a distribution center and read the event log — the circle cries wolf, the polygon stays quiet.

1 · pick a route 2 · press run 3 · read the log  ·  between runs: drag the green corners or the amber radius

SEC. 12 — HARRIS CO. (FICTIONAL PLAT) PELICAN PACKAGING CO. WAREHOUSE 4 GULFGATE DISTRIBUTION CENTER GATE EAST LOOP FWY — WB ← · → EB SERVICE ROAD 100 m N ↑
SIM 11:47:00 AM
fences are editable between runs
polygon fence circle fence property line (truth) ping outside circle only in polygon
Route
Speed
Fences
Radius 320 m

Under the hood

Polygon test — ray casting

Cast a ray from the truck's GPS ping to the edge of the map and count how many fence edges it crosses. odd = inside, even = outside. It's O(n) per ping and works for any shape — including boundaries with notches, easements, and a neighbor's driveway carved out. Flip on "show the math" and watch the crossings while the truck moves.

Circle test — one distance check

Measure the ping's distance to the fence center and compare it to the radius: d < r = inside. On a real globe that distance comes from the haversine formula on lat/lon; this sandbox projects everything onto a flat local plane in meters first — which is exactly what production geofence engines do before testing millions of pings.

Why anyone cares

A fence that fires from the freeway inflates dwell time, corrupts detention data, and buries dispatchers in alerts they learn to ignore. Shrinking the radius doesn't fix it — it just trades false arrivals for missed ones (try the slider). The fix is a boundary that follows the property line. And a hand-drawn polygon is only as good as the hand that drew it — drag a green corner into the freeway and watch it start lying too.

Scale: 1 unit = 1 meter on a local planar projection anchored at 29.7215° N, 95.2810° W (Houston's East End — the plat is fictional). Exports convert back to WGS-84 lat/lon. No libraries, no map tiles: one HTML file and math from scratch.