GPS Exchange Format library/CLI in OCaml
at v1.0.0 1.7 kB view raw
1(** Geographic coordinate types with validation *) 2 3(** Coordinate types with validation constraints *) 4type latitude = private float 5type longitude = private float 6type degrees = private float 7 8(** Coordinate pair *) 9type t = { 10 lat : latitude; 11 lon : longitude; 12} 13 14(** {2 Constructors} *) 15 16(** Create validated latitude. 17 @param f Latitude in degrees (-90.0 to 90.0) 18 @return [Ok latitude] or [Error msg] *) 19val latitude : float -> (latitude, string) result 20 21(** Create validated longitude. 22 @param f Longitude in degrees (-180.0 to 180.0) 23 @return [Ok longitude] or [Error msg] *) 24val longitude : float -> (longitude, string) result 25 26(** Create validated degrees. 27 @param f Degrees (0.0 to 360.0) 28 @return [Ok degrees] or [Error msg] *) 29val degrees : float -> (degrees, string) result 30 31(** {2 Conversion Functions} *) 32 33(** Convert latitude to float *) 34val latitude_to_float : latitude -> float 35 36(** Convert longitude to float *) 37val longitude_to_float : longitude -> float 38 39(** Convert degrees to float *) 40val degrees_to_float : degrees -> float 41 42(** {2 Operations} *) 43 44(** Create coordinate pair from validated components *) 45val make : latitude -> longitude -> t 46 47(** Create coordinate pair from floats with validation *) 48val make_from_floats : float -> float -> (t, string) result 49 50(** Extract latitude component *) 51val lat : t -> latitude 52 53(** Extract longitude component *) 54val lon : t -> longitude 55 56(** Convert coordinate to float pair *) 57val to_floats : t -> float * float 58 59(** {2 Comparison and Printers} *) 60 61(** Compare two coordinates *) 62val compare : t -> t -> int 63 64(** Test coordinate equality *) 65val equal : t -> t -> bool 66 67(** Pretty print coordinate *) 68val pp : Format.formatter -> t -> unit