diff --git a/sw/lib/ocaml/mapCanvas.ml b/sw/lib/ocaml/mapCanvas.ml index e51a2035a3..8a9fb5f02d 100644 --- a/sw/lib/ocaml/mapCanvas.ml +++ b/sw/lib/ocaml/mapCanvas.ml @@ -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" diff --git a/sw/lib/ocaml/pprz.ml b/sw/lib/ocaml/pprz.ml index dc9fc7c5ee..785c8bbd1b 100644 --- a/sw/lib/ocaml/pprz.ml +++ b/sw/lib/ocaml/pprz.ml @@ -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