gpxdistance

package module
v0.0.0-...-518da06 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2023 License: MIT Imports: 6 Imported by: 0

README

Go Report Card GoDoc

Overview

This provides a library and tools to count the distance traveled in GPX data. The library provides a function that takes an io.Reader. Alternatively, the "go-gpx-distance" command takes a single GPX file and "go-gpx-distance-path" takes a path to traverse recursively.

Example

Given a io.Reader, calculate the distance traveled:

distanceKm, err := Calculate(r)
log.PanicIf(err)

Implementation

The points are first sorted by timestamp. The distance between each point is then calculated via the Haversine formula and all distances are summed together.

Installing Commands

If you just want the commands and not the sourcecode, install via:

$ go install github.com/dsoprea/go-gpx-distance/command/go-gpx-distance@latest
$ go install github.com/dsoprea/go-gpx-distance/command/go-gpx-distance-path@latest

XML Encoding

Note that, since Go doesn't supporting XML decoding for any encoding but UTF-8, any GPX files with any other encoding but this will yield empty data. If you have a sufficiently similar encoding, such as ISO-8859-1, the current, best solution would just be to change the encoding to "UTF-8":

From:

<?xml version="1.0" encoding="ISO-8859-1" ?>

To:

<?xml version="1.0" encoding="UTF-8" ?>

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Calculate

func Calculate(r io.Reader) (totalDistanceKm float64, err error)

Calculate returns the number of kilometers traveled GPX data given a reader for that data. It first sorts by timestamp.

Types

This section is empty.

Directories

Path Synopsis
command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL