backend/model/dto/
coordinates_impl.rs

1//! Contains the implementation of [`Coordinates`].
2
3use postgis_diesel::types::Point;
4
5use super::Coordinates;
6
7/// `PostGIS` identifier for latitude/longitude coordinate system.
8const COORDINATE_SYSTEM: u32 = 4326;
9
10impl From<Point> for Coordinates {
11    fn from(point: Point) -> Self {
12        Self {
13            latitude: point.y,
14            longitude: point.x,
15        }
16    }
17}
18
19impl From<Coordinates> for Point {
20    fn from(coordinates: Coordinates) -> Self {
21        Self {
22            x: coordinates.longitude,
23            y: coordinates.latitude,
24            srid: Some(COORDINATE_SYSTEM),
25        }
26    }
27}