GPS Exchange Format library/CLI in OCaml
1(** Track types and operations *)
2
3(** Track point is an alias for waypoint *)
4type point = Waypoint.t
5
6(** Track segment *)
7type segment = {
8 trkpts : point list;
9 extensions : Extension.t list;
10}
11
12(** Main track type *)
13type t = {
14 name : string option;
15 cmt : string option;
16 desc : string option;
17 src : string option;
18 links : Link.t list;
19 number : int option;
20 type_ : string option;
21 extensions : Extension.t list;
22 trksegs : segment list;
23}
24
25(** {2 Track Segment Operations} *)
26
27module Segment : sig
28 type t = segment
29
30 (** Create empty segment *)
31 val empty : t
32
33 (** Create segment with points *)
34 val make : point list -> t
35
36 (** Create segment from coordinate list.
37 @raises Invalid_argument on invalid coordinates *)
38 val make_from_coords : (float * float) list -> t
39
40 (** Get points *)
41 val points : t -> point list
42
43 (** Get point count *)
44 val point_count : t -> int
45
46 (** Get extensions *)
47 val extensions : t -> Extension.t list
48
49 (** Add point *)
50 val add_point : t -> point -> t
51
52 (** Add points *)
53 val add_points : t -> point list -> t
54
55 (** Extract coordinates *)
56 val to_coords : t -> (float * float) list
57
58 (** Calculate segment distance in meters *)
59 val distance : t -> float
60
61 (** Check if empty *)
62 val is_empty : t -> bool
63
64 (** First point *)
65 val first_point : t -> point option
66
67 (** Last point *)
68 val last_point : t -> point option
69
70 (** Compare segments *)
71 val compare : t -> t -> int
72
73 (** Test segment equality *)
74 val equal : t -> t -> bool
75
76 (** Pretty print segment *)
77 val pp : Format.formatter -> t -> unit
78end
79
80(** {2 Track Constructors} *)
81
82(** Create empty track *)
83val empty : t
84
85(** Create track with name *)
86val make : name:string -> t
87
88(** Create track from coordinate list (single segment).
89 @param name Track name
90 @param coords List of (latitude, longitude) pairs
91 @raises Failure on invalid coordinates *)
92val make_from_coords : name:string -> (float * float) list -> t
93
94(** {2 Track Properties} *)
95
96(** Get track name *)
97val name : t -> string option
98
99(** Get track description *)
100val description : t -> string option
101
102(** Get track comment *)
103val comment : t -> string option
104
105(** Get track source *)
106val source : t -> string option
107
108(** Get track links *)
109val links : t -> Link.t list
110
111(** Get track number *)
112val number : t -> int option
113
114(** Get track type *)
115val type_ : t -> string option
116
117(** Get track extensions *)
118val extensions : t -> Extension.t list
119
120(** Get track segments *)
121val segments : t -> segment list
122
123(** Get segment count *)
124val segment_count : t -> int
125
126(** Get total point count across all segments *)
127val point_count : t -> int
128
129(** Check if track is empty *)
130val is_empty : t -> bool
131
132(** {2 Track Modification} *)
133
134(** Clear all segments *)
135val clear_segments : t -> t
136
137(** {2 Track Analysis} *)
138
139(** Extract all coordinates from track *)
140val to_coords : t -> (float * float) list
141
142(** Calculate total track distance across all segments in meters *)
143val total_distance : t -> float
144
145(** Get all points from all segments *)
146val all_points : t -> point list
147
148(** Get first point from first segment *)
149val first_point : t -> point option
150
151(** Get last point from last segment *)
152val last_point : t -> point option
153
154(** {2 Comparison and Utilities} *)
155
156(** Compare tracks *)
157val compare : t -> t -> int
158
159(** Test track equality *)
160val equal : t -> t -> bool
161
162(** {2 Functional Operations} *)
163
164(** Update name *)
165val with_name : t -> string -> t
166
167(** Update comment *)
168val with_comment : t -> string -> t
169
170(** Update description *)
171val with_description : t -> string -> t
172
173(** Update source *)
174val with_source : t -> string -> t
175
176(** Update number *)
177val with_number : t -> int -> t
178
179(** Update type *)
180val with_type : t -> string -> t
181
182(** Add segment *)
183val add_segment : t -> Segment.t -> t
184
185(** Add link *)
186val add_link : t -> Link.t -> t
187
188(** Add extensions *)
189val add_extensions : t -> Extension.t list -> t
190
191(** Pretty print track *)
192val pp : Format.formatter -> t -> unit