fleetmap-reports 2.0.228 → 2.0.230

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": "2.0.228",
3
+ "version": "2.0.230",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/util/utils.js CHANGED
@@ -296,8 +296,8 @@ exports.convertToFeature = convertToFeature
296
296
  exports.convertPositionToFeature = convertPositionToFeature
297
297
  exports.calculateDistance = (positions, ignoreOdometer) => {
298
298
  let distanceValue = 0
299
- if (!ignoreOdometer && positions.length > 1 && positions[0].attributes.odometer && positions[positions.length - 1].attributes.odometer) {
300
- distanceValue = (positions[positions.length - 1].attributes.odometer - positions[0].attributes.odometer) / 1000
299
+ if (!ignoreOdometer && positions.length > 1 && positions[0].attributes?.odometer && positions[positions.length - 1].attributes?.odometer) {
300
+ distanceValue = (positions[positions.length - 1].attributes?.odometer - positions[0].attributes?.odometer) / 1000
301
301
  }
302
302
 
303
303
  if (distanceValue > 0) {
@@ -504,10 +504,10 @@ function analyseAlerts (alerts, deviceRoute, userData, from, to, device) {
504
504
  async function getInAndOutEvents (devices, route, userData) {
505
505
  const events = []
506
506
  const geofencesFeatures = userData.geofences.map(g => convertToFeature(g))
507
- console.log('getInAndOutEvents', devices.length)
508
507
  devices.forEach(d => {
509
508
  const deviceRoute = route.filter(p => p.deviceId === d.id)
510
509
  const routePoints = deviceRoute.sort(sortPositions).map(p => convertPositionToFeature(p))
510
+ console.log('getInAndOutEvents', d.id, deviceRoute.length, routePoints.length)
511
511
  routePoints.filter(p => p.properties.position.valid).forEach((p, i, array) => {
512
512
  p.inside = {}
513
513
  if (!i) {