geo_core/
point.rs

1#![allow(dead_code)]
2use crate::geometry::Geometry;
3use crate::latlng::LatLng;
4
5#[derive(Copy, Clone)]
6pub struct Point {
7    pub x: f64,
8    pub y: f64,
9}
10
11impl Point {
12    fn new(x: f64, y: f64) -> Point {
13        Point { x, y }
14    }
15
16    fn new_lat_lng(lat_lng: LatLng) -> Point {
17        Point {
18            x: lat_lng.lng,
19            y: lat_lng.lat,
20        }
21    }
22
23    fn add(&self, n: Point) -> Point {
24        Point {
25            x: self.x + n.x,
26            y: self.y + n.y,
27        }
28    }
29
30    fn subtract(&self, n: Point) -> Point {
31        Point {
32            x: self.x - n.x,
33            y: self.y - n.y,
34        }
35    }
36}
37
38impl Geometry for Point {
39    fn describe(&self) -> String {
40        String::from("point")
41    }
42}