···11+open Js_of_ocaml
22+33+let set_result id text =
44+ let doc = Dom_html.document in
55+ Js.Opt.iter (doc##getElementById (Js.string id)) (fun el ->
66+ el##.textContent := Js.some (Js.string text))
77+88+let () =
99+ try
1010+ (* Test 1: fetch a single scales file *)
1111+ let url = "https://dl2.geotessera.org/v1/global_0.1_degree_representation/2024/grid_0.15_52.05/grid_0.15_52.05_scales.npy" in
1212+ let data = Geotessera_jsoo.fetch url in
1313+ let len = String.length data in
1414+ set_result "fetch-result"
1515+ (if len > 100 then Printf.sprintf "OK: %d bytes" len
1616+ else Printf.sprintf "FAIL: only %d bytes" len);
1717+1818+ (* Test 2: parse the fetched npy *)
1919+ let npy = Npy.of_string data |> Result.get_ok in
2020+ let shape = Npy.shape npy in
2121+ set_result "parse-result"
2222+ (Printf.sprintf "OK: shape %s"
2323+ (String.concat "x" (Array.to_list (Array.map string_of_int shape))));
2424+2525+ (* Test 3: fetch_mosaic on a single-tile bbox *)
2626+ let bbox = Geotessera.{ min_lon = 0.1; min_lat = 52.0; max_lon = 0.2; max_lat = 52.1 } in
2727+ let mosaic, h, w = Geotessera_jsoo.fetch_mosaic ~year:2024 bbox in
2828+ set_result "mosaic-result"
2929+ (Printf.sprintf "OK: %d rows x %d cols, %dx%d" mosaic.rows mosaic.cols h w);
3030+3131+ set_result "status" "ALL PASSED"
3232+ with exn ->
3333+ set_result "status" (Printf.sprintf "FAILED: %s" (Printexc.to_string exn))