fleetmap-reports 1.0.495 → 1.0.496
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/here.js +0 -1
- package/src/speeding-report.js +7 -1
package/package.json
CHANGED
package/src/here.js
CHANGED
|
@@ -96,7 +96,6 @@ function fillGeocoding(rows) {
|
|
|
96
96
|
} */
|
|
97
97
|
|
|
98
98
|
exports.routeMatch = async (rows) => {
|
|
99
|
-
console.log('here sending', rows.length)
|
|
100
99
|
const csv = generateCSV(rows)
|
|
101
100
|
const response = await axios.post(calcRoute, csv, { headers: { 'Content-Type': 'application/binary' } })
|
|
102
101
|
const hereData = response.data
|
package/src/speeding-report.js
CHANGED
|
@@ -307,12 +307,18 @@ async function getHereEvents (devices, routes, threshold) {
|
|
|
307
307
|
console.log('no positions on device', d.name)
|
|
308
308
|
resolve()
|
|
309
309
|
}
|
|
310
|
+
console.log(d.name, 'sending', positions.length, 'to here')
|
|
310
311
|
here.routeMatch(positions).then(results => {
|
|
311
312
|
console.log(d.name, 'got', results.length, 'from here')
|
|
313
|
+
const timestamps = []
|
|
314
|
+
for (const p of positions) {
|
|
315
|
+
timestamps[new Date(p.fixTime).getTime()] = p
|
|
316
|
+
}
|
|
312
317
|
const reduced = results.reduce((acc, cur, idx, src) => {
|
|
318
|
+
console.log('idx', idx)
|
|
313
319
|
cur.overSpeeding = cur.currentSpeedKmh > parseInt(cur.speedLimit) + (threshold || 0)
|
|
314
320
|
const last = acc.length && acc.slice(-1)[0]
|
|
315
|
-
cur.position =
|
|
321
|
+
cur.position = timestamps[cur.timestamp]
|
|
316
322
|
if (cur.overSpeeding && last && src[idx - 1].overSpeeding && last.speedLimit === cur.speedLimit) {
|
|
317
323
|
last.eventTime = cur.timestamp - last.timestamp
|
|
318
324
|
last.attributes.maxSpeed = Math.max(last.attributes.maxSpeed, cur.position.speed)
|