1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//! Contains the implementation of [`Coordinates`].

use postgis_diesel::types::Point;

use super::Coordinates;

/// `PostGIS` identifier for latitude/longitude coordinate system.
const COORDINATE_SYSTEM: u32 = 4326;

impl From<Point> for Coordinates {
    fn from(point: Point) -> Self {
        Self {
            latitude: point.y,
            longitude: point.x,
        }
    }
}

impl From<Coordinates> for Point {
    fn from(coordinates: Coordinates) -> Self {
        Self {
            x: coordinates.longitude,
            y: coordinates.latitude,
            srid: Some(COORDINATE_SYSTEM),
        }
    }
}