fleetmap-reports 1.0.863 → 1.0.864

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.863",
3
+ "version": "1.0.864",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -345,18 +345,17 @@ async function getOSMSpeedingEvents (devices, routes, threshold, minimumMinutes
345
345
  matched_points.forEach((mp, mIndex) => {
346
346
  const edge = edges[mp.edge_index]
347
347
  const position = route[mIndex + i]
348
- if (edge && edge.speed_limit < position.speed * 1.852) {
348
+ if (edge && (edge.speed_limit + (threshold || 0)) < position.speed * 1.852) {
349
349
  results.push({ ...mp, ...edge, ...position })
350
350
  }
351
351
  })
352
352
  }
353
353
  const reduced = results.reduce((acc, cur, idx, src) => {
354
- cur.overSpeeding = cur.speed * 1.852 > cur.speed_limit + (threshold || 0)
355
354
  const last = acc.length && acc.slice(-1)[0]
356
- if (cur.overSpeeding && last && src[idx - 1].overSpeeding && last.speed_limit === cur.speed_limit) {
355
+ if (last && new Date(cur.fixTime) - new Date(src[idx - 1]) < 1000 * 60 * 2) {
357
356
  last.eventTime = new Date(cur.fixTime) - new Date(last.fixTime)
358
357
  last.attributes.maxSpeed = Math.max(last.attributes.maxSpeed, cur.speed)
359
- last.distance = distance.default(point([cur.longitude, cur.latitude]), point([last.longitude, last.latitude]))
358
+ last.distance += distance.default(point([cur.longitude, cur.latitude]), point([src[idx - 1].longitude, src[idx - 1].latitude]))
360
359
  } else if (cur.overSpeeding) {
361
360
  cur.positionId = cur && cur.id
362
361
  cur.roadSpeedLimit = cur.speed_limit