The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Geo::TCX::Interactive - Sub-class of Geo::TCX to be used interactively in the debugger

SYNOPSIS

  perl -d -MGeo::TCX::Interactive -e '$o= Geo::TCX::Interactive->new("~/Data/Src/Garmin/History"); 1'

or perl -d -MGeo::TCX::Interactive -e 0 $o = Geo::TCX::Interactive->new('~/Data/Src/Garmin/History', work_dir => '~/Data/Garmin/');

or in a script as

  use Geo::TCX::Interactive;
  use Geo::Gpx;
  $o= Geo::TCX::Interactive->new( $sr_dir, recent => $recent, work_dir => $wk_dir );

DESCRIPTION

A sub-class of Geo::TCX, this module provides methods to manage TCX files interactively in the debugger, e.g. with prompts to select which recent file to edit, modify, and save.

Geo::TCX::Interactive also enables the interactive management and editing of waypoints using Geo::Gpx, that is, by loading/saving *.gpx files, retrieving waypoints from devices, and comparing these points with Geo::TCX Activity and Course files.

There are no return values for a few methods that prompt the user for a response before performing certain actions. This may change in the future if sensible return values can be identified. All values actually returned are documented below.

Constructor Methods

new( $foldername, key/values )

Expects a folder as main argument instead of a file name. The user is then prompted to select a file from a list of the most recent ones modified in that folder before returning an instance of the class. Many convenience methods can then be used interactively, particularly if used in the perl debugger.

key/values (all are optional)

recent => # : specifies how many recent files to display, the default being 25. work_dir => $folder: specifies where to save any working files, such as with the save_laps() method.

Object Methods

prompt_and_set_wd( $folder )

Prompts for a choice between existing folders in the current working directory and calls set_wd to set it as the working directory. Returns the path to that working directory.

save_laps( %options )

is identical to save_laps() in Geo::TCX but will prompt the user to confirm the intention to save the laps before continuing. It expects the same %options and returns the same value, except that it returns false if the user does not answer yes at the prompt.

gpx_load( $file )

Loads a Gpx file into the TCX object. If a directory is specified instead of a file, prompts for a choice among the gpx files found in that directory.

Return a reference to the Geo::Gpx object loaded.

way_add_endpoints( tolerance_meters => # )

Compare the end points of each lap with all waypoints read in the Geo::Gpx instance (by gpx_load() and, if the distance is less than tolerance_meters, prompts whether the waypoint should be added to it.

In the affirmative, prompts what name and description should be given to the new waypoint. Set tolerance_meters to 0 to compare all start/end points of laps with waypoints, or to another desired value.

The default tolerance_meters is 10. Returns true.

way_add_device( $directory_on_device )

Prompts the user whether they wish to look for waypoints saved on a GPS device and compare them to the waypoints read in the Geo::TCX instance by gpx_load(). The device must be currently plugged in with a USB cable.

In the affirmative, compares each waypoint from the device to those in the instance and, if the distance is greater than 1 meter, prompts whether the waypoint should be added to the waypoints in the object.

If no directory is provided, tries to guess where that directory might be (provided the device is plugged in). Returns false if the directory or waypoints file cannot be found (does not die) or if the user responds no at the initial prompt. Otherwise returns true.

gpx_save( )

Save the gpx file. The same options as Geo::Gpx-save()> are expected but will prompt the user whether to overwrite an existing file if $force is false.

Returns true if the file was saved, false otherwise.

gpx( )

Returns the Geo::Gpx instance currently referenced in the object. Croaks if none is found.

way_clip( $name | $regex | LIST )

Sends the coordinates of waypoints whose name is either $name or matches $regex to the clipboard (all points found are sent to the clipboard). Returns an array of points found.

By default, the regex is case-sensitive; specify qr/(?i:...)/ to ignore case.

Alternatively, an array of Geo::GXP::Points can be supplied such that we can call $o->way_clip( $o->gpx->search_desc( qr/(?i:Sunset)/ ).

This method is only supported on unix-based systems that have the xclip utility installed (see BUGS AND LIMITATIONS).

way_device_send()

Send the waypoints to a GPS device, overwriting any existing file. The device must be plugged in.

Some devices have a limit of a 100 waypoints, it will keep the first 100 in the order that they appear in the file. Returns true.

lap_summary( # )

prints summary data for a given lap number. Returns true.

EXAMPLES

Coming soon.

DEPENDENCIES

Geo::FIT is also required to parse FIT files and to add waypoints from a GPS device (except for some older models).

The way_clip() method is only supported on unix-based systems that have the xclip utility installed. On Debian based system, you may install it as

  aptitude show xlip
  sudo apt install xclip

See your package manager's instructions for information on how to install it on other systems.

SEE ALSO

Geo::TCX, Geo::Gpx, Geo::FIT, xclip(1).

BUGS

No bugs have been reported yet.

AUTHOR

Patrick Joly

VERSION

1.06