pub struct Catalog { /* private fields */ }Expand description
A catalog of stars
The catalog contains an indexed (and possibly named) list of stars, which can be searched by id, name, or geometrically
§Design rationale for Vec<Subcube>
There are roughly 4,000 (3769 in fact) subcubes used out of 32^3 (i.e. 32,768) by a star catalog with an ELE_PER_SIDE of 32
Purely using a vec of 32^3 vecs is 1MB of storage, plus subcube contents
A hash map from subcube to vec with 4k entries used is probably 64kB plus 128kB for the vecs themselves; access is slower though.
Implementations§
Source§impl Catalog
impl Catalog
pub fn load_catalog<P: AsRef<Path>>( catalog_filename: P, magnitude: f32, ) -> Result<Self, Error>
Sourcepub fn add_star(&mut self, star: Star)
pub fn add_star(&mut self, star: Star)
Add a star to the catalog
This also clears any derived data and marks the catalog as usorted
Sourcepub fn add_name<I: Into<String>>(&mut self, index: CatalogIndex, name: I)
pub fn add_name<I: Into<String>>(&mut self, index: CatalogIndex, name: I)
Add a name for a single star in the catalog; the star must have been found by ID
The catalog must have been sorted beforehand
Sourcepub fn add_names<I: Into<String> + Clone>(
&mut self,
id_names: &[(usize, I)],
ignore_not_found: bool,
) -> Result<(), Error>
pub fn add_names<I: Into<String> + Clone>( &mut self, id_names: &[(usize, I)], ignore_not_found: bool, ) -> Result<(), Error>
Add names for a set of stars in the catalog, from their IDs
The catalog must have been sorted beforehand
Sourcepub fn retain<F>(&mut self, f: F)where
F: StarFilterFn,
pub fn retain<F>(&mut self, f: F)where
F: StarFilterFn,
Retain stars that match a certain criterion; the rest are dropped
This should be invoked prior to any stars being named; it also clears the derived data (e.g. geometric searching will not be allowed until a derive_data() call is invoked)
Source§impl Catalog
impl Catalog
pub fn clear_filter(&mut self) -> StarFilter
pub fn filter(&self) -> &StarFilter
pub fn set_filter(&mut self, f: StarFilter)
pub fn add_filter(&mut self, f: StarFilter)
Source§impl Catalog
impl Catalog
Sourcepub fn derive_data(&mut self)
pub fn derive_data(&mut self)
Derive data from the stars in the catalog - such as what stars are in which subcubes
This does not impact the sorting - indeed, usually the catalog is sorted before the data is derived.
Source§impl Catalog
impl Catalog
Sourcepub fn is_filtered(&self, star: &Star, n: usize) -> bool
pub fn is_filtered(&self, star: &Star, n: usize) -> bool
Run all the filters
Sourcepub fn find_sorted(&self, id: usize) -> Option<CatalogIndex>
pub fn find_sorted(&self, id: usize) -> Option<CatalogIndex>
Find a star from its ID
The catalog must have been sorted beforehand
Sourcepub fn find_name(&self, name: &str) -> Option<CatalogIndex>
pub fn find_name(&self, name: &str) -> Option<CatalogIndex>
Find a star from its name
Sourcepub fn find_id_or_name(&self, s: &str) -> Result<CatalogIndex, Error>
pub fn find_id_or_name(&self, s: &str) -> Result<CatalogIndex, Error>
Find a star from a string, which might be an id or a name
Sourcepub fn closest_to_dir<I>(
&self,
subcube_iter: I,
vector: &[f64; 3],
) -> Option<(f64, CatalogIndex)>
pub fn closest_to_dir<I>( &self, subcube_iter: I, vector: &[f64; 3], ) -> Option<(f64, CatalogIndex)>
Find the closest star in the catalog given a direction vector
This requires the catalog to have had its data derived beforehand
Sourcepub fn closest_to_ra_de<I>(
&self,
subcube_iter: I,
ra: f64,
de: f64,
) -> Option<(f64, CatalogIndex)>
pub fn closest_to_ra_de<I>( &self, subcube_iter: I, ra: f64, de: f64, ) -> Option<(f64, CatalogIndex)>
Find the closest star in the catalog given an RA and DE in radians
This requires the catalog to have had its data derived beforehand
Sourcepub fn find_stars_around(
&self,
vector: &[f64; 3],
max_angle: f64,
) -> Vec<CatalogIndex>
pub fn find_stars_around( &self, vector: &[f64; 3], max_angle: f64, ) -> Vec<CatalogIndex>
Find stars within a certain angle around a vector
Needs data to have been derived for the Catalog
Sourcepub fn find_star_triangles<I>(
&self,
subcube_iter: I,
angles_to_find: &[f64; 3],
max_angle_delta: f64,
) -> Vec<(CatalogIndex, CatalogIndex, CatalogIndex)>
pub fn find_star_triangles<I>( &self, subcube_iter: I, angles_to_find: &[f64; 3], max_angle_delta: f64, ) -> Vec<(CatalogIndex, CatalogIndex, CatalogIndex)>
Find a triangle of stars given the visual angles between them
Needs data to have been derived for the Catalog
Source§impl Catalog
impl Catalog
pub fn iter_stars(&self) -> StarIter<'_>
Sourcepub fn iter_within_subcubes<I>(&self, subcube_iter: I) -> StarSubcubeIter<'_, I>
pub fn iter_within_subcubes<I>(&self, subcube_iter: I) -> StarSubcubeIter<'_, I>
Iterate over all the stars in the catalog within a set of subcubes provide by an iterator