geodesy/
lib.rs

1#![doc = include_str!("../README.md")]
2
3/// The bread-and-butter, shrink-wrapped and ready to use
4pub mod prelude {
5    pub use crate::coord::*;
6    pub use crate::ctx::*;
7    pub use crate::ellps::*;
8    pub use crate::Error;
9}
10
11/// Extended prelude for authoring Contexts and InnerOp modules
12pub mod authoring {
13    pub use crate::grd::*;
14    pub use crate::math::*;
15    pub use crate::ops::*;
16    pub use crate::parse::*;
17    pub use crate::prelude::*;
18
19    // All new contexts are supposed to support these
20    pub use crate::context::BUILTIN_ADAPTORS;
21
22    // Map projection characteristics
23    pub use crate::math::jacobian::Factors;
24    pub use crate::math::jacobian::Jacobian;
25
26    // External material
27    pub use log::debug;
28    pub use log::error;
29    pub use log::info;
30    pub use log::trace;
31    pub use log::warn;
32    pub use std::collections::BTreeMap;
33}
34
35/// Context related elements
36pub mod ctx {
37    pub use crate::context::minimal::Minimal;
38    #[cfg(feature = "with_plain")]
39    pub use crate::context::plain::Plain;
40    pub use crate::context::Context;
41    pub use crate::op::OpHandle;
42    pub use crate::Direction;
43    pub use crate::Direction::Fwd;
44    pub use crate::Direction::Inv;
45}
46
47/// Ellipsoid related elements
48pub mod ellps {
49    pub use crate::ellipsoid::biaxial::Ellipsoid;
50    pub use crate::ellipsoid::geocart::GeoCart;
51    pub use crate::ellipsoid::geodesics::Geodesics;
52    pub use crate::ellipsoid::gravity::Gravity;
53    pub use crate::ellipsoid::latitudes::Latitudes;
54    pub use crate::ellipsoid::meridians::Meridians;
55    pub use crate::ellipsoid::triaxial::TriaxialEllipsoid;
56    pub use crate::ellipsoid::EllipsoidBase;
57}
58
59/// Coordinate related elements
60pub mod coord {
61    // Coordinate types
62    pub use crate::coordinate::coor2d::Coor2D;
63    pub use crate::coordinate::coor32::Coor32;
64    pub use crate::coordinate::coor3d::Coor3D;
65    pub use crate::coordinate::coor4d::Coor4D;
66    // Coordinate traits
67    pub use crate::coordinate::set::CoordinateSet;
68    pub use crate::coordinate::tuple::CoordinateTuple;
69    pub use crate::coordinate::AngularUnits;
70    pub use crate::coordinate::CoordinateMetadata;
71    pub use crate::math::angular;
72}
73
74/// Elements for building operators
75mod ops {
76    pub use crate::inner_op::InnerOp;
77    pub use crate::inner_op::OpConstructor;
78    pub use crate::op::Op;
79    pub use crate::op::OpDescriptor;
80    pub use crate::op::OpParameter;
81    pub use crate::op::ParsedParameters;
82    pub use crate::op::RawParameters;
83}
84
85/// Elements for handling grids
86mod grd {
87    pub use crate::grid::grids_at;
88    pub use crate::grid::ntv2::Ntv2Grid;
89    pub use crate::grid::BaseGrid;
90    pub use crate::grid::Grid;
91}
92
93/// Elements for parsing both Geodesy and PROJ syntax
94mod parse {
95    // Tokenizing Rust Geodesy operations
96    pub use crate::token::Tokenize;
97    // PROJ interoperability
98    pub use crate::token::parse_proj;
99}
100
101use thiserror::Error;
102/// The *Rust Geodesy* error messaging enumeration. Badly needs reconsideration
103#[derive(Error, Debug)]
104pub enum Error {
105    #[error("i/o error")]
106    Io(#[from] std::io::Error),
107
108    #[error("General error: '{0}'")]
109    General(&'static str),
110
111    #[error("Syntax error: '{0}'")]
112    Syntax(String),
113
114    #[error("{0}: {1}")]
115    Operator(&'static str, &'static str),
116
117    #[error("Invalid header (expected {expected:?}, found {found:?})")]
118    InvalidHeader { expected: String, found: String },
119    #[error("{message:?} (expected {expected:?}, found {found:?})")]
120    Unexpected {
121        message: String,
122        expected: String,
123        found: String,
124    },
125
126    #[error("Operator '{0}' not found{1}")]
127    NotFound(String, String),
128
129    #[error("Recursion too deep for '{0}', at {1}")]
130    Recursion(String, String),
131
132    #[error("Attempt to invert a non-invertible item: '{0}'")]
133    NonInvertible(String),
134
135    #[error("Missing required parameter '{0}'")]
136    MissingParam(String),
137
138    #[error("Malformed value for parameter '{0}': '{1}'")]
139    BadParam(String, String),
140
141    #[error("Unsupported: {0}")]
142    Unsupported(String),
143
144    #[error("Invalid: {0}")]
145    Invalid(String),
146
147    #[error("UTF8 error")]
148    Utf8Error(#[from] std::str::Utf8Error),
149
150    #[error("Unknown")]
151    Unknown,
152}
153
154/// `Fwd`: Indicate that a two-way operator, function, or method,
155/// should run in the *forward* direction.
156/// `Inv`: Indicate that a two-way operator, function, or method,
157/// should run in the *inverse* direction.
158#[derive(Debug, PartialEq, Eq)]
159pub enum Direction {
160    Fwd,
161    Inv,
162}
163
164mod bibliography;
165mod context;
166mod coordinate;
167mod ellipsoid;
168mod grid;
169mod inner_op;
170mod math;
171mod op;
172mod token;
173
174/// Some generic coordinates for test composition
175#[cfg(test)]
176mod test_data {
177    pub fn coor4d() -> [crate::coord::Coor4D; 2] {
178        let copenhagen = crate::coord::Coor4D::raw(55., 12., 0., 0.);
179        let stockholm = crate::coord::Coor4D::raw(59., 18., 0., 0.);
180        [copenhagen, stockholm]
181    }
182
183    pub fn coor3d() -> [crate::coord::Coor3D; 2] {
184        let copenhagen = crate::coord::Coor3D::raw(55., 12., 0.);
185        let stockholm = crate::coord::Coor3D::raw(59., 18., 0.);
186        [copenhagen, stockholm]
187    }
188
189    pub fn coor2d() -> [crate::coord::Coor2D; 2] {
190        let copenhagen = crate::coord::Coor2D::raw(55., 12.);
191        let stockholm = crate::coord::Coor2D::raw(59., 18.);
192        [copenhagen, stockholm]
193    }
194
195    pub fn coor32() -> [crate::coord::Coor32; 2] {
196        let copenhagen = crate::coord::Coor32::raw(55., 12.);
197        let stockholm = crate::coord::Coor32::raw(59., 18.);
198        [copenhagen, stockholm]
199    }
200}
201
202// ---- Documentation: Bibliography ----
203#[cfg(doc)]
204pub use crate::bibliography::Bibliography;