
Geofencing Explained
for Telematics
Geofencing spans trackers, gateways, and backends for school buses, cash vans, yards, and long-haul fleets. This guide is the engineering view of what a geofence actually is, where the accuracy comes from, and why naive implementations flood operators with false entry and exit alerts. It covers geometry, GNSS error, hysteresis, dwell, and scaling to thousands of fences.
THE BASICS
What a Geofence Actually Is
A geofence is a virtual boundary defined in geographic coordinates, paired with a rule that fires when a tracked asset crosses it. The asset reports a position (latitude, longitude, and usually a timestamp and accuracy estimate), and somewhere in the system a point-in-polygon or point-in-circle test decides whether that position is inside or outside the boundary. When the inside or outside state changes between two consecutive evaluations, the system generates an entry or exit event. That event is what an operator sees as an alert, what a report counts as a stop, and what an automation uses to trigger a downstream action.
The concept sounds trivial, and the happy-path code is a few lines. The difficulty is everywhere else: the position is never exact, the asset is moving, the boundary may be drawn loosely, and the evaluation may happen on a microcontroller with kilobytes of RAM or on a server processing millions of points per minute. A geofencing feature that works in a demo with one vehicle and one square around an office routinely falls apart in production with 4,000 vehicles, 12,000 fences, and drivers parked exactly on a boundary line. The geometry, the device firmware, and the backend that make geofencing usable at that scale are covered by geofencing solutions for telematics platforms.
Throughout this guide the word "asset" means whatever is being tracked: a vehicle, a trailer, a container, a person, or a piece of equipment. The geometry and the error handling are the same regardless of what is moving. What changes between use cases is the tolerance for false alerts, the required latency, and whether the evaluation has to happen on the device or can wait for the server.
GEOMETRY
Circular, Polygon, and Corridor Fences
The simplest geofence is a circle: a center point and a radius in meters. The inside test is a single distance calculation. Because latitude and longitude are angular, plain Euclidean distance cannot be used without distortion, so the great-circle distance is computed with the haversine formula, or for small radii the position is projected to a local tangent plane with a flat-earth approximation, which is accurate to within centimeters for fences under a few kilometers and far cheaper to compute. Circular fences are ideal for points of interest: a depot, a customer site, a fuel station, a school stop. They cost almost nothing to store and evaluate, which matters when a device holds hundreds of them.
Polygon fences are an ordered list of vertices forming a closed ring. The inside test is the ray-casting or winding-number algorithm: count how many times a ray from the point crosses the polygon edges, and an odd count means the point is inside. Polygons handle real shapes that circles cannot, such as an irregular yard, a city ward boundary, a port, or a restricted no-go zone that follows a coastline. The cost is proportional to the vertex count, so a 200-vertex municipal boundary is much heavier to evaluate than a four-vertex yard. On constrained devices, polygons are simplified with the Douglas-Peucker algorithm before loading, trading a meter or two of boundary precision for a large reduction in compute and memory.
Corridor fences (also called route fences) are a polyline with a width: the centerline of a planned route plus a tolerance band on each side. The inside test is the perpendicular distance from the point to the nearest segment of the polyline. Corridors answer a different question than area fences. Instead of "is the asset here," they ask "is the asset still on its assigned route," which is the foundation of route-deviation detection. A cash van that leaves its planned corridor, or a school bus that diverges from its route, generates an exit event the instant its distance to the centerline exceeds the band. Corridor fences feature heavily in cash van and valuables tracking deployments where any unexpected deviation is a security signal that must reach the control room within seconds.
WHERE EVALUATION HAPPENS
On-Device vs Server-Side Evaluation
A geofence can be evaluated on the tracker firmware or in the backend after the position arrives. The choice is not cosmetic. It changes latency, bandwidth, battery, and how many fences can be supported. On-device evaluation means the firmware holds a copy of the relevant fences, runs the inside test locally every time it gets a GNSS fix, and only transmits when an entry or exit event occurs. This cuts uplink traffic dramatically, since a parked vehicle inside a fence sends nothing instead of a position every 10 seconds, and it produces near-instant alerts because the device does not wait for a server round trip. The cost is firmware complexity, limited fence capacity (memory bounds how many polygons you can hold), and the operational burden of pushing fence definitions to devices over the air.
Server-side evaluation keeps the device dumb. The tracker streams every position, and the backend runs all fence tests centrally. This supports an unlimited number of fences, lets operators draw and edit fences that take effect immediately with no firmware push, and centralizes the logic so a bug fix deploys once. The tradeoffs are higher uplink volume (the device transmits whether or not anything happened), added latency from the network and processing pipeline, and a backend that must index fences spatially to stay fast. Most production platforms are hybrid: time-critical and security fences (panic zones, route corridors for valuables) run on-device for speed and offline resilience, while the long tail of informational fences runs server-side. The ingestion and evaluation pipeline that makes the server side scale is part of fleet management platform engineering, and the rule-to-alert routing is handled by the alerts and notification engine.
ACCURACY LIMITS
GNSS Accuracy, HDOP, and Why the Dot Wanders
Every geofence decision rests on a position that is uncertain. A consumer-grade GNSS receiver in open sky reports a horizontal position accurate to roughly 2 to 5 meters CEP, but that number degrades quickly. In an urban canyon, signals reflect off buildings and arrive late, producing multipath errors that can shift the reported position by tens of meters. Under heavy tree cover, in tunnels, or in a steel warehouse, the fix may drift much further or drop out entirely. The receiver does not always know it is wrong, which is why a stationary vehicle parked near a fence boundary can appear to cross in and out repeatedly as the reported dot wanders across the line.
HDOP (Horizontal Dilution of Precision) is the single most useful quality signal the receiver gives you. It describes the geometric strength of the satellites currently in view: when satellites are spread evenly across the sky, HDOP is low (good) and the position estimate is tight; when satellites are clustered or few in number, HDOP is high (bad) and the same measurement error translates into a much larger position error. HDOP serves as a gate. A position with HDOP above a threshold (commonly 4 or 5, tuned per deployment) is too uncertain to trust for a boundary decision and is either discarded or flagged. Choosing a receiver and antenna that hold a strong fix in difficult environments is its own engineering problem, addressed in telematics and GPS tracking systems.
The practical consequence is that a geofence boundary is fuzzy by an amount equal to the position error, and good design accounts for that fuzz rather than pretending the dot is exact. A fence radius should never be smaller than the expected position error, because a 10-meter circle around a 5-meter-accurate device will trigger on noise alone. The error budget, not the map, sets the minimum useful fence size.
STOPPING FALSE ALERTS
Hysteresis, Debounce, and Dwell Time
The naive geofence flips state on every fix, so a vehicle sitting on a boundary while the GNSS dot jitters produces a stream of entry and exit alerts, sometimes dozens per minute. This is the single most common reason operators lose trust in a tracking platform, and it is entirely solvable with three techniques. The first is hysteresis: define two boundaries instead of one. The asset is counted as inside only after it crosses an inner radius, and counted as outside only after it crosses a larger outer radius. The gap between the two (often 15 to 50 meters depending on the accuracy budget) means a wandering dot has to make a real, decisive move to flip the state, and small jitter never crosses both thresholds.
The second technique is debounce, applied in time rather than space. A candidate state change is held pending until it persists across several consecutive fixes, or for a minimum duration, before it is confirmed as a real event. A single anomalous fix inside a fence is ignored; three in a row at a vehicle speed consistent with actually entering are accepted. The third technique is dwell time, which is both a noise filter and a feature in its own right. Dwell requires the asset to remain inside a fence for a configured minimum (say 3 minutes) before the entry is treated as significant. This converts a meaningless drive-through into a meaningful stop, and it is exactly what distinguishes a bus that paused at a stop to board students from one that merely drove past it.
These three controls interact, and tuning them is where deployment experience pays off. Tight hysteresis with short debounce gives fast alerts but more false positives; loose hysteresis with long dwell gives clean reports but delayed signals. There is no universal setting. A panic zone wants the fastest possible trigger, while a payroll-relevant site-arrival report wants the cleanest possible dwell-confirmed event. Tuning these per fence class rather than globally is one of the reasons a generic off-the-shelf geofence rarely satisfies a serious operator.
RULES ON TOP OF GEOMETRY
Route Deviation, Speed-by-Zone, and Time Windows
Once the geometry and noise handling are solid, the interesting value comes from the rules layered on top. Route deviation uses a corridor fence: the system holds the planned polyline, measures the perpendicular distance from each position to the nearest segment, and raises an alert when the asset leaves the band or skips an expected waypoint in the wrong order. This catches a driver taking an unauthorized detour, a delivery running off-plan, and a valuables van being diverted, all without anyone watching the map. Tuning the band width against the position-error budget is the same discipline as sizing a circular fence.
Speed-by-zone attaches a speed limit to a fence, so the rule is conditional on location. A vehicle is permitted 60 km/h on the open road but flagged above 20 km/h inside a yard, a school zone, or a residential corridor. The evaluation combines the inside test with the reported ground speed (from the GNSS Doppler velocity, which is more reliable than position-derived speed) and fires only when both conditions hold. Time-window rules add a schedule: a fence can be armed only outside business hours, so a vehicle entering a depot at 2 a.m. triggers an alert while the same entry at 2 p.m. does not. Stacking geometry, speed, and time turns a flat boundary into a contextual policy, and routing those policy events to the right person is the job of the notification and escalation engine.
AT SCALE
Scaling to Thousands of Fences and Vehicles
Testing every position against every fence is an O(positions x fences) problem, and it stops being viable the moment you have a few thousand of each. A platform that checks 5,000 vehicles reporting every 10 seconds against 12,000 fences with a naive loop is doing 6 million point-in-polygon tests per second, most of them wasted on fences nowhere near the vehicle. The fix is spatial indexing. Fences are indexed in an R-tree or a geohash grid so that, for any incoming position, the backend first retrieves only the handful of candidate fences whose bounding boxes contain the point, then runs the exact inside test on that short list. This turns the problem from quadratic to roughly logarithmic in the fence count and is the difference between a platform that scales and one that falls over.
On the device side, the constraint is memory rather than CPU. A tracker cannot hold 12,000 polygons, so only the fences relevant to that asset's assigned routes and operating region are pushed, refreshing them over the air as assignments change. Both sides also need clean state management: the current inside-or-outside status of every asset-fence pair has to be stored and survive reboots, otherwise the system re-fires entry events after every restart. Building this indexing, state store, and over-the-air fence distribution correctly is core platform work, and it is part of fleet management solutions and the mapping and routing foundations they sit on.
IN THE FIELD
Real Use Cases in the Field
School transport is one of the most demanding geofencing applications because parents and schools depend on the events being correct. Each stop is a circular fence with dwell, so arrival is confirmed only when the bus actually pauses, and the route is a corridor so any deviation flags immediately. Clean stop events feed the parent app and the school dashboard, and the speed-by-zone rule keeps drivers in check near schools. This combination is the backbone of a school bus and student tracking system.
Cash and valuables transport inverts the priority: here the corridor and the panic zones matter more than informational stops, and latency has to be in seconds. Route corridors and time-armed depot fences run on-device so an alert fires even if the cellular link drops mid-route, a pattern central to cash van and valuables tracking. Yard and depot management uses polygon fences to count assets in and out, measure dwell as detention time, and trigger gate workflows. Across all of these, the engineering is the same set of primitives described above, tuned to the tolerance the use case demands.
FAQ
Frequently Asked Questions
What is the difference between a circular, polygon, and corridor geofence?
A circular fence is a center point and a radius, evaluated with a single distance test, and is best for points of interest. A polygon fence is a closed ring of vertices that handles irregular real-world shapes like yards and boundaries. A corridor fence is a route polyline with a width band, used to detect when an asset leaves its planned route rather than whether it is inside an area.
Why does my geofence trigger false entry and exit alerts?
Almost always because the asset is parked near the boundary while the GNSS position jitters across the line. The fixes are hysteresis (separate inner and outer thresholds so a real, decisive move is needed to change state), debounce (require several consecutive fixes before confirming an event), and dwell time (require the asset to stay inside for a minimum duration). Discarding fixes with high HDOP also helps.
What is HDOP and why does it matter for geofencing?
HDOP, or Horizontal Dilution of Precision, describes how favorable the current satellite geometry is. Low HDOP means satellites are well spread and the position is tight; high HDOP means the same measurement noise produces a much larger position error. Geofence decisions are gated on HDOP, discarding or flagging positions above a threshold because they are too uncertain to trust for a boundary crossing.
Should geofences run on the device or on the server?
On-device evaluation gives near-instant alerts, works when the network drops, and cuts uplink traffic, but it is limited by device memory and needs over-the-air fence updates. Server-side evaluation supports unlimited fences and instant edits but adds latency and uplink volume. Most production platforms are hybrid: time-critical and security fences run on-device, and the long tail of informational fences runs server-side.
How many geofences can a system realistically handle?
On a server with spatial indexing (an R-tree or geohash grid), tens of thousands of fences and thousands of vehicles are routine, because each incoming position is tested only against the few nearby candidate fences rather than all of them. On the device, the limit is memory, typically a few hundred fences, so only the fences relevant to that asset are pushed to it.
What is dwell time and how is it used?
Dwell time is the minimum duration an asset must remain inside a fence before the entry is treated as significant. It filters out drive-throughs and converts a raw boundary crossing into a meaningful stop. It is what distinguishes a bus that actually paused to board students from one that merely passed the stop, and it is used widely in arrival reporting and detention-time measurement.
KEEP READING
Related pages
Solutions
Geofencing That Operators Actually Trust
From the firmware inside test to the spatially indexed backend, the full geofencing stack is covered: circular, polygon, and corridor fences, hysteresis and dwell tuning, route deviation, speed-by-zone, and over-the-air fence distribution to thousands of devices.
If your current platform floods you with false entry and exit alerts, or geofencing is being built from scratch, share your deployment details to see how it would be designed.
Schedule a Free Consultation