use crate::error::ChartError;
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Longitude(f64);
impl Longitude {
pub fn new(degrees: f64) -> Result<Self, ChartError> {
if !(-180.0..=180.0).contains(°rees) {
return Err(ChartError::LongitudeOutOfRange(degrees));
}
Ok(Self(degrees))
}
#[must_use]
pub fn degrees(self) -> f64 {
self.0
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Latitude(f64);
impl Latitude {
pub fn new(degrees: f64) -> Result<Self, ChartError> {
if !(-90.0..=90.0).contains(°rees) {
return Err(ChartError::LatitudeOutOfRange(degrees));
}
Ok(Self(degrees))
}
#[must_use]
pub fn degrees(self) -> f64 {
self.0
}
}
#[allow(missing_docs)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum EventType {
Unspecified,
Male,
Female,
Event,
Horary,
}
impl From<u8> for EventType {
fn from(n: u8) -> Self {
match n {
1 => Self::Male,
2 => Self::Female,
3 => Self::Event,
4 => Self::Horary,
_ => Self::Unspecified,
}
}
}
#[allow(missing_docs)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum HouseSystem {
Campanus,
Koch,
Meridian,
Morinus,
Placidus,
Porphyry,
Regiomontanus,
Topocentric,
Equal,
ZeroAries,
SolarSign,
WholeSign,
HinduBhava,
Alcabitius,
Other(u8),
}
impl From<u8> for HouseSystem {
fn from(n: u8) -> Self {
match n {
1 => Self::Campanus,
2 => Self::Koch,
3 => Self::Meridian,
4 => Self::Morinus,
5 => Self::Placidus,
6 => Self::Porphyry,
7 => Self::Regiomontanus,
8 => Self::Topocentric,
9 => Self::Equal,
10 => Self::ZeroAries,
11 => Self::SolarSign,
26 => Self::WholeSign,
27 => Self::HinduBhava,
28 => Self::Alcabitius,
other => Self::Other(other),
}
}
}
#[allow(missing_docs)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Zodiac {
Tropical,
FaganAllen,
Lahiri,
DeLuce,
Raman,
UshaShashi,
Krishnamurti,
DjwhalKhul,
Draconic,
Svp,
SriYukteswar,
JnBhasin,
LarryEly,
TakraI,
TakraII,
SundaraRajan,
ShillPond,
Other(u8),
}
impl From<u8> for Zodiac {
fn from(n: u8) -> Self {
match n {
1 => Self::Tropical,
2 => Self::FaganAllen,
3 => Self::Lahiri,
4 => Self::DeLuce,
5 => Self::Raman,
6 => Self::UshaShashi,
7 => Self::Krishnamurti,
8 => Self::DjwhalKhul,
9 => Self::Draconic,
10 => Self::Svp,
11 => Self::SriYukteswar,
12 => Self::JnBhasin,
13 => Self::LarryEly,
14 => Self::TakraI,
15 => Self::TakraII,
16 => Self::SundaraRajan,
17 => Self::ShillPond,
other => Self::Other(other),
}
}
}
#[allow(missing_docs)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CoordinateSystem {
Geocentric,
Heliocentric,
}
impl From<u8> for CoordinateSystem {
fn from(n: u8) -> Self {
match n {
2 => Self::Heliocentric,
_ => Self::Geocentric,
}
}
}
#[allow(missing_docs)]
#[derive(Debug, Clone, PartialEq)]
pub struct SubChart {
pub name: String,
pub city: Option<String>,
pub region: Option<String>,
pub longitude: Longitude,
pub latitude: Latitude,
pub year: i16,
pub month: u8,
pub day: u8,
pub hour: u8,
pub minute: u8,
pub second: u8,
pub tz_offset_hours: f64,
pub tz_abbreviation: Option<String>,
pub is_lmt: bool,
pub notes: Option<String>,
}
#[allow(missing_docs)]
#[derive(Debug, Clone, PartialEq)]
pub struct Chart {
pub name: String,
pub secondary_name: Option<String>,
pub city: Option<String>,
pub region: Option<String>,
pub longitude: Longitude,
pub latitude: Latitude,
pub year: i16,
pub month: u8,
pub day: u8,
pub hour: u8,
pub minute: u8,
pub second: u8,
pub tz_offset_hours: f64,
pub tz_abbreviation: Option<String>,
pub is_lmt: bool,
pub event_type: EventType,
pub source_rating: Option<String>,
pub house_system: HouseSystem,
pub zodiac: Zodiac,
pub coordinate_system: CoordinateSystem,
pub sub_charts: Vec<SubChart>,
pub notes: Option<String>,
}