deg_of_string added for dms parsing

This commit is contained in:
Pascal Brisset
2008-07-18 15:29:16 +00:00
parent f436593f44
commit f76b233913
2 changed files with 15 additions and 0 deletions
+13
View File
@@ -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.
+2
View File
@@ -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] *)