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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.866",
3
+ "version": "1.0.867",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -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
- // eslint-disable-next-line camelcase
322
- const { matched_points, edges } = await axios.post('https://valhalla1.openstreetmap.de/trace_attributes', {
323
- costing: 'auto',
324
- 'shape_match type': 'map_snap',
325
- filters: {
326
- attributes: [
327
- 'admin.country_code',
328
- 'admin.country_text',
329
- 'admin.state_code',
330
- 'admin.state_text',
331
- 'edge.names',
332
- 'edge.way_id',
333
- 'edge.speed_limit',
334
- 'matched.point',
335
- 'matched.type',
336
- 'matched.edge_index'
337
- ],
338
- action: 'include'
339
- },
340
- shape: slice.map(p => ({
341
- lon: p.longitude, lat: p.latitude
342
- }))
343
- }).then(r => r.data)
344
-
345
- // eslint-disable-next-line camelcase
346
- matched_points.forEach((mp, mIndex) => {
347
- const edge = edges[mp.edge_index]
348
- const position = route[mIndex + i]
349
- if (edge && (edge.speed_limit + (threshold || 0)) < position.speed * 1.852) {
350
- results.push({ ...mp, ...edge, ...position })
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]