This is an O(n) algorithm that provides information about wether or not a group of GPS coordinates are contained within a user defined Geo-Fence.
Object within Geo-Fence(left). Object not within Geo-Fence(right)
To define a geo-fence two pieces of information must be given.
1) The relative position of the center of the geo-boundary. Expressed as GPS coordinates.
2) The radius of the geo-fence expressed in meters. If this value is not provided a default value of 150 meters will be assumed.
The algorithm will detect if the GPS positions given are within the defined radius of the geo-fence.
A single call to this algorithm checks a batch size of up to 1,000 GPS markers. In the event that more than 1,000 of these markers are provided, only the first 1,000 will be processed, the rest will be returned as a list of unprocessed objects.
Processed objects will convey six types of information.
1) A boolean indicating wether or not the processed object is within the geo-boundary.
2) Distance from the center of the geo-fence to the processed object; Expressed in meters
4) The smallest distance from the geo-fence center to the processed object; Expressed in meters
5) The original lat, lon information.
6) An error margin, expressed in meters. This margin details distance computation errors that may accrue for larger distances.