Struct geo_types::Polygon [−][src]
pub struct Polygon<T> where
T: CoordinateType, { pub exterior: LineString<T>, pub interiors: Vec<LineString<T>>, }
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.
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>>
Methods
impl<T> Polygon<T> where
T: CoordinateType,
[src]
impl<T> Polygon<T> where
T: CoordinateType,
pub fn new(exterior: LineString<T>, interiors: Vec<LineString<T>>) -> Polygon<T>
[src]
pub fn new(exterior: LineString<T>, interiors: Vec<LineString<T>>) -> Polygon<T>
Creates a new polygon.
use geo_types::{Point, LineString, Polygon}; let exterior = LineString(vec![Point::new(0., 0.), Point::new(1., 1.), Point::new(1., 0.), Point::new(0., 0.)]); let interiors = vec![LineString(vec![Point::new(0.1, 0.1), Point::new(0.9, 0.9), Point::new(0.9, 0.1), Point::new(0.1, 0.1)])]; let p = Polygon::new(exterior.clone(), interiors.clone()); assert_eq!(p.exterior, exterior); assert_eq!(p.interiors, interiors);
impl<T> Polygon<T> where
T: Float + Signed,
[src]
impl<T> Polygon<T> where
T: Float + Signed,
Trait Implementations
impl<T: PartialEq> PartialEq for Polygon<T> where
T: CoordinateType,
[src]
impl<T: PartialEq> PartialEq for Polygon<T> where
T: CoordinateType,
fn eq(&self, other: &Polygon<T>) -> bool
[src]
fn eq(&self, other: &Polygon<T>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Polygon<T>) -> bool
[src]
fn ne(&self, other: &Polygon<T>) -> bool
This method tests for !=
.
impl<T: Clone> Clone for Polygon<T> where
T: CoordinateType,
[src]
impl<T: Clone> Clone for Polygon<T> where
T: CoordinateType,
fn clone(&self) -> Polygon<T>
[src]
fn clone(&self) -> Polygon<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0
[src]Performs copy-assignment from source
. Read more
impl<T: Debug> Debug for Polygon<T> where
T: CoordinateType,
[src]
impl<T: Debug> Debug for Polygon<T> where
T: CoordinateType,
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<T: CoordinateType> From<Polygon<T>> for Geometry<T>
[src]
impl<T: CoordinateType> From<Polygon<T>> for Geometry<T>