pub struct Polygon<T>where
T: CoordinateType,{
pub exterior: LineString<T>,
pub interiors: Vec<LineString<T>>,
}
Expand description
A representation of an area. Its outer boundary is represented by a LineString
that is both closed and simple
It has one exterior ring or shell, and zero or more interior rings, representing holes.
Examples
Polygons can be created from collections of Point
-like objects, such as arrays or tuples:
use geo_types::{Point, LineString, Polygon};
let poly1 = Polygon::new(vec![[0., 0.], [10., 0.]].into(), vec![]);
let poly2 = Polygon::new(vec![(0., 0.), (10., 0.)].into(), vec![]);
Fields
exterior: LineString<T>
interiors: Vec<LineString<T>>
Implementations
sourceimpl<T> Polygon<T>where
T: CoordinateType,
impl<T> Polygon<T>where
T: CoordinateType,
sourcepub fn new(exterior: LineString<T>, interiors: Vec<LineString<T>>) -> Polygon<T>
pub fn new(exterior: LineString<T>, interiors: Vec<LineString<T>>) -> Polygon<T>
Creates a new polygon.
Examples
use geo_types::{Coordinate, LineString, Polygon};
let exterior = LineString(vec![
Coordinate { x: 0., y: 0. },
Coordinate { x: 1., y: 1. },
Coordinate { x: 1., y: 0. },
Coordinate { x: 0., y: 0. },
]);
let interiors = vec![LineString(vec![
Coordinate { x: 0.1, y: 0.1 },
Coordinate { x: 0.9, y: 0.9 },
Coordinate { x: 0.9, y: 0.1 },
Coordinate { x: 0.1, y: 0.1 },
])];
let p = Polygon::new(exterior.clone(), interiors.clone());
assert_eq!(p.exterior, exterior);
assert_eq!(p.interiors, interiors);
Trait Implementations
sourceimpl<T: Clone> Clone for Polygon<T>where
T: CoordinateType,
impl<T: Clone> Clone for Polygon<T>where
T: CoordinateType,
sourceimpl<T: Debug> Debug for Polygon<T>where
T: CoordinateType,
impl<T: Debug> Debug for Polygon<T>where
T: CoordinateType,
sourceimpl<T: CoordinateType> From<Polygon<T>> for Geometry<T>
impl<T: CoordinateType> From<Polygon<T>> for Geometry<T>
sourceimpl<T: CoordinateType> From<Rect<T>> for Polygon<T>
impl<T: CoordinateType> From<Rect<T>> for Polygon<T>
sourceimpl<T: PartialEq> PartialEq<Polygon<T>> for Polygon<T>where
T: CoordinateType,
impl<T: PartialEq> PartialEq<Polygon<T>> for Polygon<T>where
T: CoordinateType,
impl<T> StructuralPartialEq for Polygon<T>where
T: CoordinateType,
Auto Trait Implementations
impl<T> RefUnwindSafe for Polygon<T>where
T: RefUnwindSafe,
impl<T> Send for Polygon<T>where
T: Send,
impl<T> Sync for Polygon<T>where
T: Sync,
impl<T> Unpin for Polygon<T>where
T: Unpin,
impl<T> UnwindSafe for Polygon<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more