fleetmap-reports 1.0.955 → 1.0.957
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/trip-report.js +11 -4
- package/src/util/geofence.js +4 -2
package/package.json
CHANGED
package/src/trip-report.js
CHANGED
|
@@ -259,11 +259,18 @@ async function processDrivers (from, to, userData, data) {
|
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
userData.drivers
|
|
262
|
+
for (const d of userData.drivers) {
|
|
263
263
|
const { route, trips } = getDriverData(d, data)
|
|
264
|
-
const filteredTrips =
|
|
264
|
+
const filteredTrips = []
|
|
265
|
+
for (const t of trips) {
|
|
266
|
+
if (userData.allWeek ||
|
|
267
|
+
!userData.weekDays ||
|
|
268
|
+
isInsideTimetable(t, userData) ||
|
|
269
|
+
await isPartialInsideTimetable(t, userData, route)) {
|
|
270
|
+
filteredTrips.push(t)
|
|
271
|
+
}
|
|
272
|
+
}
|
|
265
273
|
filteredTrips.sort((a, b) => new Date(a.startTime).getTime() - new Date(b.startTime).getTime())
|
|
266
|
-
|
|
267
274
|
filteredTrips.forEach(function (trip, i) {
|
|
268
275
|
trip.totalKms = trip.distance / 1000
|
|
269
276
|
|
|
@@ -287,7 +294,7 @@ async function processDrivers (from, to, userData, data) {
|
|
|
287
294
|
}
|
|
288
295
|
driversResult.push(driverData)
|
|
289
296
|
}
|
|
290
|
-
}
|
|
297
|
+
}
|
|
291
298
|
|
|
292
299
|
return driversResult
|
|
293
300
|
}
|
package/src/util/geofence.js
CHANGED
|
@@ -22,13 +22,15 @@ function getNearestPOIs (long, lat, geofences) {
|
|
|
22
22
|
.filter(g => g && g.area.startsWith('CIRCLE'))
|
|
23
23
|
.map(g => {
|
|
24
24
|
const str = g.area.substring('CIRCLE ('.length, g.area.indexOf(','))
|
|
25
|
+
const radius = g.area.substring(g.area.indexOf(',') + 1, g.area.indexOf(')'))
|
|
25
26
|
const coord = str.trim().split(' ')
|
|
26
27
|
return {
|
|
27
28
|
p: g,
|
|
28
|
-
distance: Math.round(coordsDistance(parseFloat(coord[1]), parseFloat(coord[0]), long, lat))
|
|
29
|
+
distance: Math.round(coordsDistance(parseFloat(coord[1]), parseFloat(coord[0]), long, lat)),
|
|
30
|
+
r: parseFloat(radius)
|
|
29
31
|
}
|
|
30
32
|
})
|
|
31
|
-
return distance.filter(a => a.distance <
|
|
33
|
+
return distance.filter(a => a.distance < a.r).sort((a, b) => (a.distance > b.distance) ? 1 : -1)
|
|
32
34
|
}
|
|
33
35
|
exports.getNearestPOIs = getNearestPOIs
|
|
34
36
|
|