Catalog

Struct Catalog 

Source
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

Source

pub fn load_catalog<P: AsRef<Path>>( catalog_filename: P, magnitude: f32, ) -> Result<Self, Error>

Source

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

Source

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

Source

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

Source

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

Source

pub fn len(&self) -> usize

Get the number of stars in the catalog

Source

pub fn is_empty(&self) -> bool

Returns true if the catalog contains no stars

Source

pub fn is_sorted(&self) -> bool

Returns true if the catalog has been sorted (and is thus ready for names to be added)

Source§

impl Catalog

Source

pub fn clear_filter(&mut self) -> StarFilter

Source

pub fn filter(&self) -> &StarFilter

Source

pub fn set_filter(&mut self, f: StarFilter)

Source

pub fn add_filter(&mut self, f: StarFilter)

Source§

impl Catalog

Source

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

pub fn sort(&mut self)

Sort the stars so that to create the index (and hence afterwards they can be searched by id)

To do: Must remap name identifiers too

Source§

impl Catalog

Source

pub fn is_filtered(&self, star: &Star, n: usize) -> bool

Run all the filters

Source

pub fn find_sorted(&self, id: usize) -> Option<CatalogIndex>

Find a star from its ID

The catalog must have been sorted beforehand

Source

pub fn find_name(&self, name: &str) -> Option<CatalogIndex>

Find a star from its name

Source

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

Source

pub fn closest_to_dir<I>( &self, subcube_iter: I, vector: &[f64; 3], ) -> Option<(f64, CatalogIndex)>
where I: Iterator<Item = Subcube>,

Find the closest star in the catalog given a direction vector

This requires the catalog to have had its data derived beforehand

Source

pub fn closest_to_ra_de<I>( &self, subcube_iter: I, ra: f64, de: f64, ) -> Option<(f64, CatalogIndex)>
where I: Iterator<Item = Subcube>,

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

Source

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

Source

pub fn find_star_triangles<I>( &self, subcube_iter: I, angles_to_find: &[f64; 3], max_angle_delta: f64, ) -> Vec<(CatalogIndex, CatalogIndex, CatalogIndex)>
where I: Iterator<Item = Subcube>,

Find a triangle of stars given the visual angles between them

Needs data to have been derived for the Catalog

Source§

impl Catalog

Source

pub fn iter_stars(&self) -> StarIter<'_>

Source

pub fn iter_within_subcubes<I>(&self, subcube_iter: I) -> StarSubcubeIter<'_, I>
where I: Iterator<Item = Subcube>,

Iterate over all the stars in the catalog within a set of subcubes provide by an iterator

Trait Implementations§

Source§

impl Default for Catalog

Source§

fn default() -> Catalog

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Catalog

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Index<CatalogIndex> for Catalog

Source§

type Output = Star

The returned type after indexing.
Source§

fn index(&self, s: CatalogIndex) -> &Star

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<Subcube> for Catalog

Source§

type Output = Vec<CatalogIndex>

The returned type after indexing.
Source§

fn index(&self, q: Subcube) -> &Vec<CatalogIndex>

Performs the indexing (container[index]) operation. Read more
Source§

impl Serialize for Catalog

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,