package mlgpx

  1. Overview
  2. Docs

Module Gpx.TrackSource

Track data with segments

The Track module handles recorded GPS traces, typically representing actual journeys. Tracks are divided into segments to handle GPS interruptions:

  • Track segments contain ordered track points
  • Each track point is a timestamped waypoint
  • Multiple segments per track handle GPS signal loss
  • Distance and time calculations available

Track types and operations

Sourcetype point = Waypoint.t

Track point is an alias for waypoint

Sourcetype segment = {
  1. trkpts : point list;
  2. extensions : Extension.t list;
}

Track segment

Sourcetype t = {
  1. name : string option;
  2. cmt : string option;
  3. desc : string option;
  4. src : string option;
  5. number : int option;
  6. type_ : string option;
  7. extensions : Extension.t list;
  8. trksegs : segment list;
}

Main track type

Track Segment Operations

Sourcemodule Segment : sig ... end

Track Constructors

Sourceval empty : t

Create empty track

Sourceval make : name:string -> t

Create track with name

Sourceval make_from_coords : name:string -> (float * float) list -> t

Create track from coordinate list (single segment).

  • parameter name

    Track name

  • parameter coords

    List of (latitude, longitude) pairs

  • raises Failure

    on invalid coordinates

Track Properties

Sourceval name : t -> string option

Get track name

Sourceval description : t -> string option

Get track description

Sourceval comment : t -> string option

Get track comment

Sourceval source : t -> string option

Get track source

Get track links

Sourceval number : t -> int option

Get track number

Sourceval type_ : t -> string option

Get track type

Sourceval extensions : t -> Extension.t list

Get track extensions

Sourceval segments : t -> segment list

Get track segments

Sourceval segment_count : t -> int

Get segment count

Sourceval point_count : t -> int

Get total point count across all segments

Sourceval is_empty : t -> bool

Check if track is empty

Track Modification

Sourceval clear_segments : t -> t

Clear all segments

Track Analysis

Sourceval to_coords : t -> (float * float) list

Extract all coordinates from track

Sourceval total_distance : t -> float

Calculate total track distance across all segments in meters

Sourceval all_points : t -> point list

Get all points from all segments

Sourceval first_point : t -> point option

Get first point from first segment

Sourceval last_point : t -> point option

Get last point from last segment

Comparison and Utilities

Sourceval compare : t -> t -> int

Compare tracks

Sourceval equal : t -> t -> bool

Test track equality

Functional Operations

Sourceval with_name : t -> string -> t

Update name

Sourceval with_comment : t -> string -> t

Update comment

Sourceval with_description : t -> string -> t

Update description

Sourceval with_source : t -> string -> t

Update source

Sourceval with_number : t -> int -> t

Update number

Sourceval with_type : t -> string -> t

Update type

Sourceval add_segment : t -> Segment.t -> t

Add segment

Add link

Sourceval add_extensions : t -> Extension.t list -> t

Add extensions

Sourceval pp : Format.formatter -> t -> unit

Pretty print track

OCaml

Innovation. Community. Security.