fleetmap-reports 1.0.404 → 1.0.405
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 +2 -2
- package/src/index.test.js +6 -5
- package/src/zone-report.js +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fleetmap-reports",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.405",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
+
"@turf/boolean-point-in-polygon": "^6.5.0",
|
|
13
14
|
"@turf/distance": "^6.5.0",
|
|
14
15
|
"@turf/helpers": "^6.5.0",
|
|
15
|
-
"@turf/point-on-feature": "^6.5.0",
|
|
16
16
|
"@turf/point-to-line-distance": "^6.5.0",
|
|
17
17
|
"axios": "^0.21.1",
|
|
18
18
|
"axios-cookiejar-support": "^1.0.1",
|
package/src/index.test.js
CHANGED
|
@@ -338,7 +338,8 @@ describe('Test_Reports', function () {
|
|
|
338
338
|
const device = data[0].devices.find(d => d.device.id === 25508)
|
|
339
339
|
assert.equal(device.days.length, 25)
|
|
340
340
|
}, 30000)
|
|
341
|
-
|
|
341
|
+
// eslint-disable-next-line no-undef
|
|
342
|
+
it('Zone Report', async () => {
|
|
342
343
|
const report = await getReports()
|
|
343
344
|
const userData = await report.getUserData()
|
|
344
345
|
const data = await report.zoneReport(new Date(2022, 3, 25, 0, 0, 0, 0),
|
|
@@ -347,10 +348,10 @@ describe('Test_Reports', function () {
|
|
|
347
348
|
|
|
348
349
|
assert.equal(data.length, 1)
|
|
349
350
|
const device = data[0].devices.find(d => d.device.id===22326)
|
|
350
|
-
assert.equal(device.geofences.length,
|
|
351
|
-
assert.equal(device.geofences[0].inTime.fixTime, '2022-04-25T23:
|
|
351
|
+
assert.equal(device.geofences.length, 19)
|
|
352
|
+
assert.equal(device.geofences[0].inTime.fixTime, '2022-04-25T23:47:58.000+0000')
|
|
352
353
|
assert.equal(device.geofences[0].outTime.fixTime, '2022-04-26T07:47:35.000+0000')
|
|
353
|
-
assert.equal(device.geofences[0].totalTime, '
|
|
354
|
+
assert.equal(device.geofences[0].totalTime, '28777')
|
|
354
355
|
assert.equal(device.geofences[0].geofenceName, 'Casa João')
|
|
355
|
-
}, 30000)
|
|
356
|
+
}, 30000)
|
|
356
357
|
})
|
package/src/zone-report.js
CHANGED
|
@@ -9,7 +9,7 @@ const {getUserPartner} = require("fleetmap-partners")
|
|
|
9
9
|
const {devicesToProcess} = require("./util/device")
|
|
10
10
|
const traccarHelper = require("./util/traccar")
|
|
11
11
|
const pointToLineDistance = require("@turf/point-to-line-distance")
|
|
12
|
-
const
|
|
12
|
+
const booleanPointInPolygon = require("@turf/boolean-point-in-polygon")
|
|
13
13
|
const distance = require("@turf/distance")
|
|
14
14
|
|
|
15
15
|
const fileName = 'ZoneReport'
|
|
@@ -161,7 +161,7 @@ function getInAndOutEvents(devices, route, userData) {
|
|
|
161
161
|
routePoints.forEach(p => {
|
|
162
162
|
geofencesFeatures.forEach(g => {
|
|
163
163
|
if(g.geometry.type === 'Polygon') {
|
|
164
|
-
if (
|
|
164
|
+
if (booleanPointInPolygon.default(p, g)) {
|
|
165
165
|
if (!entryMap.includes(g)) {
|
|
166
166
|
events.push(createEvent('geofenceEnter',d.id,p,g))
|
|
167
167
|
entryMap.push(g)
|
|
@@ -189,7 +189,7 @@ function getInAndOutEvents(devices, route, userData) {
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
if(g.geometry.type === 'LineString') {
|
|
192
|
-
if (pointToLineDistance(p, g,{units: 'meters'}) < (g.properties.geofence.attributes.polylineDistance || 25)) {
|
|
192
|
+
if (pointToLineDistance.default(p, g,{units: 'meters'}) < (g.properties.geofence.attributes.polylineDistance || 25)) {
|
|
193
193
|
if (!entryMap.includes(g)) {
|
|
194
194
|
events.push(createEvent('geofenceEnter',d.id,p,g))
|
|
195
195
|
entryMap.push(g)
|