@wemap/geo 0.3.0 → 0.3.1

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": "0.3.0",
15
+ "version": "0.3.1",
16
16
  "bugs": {
17
17
  "url": "https://github.com/wemap/wemap-utils-js/issues"
18
18
  },
@@ -27,9 +27,9 @@
27
27
  ],
28
28
  "license": "ISC",
29
29
  "dependencies": {
30
- "@wemap/maths": "^0.2.0",
30
+ "@wemap/maths": "^0.2.1",
31
31
  "lodash.isnumber": "^3.0.3",
32
32
  "lodash.isstring": "^4.0.1"
33
33
  },
34
- "gitHead": "1175cf4c2faf2506e2fafa03f2eec7cbd632a5de"
34
+ "gitHead": "7b84c9d55646761f75f19235a15be8a1b73b3dbf"
35
35
  }
@@ -202,7 +202,7 @@ class Itinerary extends Network {
202
202
  return null;
203
203
  }
204
204
 
205
- const projection = this.mapMatching.getProjection(position, false, false);
205
+ const projection = this.mapMatching.getProjection(position);
206
206
  if (!projection) {
207
207
  return null;
208
208
  }
@@ -240,7 +240,7 @@ class Itinerary extends Network {
240
240
  return {
241
241
  nextStep,
242
242
  previousStep,
243
- projection: projection,
243
+ projection,
244
244
  traveledDistance,
245
245
  traveledPercentage: traveledDistance / totalDistance,
246
246
  remainingDistance: totalDistance - traveledDistance,
@@ -345,12 +345,17 @@ class Itinerary extends Network {
345
345
  previousStep = currentStep;
346
346
 
347
347
  currentStep = new Step();
348
+ currentStep.number = this._steps.length + 1;
348
349
  currentStep.angle = angle;
349
350
  currentStep.previousBearing = previousBearing;
350
351
  currentStep.nextBearing = bearing;
351
352
  currentStep.nodes.push(node);
352
353
  this._steps.push(currentStep);
353
354
 
355
+ if (!previousStep) {
356
+ currentStep.firstStep = true;
357
+ }
358
+
354
359
  const indexOfCurrentStep = this._steps.length - 1;
355
360
  const numberOfNodesToFill = previousStep ? previousStep.nodes.length - 1 : 1;
356
361
  for (let j = 0; j < numberOfNodesToFill; j++) {
@@ -372,18 +377,26 @@ class Itinerary extends Network {
372
377
  if (lastNode.coords !== this.end) {
373
378
 
374
379
  const lastStep = new Step();
380
+ lastStep.number = this._steps.length + 1;
375
381
  lastStep._length = 0;
376
382
  lastStep.nextBearing = lastNode.coords.bearingTo(this.end);
377
383
  lastStep.previousBearing = previousBearing;
384
+ lastStep.lastStep = true;
378
385
  lastStep.angle = diffAngle(lastStep.previousBearing, lastStep.nextBearing + Math.PI);
379
386
  lastStep.nodes.push(lastNode);
380
387
  this._steps.push(lastStep);
381
388
 
389
+ if (!currentStep) {
390
+ lastStep.firstStep = true;
391
+ }
392
+
382
393
  const indexOfCurrentStep = this._steps.length - 1;
383
394
  const numberOfNodesToFill = currentStep ? currentStep.nodes.length - 1 : 1;
384
395
  for (let j = 0; j < numberOfNodesToFill; j++) {
385
396
  this._nextStepsIndexes.push(indexOfCurrentStep);
386
397
  }
398
+ } else {
399
+ currentStep.lastStep = true;
387
400
  }
388
401
 
389
402
  }
@@ -35,7 +35,7 @@ class MapMatching {
35
35
  this.network = network;
36
36
  }
37
37
 
38
- getProjection(location, useDistance = true, useBearing = true, useMultiLevelSegments = true, acceptEdgeFn = () => true) {
38
+ getProjection(location, useDistance = false, useBearing = false, useMultiLevelSegments = true, acceptEdgeFn = () => true) {
39
39
 
40
40
  if (!this.network) {
41
41
  return null;
@@ -16,7 +16,7 @@ describe('MapMatching', () => {
16
16
  const location = new WGS84UserPosition(43.6091762, 3.8841239, null, new Level(2));
17
17
 
18
18
  it('without bearing', () => {
19
- const result = mapMatching.getProjection(location, true, false).projection;
19
+ const result = mapMatching.getProjection(location).projection;
20
20
  const expected = new WGS84(43.609176389330685, 3.8841226728537976, null, new Level(2));
21
21
  expect(result.distanceTo(expected)).to.below(0.01);
22
22
  expect(Level.equalsTo(expected.level, result.level)).true;
@@ -25,7 +25,7 @@ describe('MapMatching', () => {
25
25
  it('with bearing', () => {
26
26
  mapMatching.maxAngleBearing = 30;
27
27
  location.bearing = 101.9;
28
- const result = mapMatching.getProjection(location).projection;
28
+ const result = mapMatching.getProjection(location, true, true).projection;
29
29
  const expected = new WGS84(43.60918861773314, 3.8841274925288447, null, new Level(2));
30
30
  expect(result.distanceTo(expected)).to.below(0.01);
31
31
  expect(Level.equalsTo(expected.level, result.level)).true;
package/src/graph/Step.js CHANGED
@@ -2,12 +2,15 @@ import Itinerary from './Itinerary';
2
2
 
3
3
  class Step {
4
4
 
5
+ number;
5
6
  nodes = [];
6
7
  edges = [];
7
8
  angle;
8
9
  _length = 0;
9
10
  previousBearing;
10
11
  nextBearing;
12
+ firstStep = false;
13
+ lastStep = false;
11
14
 
12
15
  get node() {
13
16
  return this.nodes[0];