Script 5 km gap without position updates
This guide shows how you can write a script that triggers if a vehicle/device travels more than 5 km without any updates in between. It would typically be used to get an indication that something is wrong with the device or the placement of the GPS antenna.
Test Setup
Tips when developing Script Expressions.
Create Event Rule
Create an Event Rule with a Script Expression like the one below:
Code: Select all
// Trigger event after 5000 meters without a new position. var limit = 5000; var trigger = false; // Condition if(trackPoint.valid) { var lastPos = context.state; if(lastPos != null && lastPos != "") { if (trackPoint.position.distance(lastPos.longitude, lastPos.latitude) > limit) { trigger = true; } } context.setState(trackPoint.position); } return trigger;