What is Point-in-polygon?

Point-in-polygon is the geometric test that decides whether a coordinate falls inside a shape — the core calculation behind every geofence check.

Every geofence check comes down to one question: is this coordinate inside this shape? The point-in-polygon test answers it, and it runs on every position report from every device, forever.

How ray casting works

The standard algorithm is beautifully simple. Draw an imaginary ray from the point out to infinity in any direction, and count how many times it crosses the polygon’s edges.

The intuition: every time you cross an edge you move from outside to inside or back again. Starting from infinity, which is definitely outside, an odd number of transitions leaves you inside.

It works for any simple polygon — convex, concave, or awkwardly shaped — and handles holes naturally, because a hole’s ring contributes its own crossings. The cost is proportional to the number of edges.

Circles are much cheaper

For a circular zone there is no polygon to walk. The test is one distance calculation:

inside = distance(point, centre) <= radius

That is why circular geofences are the cheapest kind to evaluate, and why almost every tracking platform supports them even when it supports nothing else. If your zone is genuinely “within X metres of this address”, use a circle — see GeoJSON polygon for when a polygon earns its cost.

Vertex count matters at scale

The per-check cost is small. Multiply it by every position report from every device and it stops being negligible.

A 500-vertex shape costs roughly twenty-five times more to test than a 20-vertex one. With a device reporting every five minutes, that difference is invisible. With thousands of devices reporting continuously across many zones, it is the difference between comfortable and struggling.

The practical guidance: trace the shape you need and stop. Extra vertices add no accuracy that GPS drift has not already erased. Once your vertex spacing drops below the position error of the devices being tested, you are encoding measurement noise into the boundary and paying for it on every check. Twelve well-placed points beat two hundred.

Edge cases

Real implementations have to decide some genuinely ambiguous situations:

In practice these matter far less than they sound, because a coordinate landing exactly on an edge is vanishingly unlikely with real GPS data — the position error is many orders of magnitude larger than the floating-point ambiguity.

What Geoblip does

Geoblip evaluates every incoming coordinate against each zone assigned to that device, supporting both circular zones — a centre and a radius — and arbitrary polygons including holes.

The important design point is what happens after the test. A raw inside/outside answer is not enough to alert on, because GPS drift makes that answer flip for a stationary device near a boundary. The geometric result updates the device’s physical position, but notifications are driven by a separate state machine described under alert debouncing.

Getting the geometry right is the easy half. Deciding what to do with the answer is the half that determines whether anyone trusts the alerts.

Last reviewed 7 August 2026.

Related terms

GeoJSON polygon

A GeoJSON polygon is the standard way to describe an area on a map as a list of coordinates, defined by RFC 7946 and understood by nearly every mapping tool.

Geofencing

Geofencing is the practice of drawing a virtual boundary around a real-world place and having software react when a tracked device crosses it.

GPS accuracy

GPS accuracy is how close a reported position is to the true location, usually expressed as a radius within which the real position probably falls.

Alert debouncing

Alert debouncing is the practice of suppressing repeat notifications for a condition that is already active, so a single real event produces a single alert.

Browse the full glossary →

Put it into practice

Draw a zone, assign a phone or GPS tracker, and get a blip the moment it crosses the line. Free for 7 days.

Start free trial → Try the geofence builder