Class Geofence
Keeps a tracked point inside an area, and notices when it leaves.
public sealed class Geofence : IDisposable
- Inheritance
-
Geofence
- Implements
- Inherited Members
Examples
using var pen = new Geofence(new Coordinate(-1.2921, 36.8219), 50.0);
pen.Update(new Coordinate(-1.2921, 36.8219)); // Boundary.Inside
pen.Update(new Coordinate(-1.2930, 36.8219)); // Boundary.Exited
Remarks
A fence is a centre and a radius. Feeding it successive fixes reports whether each is inside or outside and, crucially, the single fix that crossed, so an alert fires once on the crossing rather than on every fix while away.
Constructors
Geofence(Coordinate, double)
Creates a circular fence around a centre fix.
public Geofence(Coordinate center, double radiusM)
Parameters
centerCoordinateThe centre of the fence.
radiusMdoubleThe fence radius, in metres.
Exceptions
- PamojaException
The native fence could not be created.
Methods
Contains(Coordinate)
Reports whether a fix lies inside, without recording a crossing.
public bool Contains(Coordinate point)
Parameters
pointCoordinateThe fix to test.
Returns
- bool
trueif the fix is inside the fence.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Update(Coordinate)
Feeds a fix in and reports where it sits, including a crossing.
public Boundary Update(Coordinate point)
Parameters
pointCoordinateThe latest fix.
Returns
- Boundary
The boundary state for this fix.