fleetmap-reports 1.0.402 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.402",
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",
@@ -87,7 +87,7 @@ async function createActivityReportByDevice (from, to, userData, traccarInstance
87
87
  trips,
88
88
  route,
89
89
  summary
90
- } = await traccar.getAllInOne(traccarInstance, from, to, devices, true, true, false, !userData.groupByDay, deviceCount)
90
+ } = await traccar.getAllInOne(traccarInstance, from, to, devices, true, true, false, !userData.groupByDay, deviceCount, allDevices.length)
91
91
 
92
92
  if (userData.groupByDay) {
93
93
  console.log('trips:' + trips.length)
@@ -299,6 +299,7 @@ async function exportActivityReportToPDF (userData, reportData) {
299
299
  const translations = getTranslations(userData)
300
300
 
301
301
  if (reportData.devices || reportData.drivers) {
302
+ // eslint-disable-next-line new-cap
302
303
  const doc = new jsPDF.jsPDF('l')
303
304
  await headerFromUser(doc, translations.report.titleActivityReport, userData.user)
304
305
 
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
- /* it('Zone Report', async () => {
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, 11)
351
- assert.equal(device.geofences[0].inTime.fixTime, '2022-04-25T23:48:05.000+0000')
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, '28770')
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
  })
@@ -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 pointOnFeature = require("@turf/point-on-feature")
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 (pointOnFeature(p, g)) {
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)
@@ -175,7 +175,7 @@ function getInAndOutEvents(devices, route, userData) {
175
175
  }
176
176
  }
177
177
  if(g.geometry.type === 'Point') {
178
- if (distance(p, g, {units: 'meters'}) < g.properties.distance) {
178
+ if (distance.default(p, g, {units: 'meters'}) < g.properties.distance) {
179
179
  if (!entryMap.includes(g)) {
180
180
  events.push(createEvent('geofenceEnter',d.id,p,g))
181
181
  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)