Skip to main content

target_match/
lib.rs

1//! Identify which catalogued sky objects a telescope frame covers, given a
2//! pointing (right ascension / declination) and a field of view (derived from
3//! optics, or supplied directly).
4//!
5//! A caller-supplied set of catalogue objects is ranked by angular separation
6//! from the pointing; objects inside the frame's membership shape are flagged.
7//! Matching uses sky position only — a designation may ride along on a result
8//! for display, but it never influences the match.
9//!
10//! The crate holds no catalogue data and performs no I/O. A consumer supplies
11//! its own objects — from a database, a file, a name resolver, or a hand-built
12//! list — by implementing the [`matcher`] module's `SkyObject` trait.
13//!
14//! Coordinate and angle types come from the [`skymath`] crate and appear
15//! directly in this crate's signatures: construct positions with
16//! [`skymath::Equatorial`] and angles with [`skymath::Angle`]. The crate is
17//! re-exported as `target_match::skymath` so consumers can name a
18//! version-matched `skymath` without a separate dependency entry.
19//!
20//! # Modules
21//!
22//! - [`optics`] — plate scale and field-of-view geometry from focal length,
23//!   pixel size (x/y), binning (x/y), and sensor dimensions — or a directly
24//!   supplied pixel scale / field of view — plus the search-radius policies.
25//! - [`matcher`] — the `SkyObject` input trait, match constraints (radius,
26//!   rectangular field of view, nearest-N), and deterministic ranking.
27//!
28//! # Example
29//!
30//! ```
31//! use skymath::{Angle, Equatorial, ParseMode};
32//! use target_match::{rank, Constraint, Field, Optics, RadiusPolicy, SkyObject};
33//!
34//! struct Target { name: &'static str, ra: f64, dec: f64 }
35//! impl SkyObject for Target {
36//!     fn position(&self) -> Equatorial {
37//!         Equatorial::j2000(Angle::from_degrees(self.ra), Angle::from_degrees(self.dec)).unwrap()
38//!     }
39//! }
40//!
41//! let catalog = [
42//!     Target { name: "M 31",  ra: 10.6847, dec: 41.2688 },
43//!     Target { name: "M 33",  ra: 23.4621, dec: 30.6599 },
44//! ];
45//! let pointing = Equatorial::parse_j2000("00:42:44.3", "+41:16:09", ParseMode::Strict).unwrap();
46//! let field = Field::from_optics(Optics {
47//!     focal_mm: 800.0, pixel_um: (3.76, 3.76), binning: (1, 1), pixels: (6248, 4176),
48//! }).unwrap();
49//!
50//! let hits = rank(pointing, &catalog, Constraint::within(&field, RadiusPolicy::Circumscribed).nearest_one());
51//! assert_eq!(hits[0].object.name, "M 31");
52//! ```
53
54pub mod error;
55pub mod matcher;
56pub mod optics;
57
58/// The astronomy-math crate whose types appear in this crate's public API,
59/// re-exported so consumers can use the exact version target-match was built
60/// against.
61pub use skymath;
62
63pub use error::{Error, Result};
64pub use matcher::{
65    is_framed, rank, Constraint, Match, Matcher, Membership, Offset, Query, SkyObject,
66};
67pub use optics::{
68    Field, Optics, RadiusPolicy, ARCSEC_PER_DEGREE, ARCSEC_PER_RADIAN, DEFAULT_FALLBACK_RADIUS,
69};