mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-06 16:58:48 +08:00
error handling
This commit is contained in:
+20
-17
@@ -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"
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user