fleetmap-reports 1.0.412 → 1.0.413

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.412",
3
+ "version": "1.0.413",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,12 +1,13 @@
1
- const turf = require('turf')
1
+ const turf = require('@turf/helpers')
2
+ const inside = require('@turf/boolean-point-in-polygon')
2
3
 
3
- exports.insideGeofence = function insideGeofence(position, geofence) {
4
- const coords = geofence.area.slice(9, geofence.area.length-2).split(',')
5
- const coords2 = coords.map(c => {
6
- return c.trim().split(' ').map(a => parseFloat(a))
7
- })
8
- var pt = turf.point([parseFloat(position.latitude), parseFloat(position.longitude)]);
9
- var poly = turf.polygon([coords2]);
4
+ exports.insideGeofence = function insideGeofence (position, geofence) {
5
+ const coords = geofence.area.slice(9, geofence.area.length - 2).split(',')
6
+ const coords2 = coords.map(c => {
7
+ return c.trim().split(' ').map(a => parseFloat(a))
8
+ })
9
+ const pt = turf.point([parseFloat(position.latitude), parseFloat(position.longitude)])
10
+ const poly = turf.polygon([coords2])
10
11
 
11
- return turf.inside(pt, poly)
12
+ return inside.default(pt, poly)
12
13
  }
@@ -53,26 +53,24 @@ async function createZoneReport (from, to, userData, traccar) {
53
53
  xpert: devices.filter(d => d.attributes.xpert).length > 0
54
54
  }
55
55
 
56
- const sliced = automaticReports.sliceArray(devices, 30)
56
+ const sliced = automaticReports.sliceArray(devices, 20)
57
57
 
58
- const deviceCount = { count: 0 }
59
- const promises = []
58
+ let deviceCount = 0
60
59
  for (const slice of sliced) {
61
- promises.push(traccarHelper.getAllInOne(
60
+ const allInOne = await traccarHelper.getAllInOne(
62
61
  traccar, from, to, slice, true, false, false, false,
63
- deviceCount, devices.length, 20, 5, deviceCount).then(async allInOne => {
64
- const routeData = allInOne.route
62
+ deviceCount, devices.length, 20, 5)
63
+ const routeData = allInOne.route
65
64
 
66
- const data = getInAndOutEvents(slice, routeData, userData)
65
+ const data = getInAndOutEvents(slice, routeData, userData)
67
66
 
68
- console.log('Geofence Enter/Exit Alerts:' + data.length)
67
+ console.log('Geofence Enter/Exit Alerts:' + data.length)
69
68
 
70
- if (data.length) {
71
- allData.devices.push(...await processDevices(from, to, devices, userData.drivers, userData.geofences, data, traccar))
72
- }
73
- }))
69
+ if (data.length) {
70
+ allData.devices.push(...await processDevices(from, to, devices, userData.drivers, userData.geofences, data, traccar))
71
+ }
72
+ deviceCount = deviceCount + slice.length
74
73
  }
75
- await Promise.all(promises)
76
74
 
77
75
  reportData.push(allData)
78
76