GpxStat

Summary: A recipe to display statistics about a GPX file
Version: 2024-01-20
Prerequisites: PmWiki 2.3.29; PHP 8
Status: Beta
Maintainer: simon
Licence: GPL3#
Categories: Maps Markup Includes
Users: +1 (view / edit)
Discussion: GpxStat-Talk?

Questions answered by this recipe

How can I display information from a .gpx track file?

Description

This recipe extracts and derives information from a .gpx file. Information available includes times, duration, speed, and elevation.

It provides a single line directive that implements a display of information contained in, and derived from, .gpx file .

(:gpxstat gpx="wiki file name" display="layout" timezone="time/zone":).

The recipe uses a simple sliding window algorithm to remove outlier points and smooth the trace. An empirical 2.5 standard deviations from the average of the variation between points is used to set a threshold outside of which points are replaced by an estimated value.

Different layout displays can be selected to show the information relevant to the activity that generated the track.

Installation

  • download gpxstat-2024-01-20.phpΔ
  • copy to the /cookbook/ directory as gpxstat.php
  • add to config.php the line
    include_once($FarmD/cookbook/gpxstat.php);

Usage

Place the directive, as follows, in your PmWiki page.

(:gpxstat gpx='GroupName.PageName/filename.gpx' display='table,analyse' timezone='time/zone':)

Parameters are

gpx="groupname.pagename/filename"
this parameter is mandatory, the groupname and pagename are optional
display="layout"
this parameter is optional. Layout values are
  • table (of all available values)
  • tramp (i.e. walk)
  • ski
  • drive (also boat, fly in case these are differentiated in the future)
  • analyse (to assist with understanding the .gpx file)
if not supplied all available values are displayed in a column
stoppedthreshold="speed"
this parameter is optional. Set thespeed in km/h below which points count as stopped, overrides default and config value if specified
timezone="timezone/name"
this parameter is optional. Timezones recognised are those from the IANA / Olson timezone database. A conversion from timezone abbreviations is also attempted. You can also try the keyword 'detect' to calculate the timezone from the first point on the track, YMMV.
startname="location name"
this parameter is optional. Replaces the text "Start:"
endname="location name"
this parameter is optional. Replaces the text "End:"
banner="on", "off", or "version"
this parameter is optional. Enables (default), disables, or shows banner with version

GPX track files do not always comply with the GPS exchange format standard. This recipe takes precautions to handle some variances. If you have a .gpx file that does not work as expected with this recipe please send it for analysis with a description of the issue.

Example output

display=tramp


GpxStat tramp output

display=table


GpxStat table output

Configuration

config.php settings

You can set the following in config.php before including the recipe. for example:

$GpxStatDebug = true; # results may vary
$GpxStatThresholdSpeed = 1; # 1 km/h under which it is considered to be not moving
$GpxStatDTimeFmt = 'H:i'; # e.g. 'Y-m-d T H:i:s'
$GpxStatDateFmt = 'Y-m-d'; # e.g. 'Y-m-d T H:i:s'
$GpxStatBanner = 'on', 'off', or 'version

CSS style

The class ".gpxstat" is used to format the output. A default set of formatting is provided in $HTMLStylesFmt['GpxStat'] = '.gpxstat { ... }';. Defining this variable in config.php before the recipe is included will override the defaults.

Change log / Release notes

2024-01-10 Add parameters (startname, endname, stoppedthreshold), update analyse, handle no timestamps, correct display of duration 2024-01-01 Initial version

See also

A handy companion to

Similar utilities and information

Used on

Contributors

Talkback

See discussion at GpxStat-Talk?

User notes +1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.