package mlgpx

  1. Overview
  2. Docs

Source file gpx.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
(** OCaml library for reading and writing GPX (GPS Exchange Format) files *)

(** {1 Core Modules} *)

(** Geographic coordinate handling *)
module Coordinate = Coordinate

(** Links, persons, and copyright information *)
module Link = Link

(** Extension mechanism for custom GPX elements *)
module Extension = Extension

(** GPS waypoint data and fix types *)
module Waypoint = Waypoint

(** GPX metadata including bounds *)
module Metadata = Metadata

(** Route data and calculations *)
module Route = Route

(** Track data with segments *)
module Track = Track

(** Error handling *)
module Error = Error

(** Main GPX document type *)
module Doc = Doc

(** {1 Main Document Type} *)

(** Main GPX document type *)
type t = Doc.t

(** {1 Error Handling} *)

(** Error types *)
type error = Error.t

(** GPX exception *)
exception Gpx_error of error

(** {1 Parsing Functions} *)

(** Parse GPX from XML input *)
let parse ?validate input = Parser.parse ?validate input

(** Parse GPX from string *)
let parse_string ?validate s = Parser.parse_string ?validate s

(** {1 Writing Functions} *)

(** Write GPX to XML output *)
let write ?validate output gpx = Writer.write ?validate output gpx

(** Write GPX to string *)
let write_string ?validate gpx = Writer.write_string ?validate gpx

(** {1 Validation Functions} *)

(** Validation issue with severity level *)
type validation_issue = Validate.validation_issue = {
  level : [`Error | `Warning];
  message : string;
  location : string option;
}

(** Result of validation containing all issues found *)
type validation_result = Validate.validation_result = {
  issues : validation_issue list;
  is_valid : bool;
}

(** Validate complete GPX document *)
let validate_gpx = Validate.validate_gpx

(** Quick validation - returns true if document is valid *)
let is_valid = Validate.is_valid

(** Get only error messages *)
let errors = Validate.errors

(** Get only warning messages *)
let warnings = Validate.warnings

(** Format validation issue for display *)
let format_issue = Validate.format_issue

(** {1 Constructors and Utilities} *)

(** Create new GPX document *)
let make_gpx ~creator = Doc.empty ~creator

(** Create empty GPX document *)
let empty ~creator = Doc.empty ~creator
OCaml

Innovation. Community. Security.