GeoCorrelator

class sitchlib.GeoCorrelator(device_id)[source]

Geographic correlator.

correlate(scan_bolus)[source]

Correlate one geo event.

The first time we get a geo event, we set the state and print a message
to stdout to that effect. Every subsequent message is compared against the geo_anchor. Once the anchor is set, it does not change for the life of the instance. Correlation of subsequent events causes the distance beween the anchor and current event to be determined and if the threshold of 10km is exceeded, an alert is returned.
Parameters:scan_bolus (tuple) – Two-item tuple. Position 0 contains the scan type, which is not checked. We should only ever have geo events coming through this method. Position 1 is expected to contain geo json.
Returns:
List of alerts. If no alerts are fired, the list returned is
zero-length.
Return type:list
classmethod geo_drift_check(geo_anchor, gps_scan, threshold, device_id)[source]

Fire alarm if distance between points exceeds threshold.

Parameters:
  • geo_anchor (dict) – Geographic anchor point, usually stored in an instance variable and passed in via the correlate() method.
  • gps_scan (dict) – Same format as geo_anchor, expects the same format as geo_anchor.
  • threshold (int) – Alerting threshold in km.
Returns:

list of alerts (usually just one) or an empty list of there

are no alerts.

Return type:

list

classmethod time_drift_check(gps_scan, threshold_mins, device_id)[source]

Checks drift value, alarms if beyond threshold.