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 +1 -1
- package/src/util/geofence.js +10 -9
- package/src/zone-report.js +11 -13
package/package.json
CHANGED
package/src/util/geofence.js
CHANGED
|
@@ -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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
12
|
+
return inside.default(pt, poly)
|
|
12
13
|
}
|
package/src/zone-report.js
CHANGED
|
@@ -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,
|
|
56
|
+
const sliced = automaticReports.sliceArray(devices, 20)
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
const promises = []
|
|
58
|
+
let deviceCount = 0
|
|
60
59
|
for (const slice of sliced) {
|
|
61
|
-
|
|
60
|
+
const allInOne = await traccarHelper.getAllInOne(
|
|
62
61
|
traccar, from, to, slice, true, false, false, false,
|
|
63
|
-
deviceCount, devices.length, 20, 5
|
|
64
|
-
|
|
62
|
+
deviceCount, devices.length, 20, 5)
|
|
63
|
+
const routeData = allInOne.route
|
|
65
64
|
|
|
66
|
-
|
|
65
|
+
const data = getInAndOutEvents(slice, routeData, userData)
|
|
67
66
|
|
|
68
|
-
|
|
67
|
+
console.log('Geofence Enter/Exit Alerts:' + data.length)
|
|
69
68
|
|
|
70
|
-
|
|
71
|
-
|
|
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
|
|