+ let is_rect l =
+ try List.assoc "shape" l = "rect" with Not_found -> false
+ in
+ let is_poly l =
+ try List.assoc "shape" l = "poly" with Not_found -> false
+ in
+ let rectify l =
+ List.map (
+ function "coords",c ->
+ let xys = HExtlib.split ~sep:' ' c in
+ let xys =
+ List.map
+ (fun s ->
+ match HExtlib.split ~sep:',' s with
+ | [x; y] -> int_of_string x, int_of_string y
+ | _ -> assert false)
+ xys
+ in
+ let xs, ys = List.split xys in
+ let max_x = string_of_int (List.fold_left max 0 xs) in
+ let max_y = string_of_int (List.fold_left max 0 ys) in
+ let min_x = string_of_int (List.fold_left min max_int xs) in
+ let min_y = string_of_int (List.fold_left min max_int ys) in
+ "coords", min_x^","^min_y^" "^max_x^","^max_y
+ | x -> x) l
+ in