mirror of https://codeberg.org/topola/topola.git
20 lines
413 B
Rust
20 lines
413 B
Rust
use enum_dispatch::enum_dispatch;
|
|
use geo::{Centroid, Contains, Point, Polygon};
|
|
|
|
use crate::geometry::shape::ShapeTrait;
|
|
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct PolyShape {
|
|
pub polygon: Polygon,
|
|
}
|
|
|
|
impl ShapeTrait for PolyShape {
|
|
fn center(&self) -> Point {
|
|
self.polygon.centroid().unwrap()
|
|
}
|
|
|
|
fn contains_point(&self, p: Point) -> bool {
|
|
self.polygon.contains(&p)
|
|
}
|
|
}
|