utiles_core/
projection.rs1use crate::UtilesCoreError;
3use serde::{Deserialize, Serialize};
4use std::fmt;
5
6#[derive(Debug, Serialize, Deserialize)]
8pub enum Projection {
9 Geographic,
11
12 Mercator,
14}
15
16impl TryFrom<String> for Projection {
17 type Error = UtilesCoreError;
18
19 fn try_from(value: String) -> Result<Self, Self::Error> {
20 match value.to_lowercase().as_str() {
21 "geographic" => Ok(Projection::Geographic),
22 "mercator" => Ok(Projection::Mercator),
23 _ => Err(UtilesCoreError::InvalidProjection(value)),
24 }
25 }
26}
27
28impl fmt::Display for Projection {
29 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30 match self {
31 Projection::Geographic => write!(f, "geographic"),
32 Projection::Mercator => write!(f, "mercator"),
33 }
34 }
35}