Computes distance between two paths by projecting positions of the second (acquired) path onto the first (reference) one. This allows to compare paths with different location counts.
comparing two paths | comparing same paths with time information taken into account |
Add this line to ~/.npmrc
to set up the package registry:
@indoor-analytics:registry=https://npm.pkg.github.com/indoor-analytics
In your project, install the package:
npm i --save @indoor-analytics/path-distance
Import the function in your code:
import {pathDistance} from '@indoor-analytics/path-distance';
For each acquired path location, we create a projection on the reference path; first path location will always match first reference path, the same for the last location.
A projected position is obtained by:
- getting distance between the current path position and the path origin;
- computing the ratio position distance / path length;
- computing the equivalent distance regarding the reference path;
- projecting the position on the reference path.
For each path reference path segment (made by two consecutive path points):
- get both points' timestamps;
- get compared path segment whose locations have been captured while walking current reference path segment;
- compare reference path segment and compared path segment using classic distance algorithm