I am struggling with my first attempt at some track functions --
https://developers.arcgis.com/arcade/function-reference/track_functions/
Specifically, I want to look at the last 10 transactions in the Track (the last five minutes of activity) and determine the distance traveled between the starting and ending transactions in the window. So I wrote two arcade expressions to populate two new fields in the output schema.
First I get the TrackWindow looking back -10 to current 0.
Then get the number of reports for the Track.
If we get less than Ten return -9999 for downstream logic.
If we got ten then return the TrackSpeedAt(0) over Window, or Return the TrackDistanceAt[10] over the Window. But I am not at all sure that/how these functions know I am looking at the 10 Tracks from the TrackWindow command.
However, the arcade debugger does not seem to be much help, and debugging this downstream, I never seem to get anything other than the -9999.
Any ideas, explanations for something I am missing, or corrections to my logic would be appreciated.
// Get the last ten reports, 5 minuites worth, assuming 2 per minuite
var tracks = TrackWindow(-10, 0);
// Count the number of elements in the array
var numFeatures = count(tracks);
// if the number of features < 10 retun Not Idle.numFeatures
// TrackSpeed is in meters per second.
if (numFeatures < 10 ) {
return(-9999)
} else {
return(TrackSpeedAt(0));
}
The other is
// Get the last ten reports, 5 minuites worth, assuming 2 per minuite
var tracks = TrackWindow(-10, 0);
// Count the number of elements in the array
var numFeatures = count(tracks);
// Get the distance traveled over the last ten reports, Meters
var distanceWindow = TrackDistanceWindow(-10, 0);
// if the number of features < 10 retun Not Idle.numFeatures
// TrackDistance in meters second.
if (numFeatures < 10 ) {
return(-9999)
} else {
return(distanceWindow[10]);
}