error handling

This commit is contained in:
Pascal Brisset
2006-04-20 08:01:40 +00:00
parent c227c70033
commit 7b27f3f47e
2 changed files with 27 additions and 17 deletions
+20 -17
View File
@@ -176,23 +176,26 @@ class basic_widget = fun ?(height=800) ?width ?(projection = Mercator) ?georef (
method world_of = fun wgs84 ->
match georef with
Some georef -> begin
match projection with
UTM ->
let utmref = LL.utm_of LL.WGS84 georef
and utm = LL.utm_of LL.WGS84 wgs84 in
let (wx, y) = LL.utm_sub utm utmref in
(wx, -.y)
| Mercator ->
let mlref = LL.mercator_lat georef.LL.posn_lat
and ml = LL.mercator_lat wgs84.LL.posn_lat in
let xw = (wgs84.LL.posn_long -. georef.LL.posn_long) *. mercator_coeff
and yw = -. (ml -. mlref) *. mercator_coeff in
(xw, yw)
| 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)
try
match projection with
UTM ->
let utmref = LL.utm_of LL.WGS84 georef
and utm = LL.utm_of LL.WGS84 wgs84 in
let (wx, y) = LL.utm_sub utm utmref in
(wx, -.y)
| Mercator ->
let mlref = LL.mercator_lat georef.LL.posn_lat
and ml = LL.mercator_lat wgs84.LL.posn_lat in
let xw = (wgs84.LL.posn_long -. georef.LL.posn_long) *. mercator_coeff
and yw = -. (ml -. mlref) *. mercator_coeff in
(xw, yw)
| 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)
with
_ -> (0., 0.) (** Don't want to break everything with bad coordinates *)
end
| None -> failwith "#world_of : no georef"
+7
View File
@@ -393,6 +393,13 @@ module Messages(Class:CLASS) = struct
| [] -> invalid_arg (sprintf "Pprz.values_of_string: %s" s)
let string_of_message = fun msg values ->
(** Check that the values are compatible with this message *)
List.iter
(fun (k, _) ->
if not (List.mem_assoc k msg.fields)
then invalid_arg (sprintf "Pprz.string_of_message: unknown field '%s' in message '%s'" k msg.name))
values;
String.concat " "
(msg.name::
List.map