Geofencing

Geofencing / Electronic Fence

Definition

Geofencing (Geofence/Electronic Fence) sets virtual geographic boundaries (circular or polygonal). When a device enters or exits the fence through GPS/Beidou positioning, it triggers an alert. It is used for vehicle, asset, and personnel location tracking and boundary monitoring, supporting entry and exit statistics.

Technical Implementation

Fence shapes can be circular (center point + radius) or polygonal (sequence of vertex coordinates). Devices obtain latitude and longitude via GNSS, GPS, Beidou, and the platform or edge logic determines the spatial relationship between the point and the fence (ray casting, ray projection, etc.). Trigger types include: enter, exit, enter and dwell, exit timeout, etc. Positioning accuracy and reporting frequency affect trigger timeliness; a hysteresis zone can be set to avoid false alarms due to boundary jitter.

Use Cases

Vehicle management: set operation areas and restricted zones, boundary alerts; logistics: warehouse and delivery point fences, entry and exit statistics; personnel: construction site and park electronic fences, attendance and safety; assets: limit activity range for valuable equipment; shared bicycles: electronic fence parking management. Combined with RTLS indoor positioning, it can form integrated indoor and outdoor fences. IoT platforms often provide capabilities for fence configuration, trigger rules, and alert notifications.

Deciding whether a point is inside a polygon

A fence is a set of geographic coordinates plus a decision rule. A circle is a center and a radius. A polygon is vertices closed in order. The test only answers whether the current point is inside or outside. Enter, leave, and dwell timeout are a state machine on top of several tests in a row. If two fixes in a row jump across the whole boundary, looking only at the current point misses "it went out and came back." The report interval and the maximum allowed speed have to say whether that piece of track is credible. The radius and the vertices must use the same datum as the fix. Mixing two datums shifts the whole fence somewhere else, while the terminal's own fix may be stable.

The condition is a fix that carries a quality indication. Enough satellites with poor geometry make the point drift along the street. Indoors, underground, and inside a metal box there is often no valid fix. Hold the last reliable state, or mark it unknown. Do not treat an invalid coordinate of zero as a real position near the equator or the origin. A circle suits a coarse range around a site. An irregular plant, a river, or a road that must not be entered needs a polygon. Vertex order has to be consistent. A self-crossing polygon makes the same area both inside and outside.

Position jitter and a hysteresis band

Ordinary jitter on the boundary fires enter and leave again and again in a short time. A hysteresis band leaves a layer inside the boundary and a layer outside, and the state changes only when the point crosses that layer. The enter threshold and the leave threshold cannot be the same line. Another mistake is to use the time the platform received the message instead of the time of the fix. An old point sent late is treated as a crossing that just happened. If reports are very sparse, a device can enter the fence and leave again between two reports, and the platform never sees it. That is not an algorithm written backwards. The sampling does not meet the application.

A circle's radius is in metres, while vertices are in degrees. Using a fraction of a degree directly as the radius draws a meaningless ring. When a person draws a polygon on a map, and the map is already shifted while the device output is not, convert first and then save the vertices. A change in altitude or floor is invisible to a flat fence. An interchange and a basement need a height condition or an indoor fix as well. An alarm should carry direction, fix time, and fix quality. "Out of bounds" alone cannot be reviewed. After vertices are edited, recompute the state of terminals already inside the fence with the new boundary. Otherwise the state waits for the next crossing, and dwell statistics in between are still the old boundary.

Late points and the unknown state

A fix sent late carries the time of the fix. The platform replays the track on that time. Do not use the receive time to fire the fence. If a string of old points is judged in arrival order, yesterday's crossing is reported as now. An invalid fix should keep the last reliable state and be marked unknown. Do not feed a zero coordinate into the polygon test. A zero coordinate often falls in the Gulf of Guinea and looks like an international jump.

Set the enter condition and the leave condition of the hysteresis band separately, and make the band wider than the terminal's normal jitter on the boundary. If the report interval is longer than the dwell the application cares about, the fence will not see an entry in between. Write that into the rule. Do not make the algorithm more sensitive to compensate. A flat polygon is not enough for an interchange or a basement. Height or an indoor fix is an extra condition. After vertices change, recompute terminals already in the area against the new boundary at once, or dwell time keeps accumulating on the old shape. An alarm record should keep direction, fix time, and quality, so a replay can tell jitter from a real crossing.

Order polygon vertices in one direction and close the ring. If the closing edge is missing, a ray test flips at random near the boundary. Split a self-crossing shape into pieces that do not cross, or the same place is inside and then outside. A circle's radius is in metres, and its center uses the same datum as the fix. Do not put a fraction of longitude or latitude into the radius. While a terminal sits on the edge, several fixes in a row inside the hysteresis band should not toggle. If speed is high enough that one report jumps the whole area, test the segment from the previous point against the boundary. Looking only at the current point misses the crossing. Drop intervals with no indoor fix from enter and dwell statistics. They are neither a stay nor a leave. Version the rule when it changes. An old alarm still points at the vertices of that time, or the review no longer matches the shape.

Related Terms

Return to hardware knowledge base