@wemap/geo 6.2.2 → 6.2.3

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
@@ -12,7 +12,7 @@
12
12
  "directory": "packages/geo"
13
13
  },
14
14
  "name": "@wemap/geo",
15
- "version": "6.2.2",
15
+ "version": "6.2.3",
16
16
  "bugs": {
17
17
  "url": "https://github.com/wemap/wemap-modules-js/issues"
18
18
  },
@@ -30,5 +30,5 @@
30
30
  "@wemap/logger": "^6.0.0",
31
31
  "@wemap/maths": "^6.0.0"
32
32
  },
33
- "gitHead": "ee717a21b2f01820472df0112da9373044f267f9"
33
+ "gitHead": "e88b0f15de31c30588aaacdadcbad2da46f9673d"
34
34
  }
package/src/Utils.js CHANGED
@@ -85,6 +85,10 @@ export function trimRoute(route, startPosition = route[0], length = Number.MAX_V
85
85
  let currentPointIndex;
86
86
  let cumulativeDistance = 0;
87
87
 
88
+ if (route.length <= 1) {
89
+ throw new Error('Route must have at least 2 points');
90
+ }
91
+
88
92
  for (currentPointIndex = 1; currentPointIndex < route.length; currentPointIndex++) {
89
93
 
90
94
  const p1 = route[currentPointIndex - 1];
package/src/Utils.spec.js CHANGED
@@ -60,6 +60,8 @@ describe('Geo Utils', () => {
60
60
  const route = [p1, p2, p3];
61
61
 
62
62
  expect(() => trimRoute(route, new Coordinates(0, 0))).throw(Error);
63
+ expect(() => trimRoute([p1], p1)).throw(Error);
64
+ expect(() => trimRoute([], null)).throw(Error);
63
65
 
64
66
  newRoute = trimRoute(route);
65
67
  expect(newRoute.length).equals(3);