geo-core 0.1.4

Common tools for working with spatial data
Documentation
#![allow(dead_code)]
use crate::geometry::Geometry;
use crate::latlng::LatLng;

#[derive(Copy, Clone)]
pub struct Point {
    pub x: f64,
    pub y: f64,
}

impl Point {
    fn new(x: f64, y: f64) -> Point {
        Point { x, y }
    }

    fn new_lat_lng(lat_lng: LatLng) -> Point {
        Point {
            x: lat_lng.lng,
            y: lat_lng.lat,
        }
    }

    fn add(&self, n: Point) -> Point {
        Point {
            x: self.x + n.x,
            y: self.y + n.y,
        }
    }

    fn subtract(&self, n: Point) -> Point {
        Point {
            x: self.x - n.x,
            y: self.y - n.y,
        }
    }
}

impl Geometry for Point {
    fn describe(&self) -> String {
        String::from("point")
    }
}