mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-06 07:53:43 +08:00
deg_of_string added for dms parsing
This commit is contained in:
@@ -456,6 +456,19 @@ let of_string = fun s ->
|
||||
let string_of = fun geo ->
|
||||
Printf.sprintf "WGS84 %s" (string_degrees_of_geographic geo)
|
||||
|
||||
let deg_of_string = fun s ->
|
||||
match Str.split space s with
|
||||
[lat_d; lat_m; lat_s] ->
|
||||
decimal (ios lat_d) (ios lat_m) (fos lat_s)
|
||||
| [lat_d; lat_m; lat_s; hemi] ->
|
||||
let sign =
|
||||
match hemi with
|
||||
"N" | "E" -> 1. | "S" | "W" -> -1.
|
||||
| _ -> failwith (Printf.sprintf "N or S expected for hemispere in dms, found '%s'" hemi) in
|
||||
sign *. decimal (ios lat_d) (ios lat_m) (fos lat_s)
|
||||
| [deg] -> float_of_string deg
|
||||
| _ -> invalid_arg (Printf.sprintf "Latlong.of_string: %s" s)
|
||||
|
||||
|
||||
let mercator_lat = fun l -> log (tan (pi/.4. +. 0.5*. l))
|
||||
let inv_mercator_lat = fun l -> 2. *. atan (exp l) -. pi/.2.
|
||||
|
||||
@@ -137,6 +137,8 @@ val of_string : string -> geographic
|
||||
(** [of_string pos] Parses [pos] as "WGS84 45.678 1.2345", "UTM 500123 4500300 31" or "LBT2e 544945 1755355" *)
|
||||
val string_of : geographic -> string
|
||||
(** Returns a "WGS84" annotated string *)
|
||||
val deg_of_string : string -> float
|
||||
(** Parse a deg min sec or a decimal angle *)
|
||||
|
||||
val mercator_lat : float -> float
|
||||
(** wgs84 -> [-pi; pi] *)
|
||||
|
||||
Reference in New Issue
Block a user