GPS Exchange Format library/CLI in OCaml
at main 3.0 kB view raw
1(** GPX metadata and bounds types *) 2 3(** Bounding box *) 4type bounds = { 5 minlat : Coordinate.latitude; 6 minlon : Coordinate.longitude; 7 maxlat : Coordinate.latitude; 8 maxlon : Coordinate.longitude; 9} 10 11(** Main metadata type *) 12type t = { 13 name : string option; 14 desc : string option; 15 author : Link.person option; 16 copyright : Link.copyright option; 17 links : Link.t list; 18 time : Ptime.t option; 19 keywords : string option; 20 bounds : bounds option; 21 extensions : Extension.t list; 22} 23 24(** {2 Bounds Operations} *) 25 26module Bounds : sig 27 type t = bounds 28 29 (** Create bounds from validated coordinates *) 30 val make : minlat:Coordinate.latitude -> minlon:Coordinate.longitude -> 31 maxlat:Coordinate.latitude -> maxlon:Coordinate.longitude -> t 32 33 (** Create bounds from float coordinates with validation *) 34 val make_from_floats : minlat:float -> minlon:float -> maxlat:float -> maxlon:float -> (t, string) result 35 36 (** Get minimum corner coordinates *) 37 val min_coords : t -> Coordinate.t 38 39 (** Get maximum corner coordinates *) 40 val max_coords : t -> Coordinate.t 41 42 (** Get all bounds as tuple *) 43 val bounds : t -> (Coordinate.latitude * Coordinate.longitude * Coordinate.latitude * Coordinate.longitude) 44 45 (** Check if coordinate is within bounds *) 46 val contains : t -> Coordinate.t -> bool 47 48 (** Calculate bounds area in square degrees *) 49 val area : t -> float 50 51 (** Compare bounds *) 52 val compare : t -> t -> int 53 54 (** Test bounds equality *) 55 val equal : t -> t -> bool 56 57 (** Pretty print bounds *) 58 val pp : Format.formatter -> t -> unit 59end 60 61(** {2 Metadata Operations} *) 62 63(** Create empty metadata *) 64val empty : t 65 66(** Create metadata with name *) 67val make : name:string -> t 68 69(** Get name *) 70val name : t -> string option 71 72(** Get description *) 73val description : t -> string option 74 75(** Get author *) 76val author : t -> Link.person option 77 78(** Get copyright *) 79val copyright : t -> Link.copyright option 80 81(** Get links *) 82val links : t -> Link.t list 83 84(** Get time *) 85val time : t -> Ptime.t option 86 87(** Get keywords *) 88val keywords : t -> string option 89 90(** Get bounds *) 91val bounds_opt : t -> bounds option 92 93(** Get extensions *) 94val extensions : t -> Extension.t list 95 96(** Functional operations for building metadata *) 97 98(** Update name *) 99val with_name : t -> string -> t 100 101(** Update description *) 102val with_description : t -> string -> t 103 104(** Update keywords *) 105val with_keywords : t -> string -> t 106 107(** Update time *) 108val with_time : t -> Ptime.t option -> t 109 110(** Update bounds *) 111val with_bounds : t -> bounds -> t 112 113(** Update author *) 114val with_author : t -> Link.person -> t 115 116(** Update copyright *) 117val with_copyright : t -> Link.copyright -> t 118 119(** Add link *) 120val add_link : t -> Link.t -> t 121 122(** Add extensions *) 123val add_extensions : t -> Extension.t list -> t 124 125(** Compare metadata *) 126val compare : t -> t -> int 127 128(** Test metadata equality *) 129val equal : t -> t -> bool 130 131(** Pretty print metadata *) 132val pp : Format.formatter -> t -> unit