GithubHelp home page GithubHelp logo

netroscript / gps-path-average-distance Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 43 KB

A Rust application for computing the average distance between a reference GPS path and multiple tracks, utilizing point proximity analysis and path simplification for accurate comparison.

License: MIT License

Rust 100.00%

gps-path-average-distance's Introduction

GPS Path Average Distance

This Rust console application is designed to compute the average distance between a reference GPS path and one or more additional GPS tracks. The calculation is based on determining the closest point on the reference path for each point on the track(s) being compared. Additionally, conventional curve metrics such as the Hausdorff distance and the Fréchet distance are provided as output.

The application provides four output values: an average distance "in time"*, an "location-dependent" average distance, the Fréchet distance, and the Hausdorff distance. The rationale behind the distinction between location and time-dependent average distances is as follows:

When sampling points along the track(s) to compare against the reference, it is possible to encounter multiple points at the same location if a person remains stationary for a period of time. Consequently, the longer the stationary period, the more the distance measurement becomes skewed towards that particular location. However, the focus may be on understanding the actual differences in paths, irrespective of movement speed or time. To address this, the algorithm simplifies the track using the Douglas-Peucker algorithm prior to calculating the average distance. This simplification process retains only points corresponding to changes in the path's direction, resulting in a simplified path. The average distance is then computed based on this simplified representation, which more accurately reflects the average distance between the paths, independent of movement speed or time.

To provide a distance in meters for the Fréchet and Hausdorff distances, it is necessary to project the GPS coordinates onto a 2D plane. This is done using the flat_projection crate. According to the crate's documentation, the projection is based on WGS84 and very precise for distances up to 500 km.

Table of Contents

Installation / Building from Source

  1. Install Rust and Cargo from https://www.rust-lang.org.
  2. Clone the repository or download the source code.
  3. Open a terminal and navigate to the project directory.
  4. Run the command cargo build --release to compile the application.

Usage

This assumes you have a compiled version of the application.

The application takes input in the form of GPX files (.gpx) for both the reference path and the tracks to compare. Here's how to use it:

gps-path-average-distance [OPTIONS] --reference <REFERENCE> --track <TRACK>

Options

Options

  • -r, --reference <REFERENCE>: File path to the .gpx file containing the reference path.
  • -t, --track <TRACK>: File path(s) to the .gpx file(s) containing the track(s) to compare. Separate multiple paths with a comma.
  • -d, --debug: Turn on debugging information.
  • -s, --simplify_epsilon <EPSILON>: Custom epsilon value for simplifying the reference path. Default is 0.00001.
    • This value is used as the epsilon in the Douglas-Peucker algorithm for simplifying the current path. The bigger the value, the more simplified the path will be. The reference "space" is in latitude and longitude, for this reason the value is quite small by default.
  • -e, --export_track: Toggle to also reexport the parsed GPX files as simplified GPX files.
    • Exported files will be named <original_file_name>.modified.gpx and will be placed in the same directory as the original file. No GPX extensions are supported, so you will be left with only track points containing latitude and longitude.

Example

gps-path-average-distance -r ./reference.gpx -t ./track1.gpx,./track2.gpx -d -e

Exemplary Output

The following figure shows four example paths. The red path is the reference path, while the blue and green paths are the tracks to compare. (Green is the original track, while Blue is the simplified track). You can see how there is almost no visual difference between the original path and the simplified path.

Path-distances-example

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.