fleetmap-reports 1.0.866 → 1.0.867
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/speeding-report.js +41 -32
package/package.json
CHANGED
package/src/speeding-report.js
CHANGED
|
@@ -318,38 +318,47 @@ async function getOSMSpeedingEvents (devices, routes, threshold, minimumMinutes
|
|
|
318
318
|
const results = []
|
|
319
319
|
for (let i = 0; i < route.length; i += chunk) {
|
|
320
320
|
const slice = route.slice(i, i + chunk)
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
'
|
|
329
|
-
'
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
321
|
+
try {
|
|
322
|
+
const {
|
|
323
|
+
// eslint-disable-next-line camelcase
|
|
324
|
+
matched_points,
|
|
325
|
+
edges
|
|
326
|
+
} = await axios.post(`${process.env.VALHALLA_BASEURL}/trace_attributes`,
|
|
327
|
+
{
|
|
328
|
+
costing: 'auto',
|
|
329
|
+
shape_match: 'map_snap',
|
|
330
|
+
filters: {
|
|
331
|
+
attributes: [
|
|
332
|
+
'admin.country_code',
|
|
333
|
+
'admin.country_text',
|
|
334
|
+
'admin.state_code',
|
|
335
|
+
'admin.state_text',
|
|
336
|
+
'edge.names',
|
|
337
|
+
'edge.way_id',
|
|
338
|
+
'edge.speed_limit',
|
|
339
|
+
'matched.point',
|
|
340
|
+
'matched.type',
|
|
341
|
+
'matched.edge_index'
|
|
342
|
+
],
|
|
343
|
+
action: 'include'
|
|
344
|
+
},
|
|
345
|
+
shape: slice.map(p => ({
|
|
346
|
+
lon: p.longitude,
|
|
347
|
+
lat: p.latitude
|
|
348
|
+
}))
|
|
349
|
+
})
|
|
350
|
+
.then(r => r.data)
|
|
351
|
+
// eslint-disable-next-line camelcase
|
|
352
|
+
matched_points.forEach((mp, mIndex) => {
|
|
353
|
+
const edge = edges[mp.edge_index]
|
|
354
|
+
const position = route[mIndex + i]
|
|
355
|
+
if (edge && (edge.speed_limit + (threshold || 0)) < position.speed * 1.852) {
|
|
356
|
+
results.push({ ...mp, ...edge, ...position })
|
|
357
|
+
}
|
|
358
|
+
})
|
|
359
|
+
} catch (e) {
|
|
360
|
+
console.error(e.message, e.response && e.response.data, slice)
|
|
361
|
+
}
|
|
353
362
|
}
|
|
354
363
|
const reduced = results.reduce((acc, cur, idx, src) => {
|
|
355
364
|
const last = acc.length && acc.slice(-1)[0]
|