Struct geometry_rs::Polygon
source · pub struct Polygon { /* private fields */ }
Implementations§
source§impl Polygon
impl Polygon
sourcepub fn contains_point(&self, p: Point) -> bool
pub fn contains_point(&self, p: Point) -> bool
Do point-in-polygon search.
sourcepub fn new(exterior: Vec<Point>, holes: Vec<Vec<Point>>) -> Polygon
pub fn new(exterior: Vec<Point>, holes: Vec<Vec<Point>>) -> Polygon
Create a new Polygon instance from exterior and holes.
Please note that set with_index
to true will increase performance, but requires more memory.
See #4 for more details.
Example:
use std::vec;
use geometry_rs;
let poly = geometry_rs::Polygon::new(
vec![
geometry_rs::Point {
x: 90.48826291293898,
y: 45.951129815858565,
},
geometry_rs::Point {
x: 90.48826291293898,
y: 27.99437617512571,
},
geometry_rs::Point {
x: 122.83201291294,
y: 27.99437617512571,
},
geometry_rs::Point {
x: 122.83201291294,
y: 45.951129815858565,
},
geometry_rs::Point {
x: 90.48826291293898,
y: 45.951129815858565,
},
],
vec![],
);
let p_out = geometry_rs::Point {
x: 130.74216916294148,
y: 37.649011392900306,
};
print!("{:?}\n", poly.contains_point(p_out));
let p_in = geometry_rs::Point {
x: 99.9804504129416,
y: 39.70716466970461,
};
print!("{:?}\n", poly.contains_point(p_in));
pub fn new_with_rtree_index_opt( exterior: Vec<Point>, holes: Vec<Vec<Point>>, with_index: bool ) -> Polygon
Auto Trait Implementations§
impl RefUnwindSafe for Polygon
impl Send for Polygon
impl Sync for Polygon
impl Unpin for Polygon
impl UnwindSafe for Polygon
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more