fleetmap-reports 2.0.333 → 2.0.335
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/sensor-report.js +18 -2
package/package.json
CHANGED
package/src/sensor-report.js
CHANGED
|
@@ -88,16 +88,32 @@ function computeSensorPeriods (positions, sensors, d, userData) {
|
|
|
88
88
|
const prevPos = positions[i - 1]
|
|
89
89
|
const currPos = positions[i]
|
|
90
90
|
const changeTime = new Date(currPos.fixTime)
|
|
91
|
+
const endTime = new Date(prevPos.fixTime)
|
|
91
92
|
|
|
92
93
|
for (const s of sensors) {
|
|
93
94
|
const key = s.sensor
|
|
94
95
|
const prevValue = current[key].value
|
|
95
96
|
const newValue = currPos.attributes[s.id]
|
|
96
97
|
|
|
98
|
+
const oldStartTime = current[key].startTime
|
|
99
|
+
const gap = changeTime - new Date(prevPos.fixTime)
|
|
100
|
+
if (prevValue === true && newValue === true && gap > maxDistanceBetweenPositions) {
|
|
101
|
+
const prevEndTime = new Date(prevPos.fixTime)
|
|
102
|
+
const duration = prevEndTime - oldStartTime
|
|
103
|
+
const threshold = minThreshold(true)
|
|
104
|
+
|
|
105
|
+
if (duration >= threshold) {
|
|
106
|
+
pushPeriod(key, s, true, oldStartTime, prevEndTime, prevPos)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
current[key] = { value: true, startTime: changeTime }
|
|
110
|
+
|
|
111
|
+
continue
|
|
112
|
+
}
|
|
113
|
+
|
|
97
114
|
if (prevValue === newValue) continue
|
|
98
115
|
|
|
99
|
-
const
|
|
100
|
-
const prevEndTime = changeTime
|
|
116
|
+
const prevEndTime = endTime
|
|
101
117
|
const duration = prevEndTime - oldStartTime
|
|
102
118
|
const threshold = minThreshold(prevValue)
|
|
103
119
|
let newPeriodStartTime = changeTime
|