gistools/proj/project/
mod.rs1pub mod aea;
3pub mod aeqd;
5pub mod airy;
7pub mod bonne;
9pub mod cass;
11pub mod cea;
13pub mod eqc;
15pub mod eqdc;
17pub mod eqearth;
19pub mod gnom;
21pub mod goode;
23pub mod gstmerc;
25pub mod krovak;
27pub mod labrd;
29pub mod laea;
31pub mod lcc;
33pub mod lcca;
35pub mod merc;
37pub mod mgrs;
39pub mod mill;
41pub mod moll;
43pub mod nzmg;
45pub mod ocea;
47pub mod oea;
49pub mod omerc;
51pub mod ortho;
53pub mod poly;
55pub mod robin;
57pub mod sinu;
59pub mod somerc;
61pub mod stere;
63pub mod sterea;
65pub mod tcc;
67pub mod tcea;
69pub mod tmerc;
71pub mod vandg;
73
74use super::{CoordinateStep, DatumType, Proj, Step, TransformCoordinates};
75pub use aea::*;
76pub use aeqd::*;
77pub use airy::*;
78use alloc::rc::Rc;
79pub use bonne::*;
80pub use cass::*;
81pub use cea::*;
82use core::cell::RefCell;
83pub use eqc::*;
84pub use eqdc::*;
85pub use eqearth::*;
86pub use gnom::*;
87pub use goode::*;
88pub use gstmerc::*;
89pub use krovak::*;
90pub use labrd::*;
91pub use laea::*;
92pub use lcc::*;
93pub use lcca::*;
94pub use merc::*;
95pub use mgrs::*;
96pub use mill::*;
97pub use moll::*;
98pub use nzmg::*;
99pub use ocea::*;
100pub use oea::*;
101pub use omerc::*;
102pub use ortho::*;
103pub use poly::*;
104pub use robin::*;
105pub use sinu::*;
106pub use somerc::*;
107pub use stere::*;
108pub use sterea::*;
109pub use tcc::*;
110pub use tcea::*;
111pub use tmerc::*;
112pub use vandg::*;
113
114pub trait ProjectCoordinates {
116 fn code(&self) -> i64;
118 fn name(&self) -> &'static str;
120 fn names() -> &'static [&'static str];
123 fn datum_type() -> u8 {
125 DatumType::NoDatum as u8
126 }
127}
128
129pub type LonLatProjection = BaseProjection;
131
132#[derive(Debug, Default, Clone, PartialEq)]
134pub struct BaseProjection {}
135impl BaseProjection {
136 pub fn to_step() -> Step {
138 let base_proj = BaseProjection {};
139 base_proj.into()
140 }
141}
142impl ProjectCoordinates for BaseProjection {
143 fn code(&self) -> i64 {
144 0
145 }
146 fn name(&self) -> &'static str {
147 "longlat"
148 }
149 fn names() -> &'static [&'static str] {
150 &["longlat", "identity"]
151 }
152}
153impl CoordinateStep for BaseProjection {
154 fn new(_proj: Rc<RefCell<Proj>>) -> Self {
155 BaseProjection {}
156 }
157 fn forward<P: TransformCoordinates>(&self, p: &mut P) {
160 p.set_x(p.lam().to_degrees());
161 p.set_y(p.phi().to_degrees());
162 }
163 fn inverse<P: TransformCoordinates>(&self, p: &mut P) {
166 p.set_lam(p.x().to_radians());
167 p.set_phi(p.y().to_radians());
168 }
169}
170impl From<BaseProjection> for Step {
171 fn from(p: BaseProjection) -> Step {
172 Step::Base(p.into())
173 }
174}