LambertIIe in maps

This commit is contained in:
Pascal Brisset
2006-03-09 22:03:20 +00:00
parent fa981e8824
commit 3942cbe6c1
4 changed files with 28 additions and 7 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ let calibrate_xy = fun x0 y0 ->
let print x y =
let xl = x0 + truncate (float x *. scale)
and yl = y0 + truncate (float y *. scale) in
let wgs84 = Latlong.wgs84_of_lambertIIe xl yl in
let wgs84 = Latlong.of_lambertIIe {lbt_x=xl;lbt_y= yl} in
Console.write (Printf.sprintf "%d %d %f %f\n" x y ((Rad>>Deg)wgs84.Latlong.posn_lat) ((Rad>>Deg)wgs84.Latlong.posn_long)) in
Console.write (Printf.sprintf "Calibration for x0=%d y0=%d:\n--8<----------------------\n" x0 y0);
+10 -2
View File
@@ -344,7 +344,15 @@ let utm_sub = fun u1 u2 ->
(u1.utm_x -. u2.utm_x, u1.utm_y -. u2.utm_y)
let wgs84_of_lambertIIe = fun x y -> (WGS84<<NTF)(of_lambert lambertIIe {lbt_x = x; lbt_y = y})
let of_lambertIIe = fun lbt ->
(WGS84<<NTF)(of_lambert lambertIIe lbt)
let lambertIIe_of = fun wgs84 ->
lambert_of lambertIIe ((NTF<<WGS84)wgs84)
let lbt_add = fun {lbt_x=x; lbt_y=y} (dx, dy) ->
{lbt_x = x + truncate dx; lbt_y = y + truncate dy }
let lbt_sub = fun {lbt_x=x1; lbt_y=y1} {lbt_x=x2; lbt_y=y2} ->
(float (x2-x1), float (y2-y1))
let space = Str.regexp "[ \t]+"
let fos = float_of_string
@@ -357,7 +365,7 @@ let of_string = fun s ->
| ["UTM";x;y;zone] ->
of_utm WGS84 { utm_x = fos x; utm_y = fos y; utm_zone = ios zone}
| ["LBT2e";x;y] ->
wgs84_of_lambertIIe (ios x) (ios y)
of_lambertIIe {lbt_x=ios x; lbt_y=ios y }
| _ -> invalid_arg (Printf.sprintf "Latlong.of_string: %s" s)
+8 -1
View File
@@ -114,7 +114,14 @@ val utm_sub : utm -> utm -> (fmeter * fmeter)
(** [utm_sub u1 u2] Raises Invalid_arg if [u1] and [u2] are not in the same
UTM zone *)
val wgs84_of_lambertIIe : meter -> meter -> geographic
val of_lambertIIe : lambert -> geographic
val lambertIIe_of : geographic -> lambert
val lbt_add : lambert -> (fmeter * fmeter) -> lambert
(** [add_lbt utm (east,north)] *)
val lbt_sub : lambert -> lambert -> (fmeter * fmeter)
(** Returns (east,north) *)
val of_string : string -> geographic
(** [of_string pos] Parses [pos] as "WGS84 45.678 1.2345", "UTM 500123 4500300 31" or "LBT2e 544945 1755355" *)
+9 -3
View File
@@ -15,7 +15,7 @@ type utm_zone = int
type projection =
Mercator (* 1e-6 = 1 world unit, y axis reversed *)
| UTM (* 1m = 1 world unit, y axis reversed *)
| Lambert2 (* 1m = 1 world unit, y axis reversed *)
| LambertIIe (* 1m = 1 world unit, y axis reversed *)
let default_georef = { LL.posn_lat = 0.; LL.posn_long = 0. }
@@ -141,7 +141,11 @@ class basic_widget = fun ?(height=800) ?width ?(projection = Mercator) ?georef (
let xw = (wgs84.LL.posn_long -. georef.LL.posn_long) *. mercator_coeff
and yw = -. (ml -. mlref) *. mercator_coeff in
(xw, yw)
| _ -> failwith "#world_of : unknown projection"
| LambertIIe ->
let lbtref = LL.lambertIIe_of georef
and lbt = LL.lambertIIe_of wgs84 in
let (wx, y) = LL.lbt_sub lbt lbtref in
(wx, -.y)
end
| None -> failwith "#world_of : no georef"
@@ -152,13 +156,15 @@ class basic_widget = fun ?(height=800) ?width ?(projection = Mercator) ?georef (
UTM ->
let utmref = LL.utm_of LL.WGS84 georef in
LL.of_utm LL.WGS84 (LL.utm_add utmref (wx, -.wy))
| LambertIIe ->
let utmref = LL.lambertIIe_of georef in
LL.of_lambertIIe (LL.lbt_add utmref (wx, -.wy))
| Mercator ->
let mlref = LL.mercator_lat georef.LL.posn_lat in
let ml = mlref -. wy /. mercator_coeff in
let lat = LL.inv_mercator_lat ml
and long = wx /. mercator_coeff +. georef.LL.posn_long in
{ LL.posn_lat = lat; posn_long = long }
| _ -> failwith "#of_world : unknown projection"
end
| None -> failwith "#of_world : no georef"