Skip to main content

geometry_kernel/
kernel.rs

1use crate::buffer::BufferOptions;
2use crate::error::Result;
3use crate::precision::PrecisionModel;
4use crate::types::{Coord, LineString, MultiPolygon, Polygon};
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum KernelBackend {
8    PureRust,
9    GeosReference,
10}
11
12pub trait GeometryKernel {
13    fn backend(&self) -> KernelBackend;
14    fn precision(&self) -> PrecisionModel;
15    fn canonicalize_polygon(&self, polygon: &Polygon) -> Polygon;
16    fn polygon_area(&self, polygon: &Polygon) -> Result<f64>;
17    fn largest_polygon(&self, multi_polygon: &MultiPolygon) -> Result<Option<Polygon>>;
18    fn buffer_polygon(
19        &self,
20        polygon: &Polygon,
21        distance: f64,
22        options: BufferOptions,
23    ) -> Result<MultiPolygon>;
24    fn line_buffer(
25        &self,
26        line: &LineString,
27        distance: f64,
28        options: BufferOptions,
29    ) -> Result<MultiPolygon>;
30    fn intersection(&self, subject: &MultiPolygon, clip: &MultiPolygon) -> Result<MultiPolygon>;
31    fn difference(&self, subject: &MultiPolygon, clip: &MultiPolygon) -> Result<MultiPolygon>;
32    fn line_polygon_intersections(
33        &self,
34        line: &LineString,
35        polygon: &Polygon,
36    ) -> Result<Vec<Coord>>;
37}