Satellite pass prediction and contact window computation
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-contact: enable MDX on lib/contact.mli, fix broken doc example

Run mdx on lib/contact.mli so the {[ ... ]} odoc block now type-checks.

The example referenced a free `tle_str`, swallowed parse errors with
`Result.get_ok`, passed `~duration_days:3` (an int) where the
signature expects `float`, and accessed `p.aos_epoch` etc. on an
unannotated record (which only resolves with the right type in
scope).

Wrapped in `let predict_la_passes tle_str = ...` so the user supplies
the TLE, surfaced the parse error via `failwith` with a real
`Sgp4.pp_error`, used `~duration_days:3.0`, and annotated
`(p : Contact.pass)` for unambiguous field access.

+19 -9
+15 -9
lib/contact.mli
··· 3 3 {2 Quick start} 4 4 5 5 {[ 6 - (* Predict ISS passes over Los Angeles for the next 3 days *) 7 - let tle = Sgp4.parse_tle_string tle_str |> Result.get_ok in 8 - let la = Contact.ground_station ~lat:34.05 ~lon:(-118.25) ~alt:0.071 in 9 - let passes = Contact.predict tle la ~duration_days:3 in 10 - List.iter 11 - (fun p -> 12 - Printf.printf "%s max_el=%.1f deg dur=%.0fs\n" p.aos_epoch 13 - p.max_elevation p.duration) 14 - passes 6 + (* Predict ISS passes over Los Angeles. Provide a fresh TLE -- TLEs go 7 + stale after about a week, so the example reads it from input. *) 8 + let predict_la_passes tle_str = 9 + let tle = 10 + match Sgp4.parse_tle_string tle_str with 11 + | Ok t -> t 12 + | Error e -> Format.kasprintf failwith "TLE parse: %a" Sgp4.pp_error e 13 + in 14 + let la = Contact.ground_station ~lat:34.05 ~lon:(-118.25) ~alt:0.071 in 15 + let passes = Contact.predict tle la ~duration_days:3.0 in 16 + List.iter 17 + (fun (p : Contact.pass) -> 18 + Printf.printf "%s max_el=%.1f deg dur=%.0fs\n" p.aos_epoch 19 + p.max_elevation p.duration) 20 + passes 15 21 ]} *) 16 22 17 23 (** {1 Types} *)
+4
lib/dune
··· 2 2 (name contact) 3 3 (public_name contact) 4 4 (libraries sgp4 coordinate vec3 ptime fmt)) 5 + 6 + (mdx 7 + (files contact.mli) 8 + (libraries contact sgp4 fmt))