GPS Exchange Format library/CLI in OCaml
at main 2.2 kB view raw
1(** OCaml library for reading and writing GPX (GPS Exchange Format) files *) 2 3(** {1 Core Modules} *) 4 5(** Geographic coordinate handling *) 6module Coordinate = Coordinate 7 8(** Links, persons, and copyright information *) 9module Link = Link 10 11(** Extension mechanism for custom GPX elements *) 12module Extension = Extension 13 14(** GPS waypoint data and fix types *) 15module Waypoint = Waypoint 16 17(** GPX metadata including bounds *) 18module Metadata = Metadata 19 20(** Route data and calculations *) 21module Route = Route 22 23(** Track data with segments *) 24module Track = Track 25 26(** Error handling *) 27module Error = Error 28 29(** Main GPX document type *) 30module Doc = Doc 31 32(** {1 Main Document Type} *) 33 34(** Main GPX document type *) 35type t = Doc.t 36 37(** {1 Error Handling} *) 38 39(** Error types *) 40type error = Error.t 41 42(** GPX exception *) 43exception Gpx_error of error 44 45(** {1 Parsing Functions} *) 46 47(** Parse GPX from XML input *) 48let parse ?validate input = Parser.parse ?validate input 49 50(** Parse GPX from string *) 51let parse_string ?validate s = Parser.parse_string ?validate s 52 53(** {1 Writing Functions} *) 54 55(** Write GPX to XML output *) 56let write ?validate output gpx = Writer.write ?validate output gpx 57 58(** Write GPX to string *) 59let write_string ?validate gpx = Writer.write_string ?validate gpx 60 61(** {1 Validation Functions} *) 62 63(** Validation issue with severity level *) 64type validation_issue = Validate.validation_issue = { 65 level : [`Error | `Warning]; 66 message : string; 67 location : string option; 68} 69 70(** Result of validation containing all issues found *) 71type validation_result = Validate.validation_result = { 72 issues : validation_issue list; 73 is_valid : bool; 74} 75 76(** Validate complete GPX document *) 77let validate_gpx = Validate.validate_gpx 78 79(** Quick validation - returns true if document is valid *) 80let is_valid = Validate.is_valid 81 82(** Get only error messages *) 83let errors = Validate.errors 84 85(** Get only warning messages *) 86let warnings = Validate.warnings 87 88(** Format validation issue for display *) 89let format_issue = Validate.format_issue 90 91(** {1 Constructors and Utilities} *) 92 93(** Create new GPX document *) 94let make_gpx ~creator = Doc.empty ~creator 95 96(** Create empty GPX document *) 97let empty ~creator = Doc.empty ~creator