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.

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

Methods

impl<T> Polygon<T> where
    T: CoordinateType
[src]

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);

impl<T> Polygon<T> where
    T: Float + Signed
[src]

Determine whether a Polygon is convex

Trait Implementations

impl<T: PartialEq> PartialEq for Polygon<T> where
    T: CoordinateType
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<T: Clone> Clone for Polygon<T> where
    T: CoordinateType
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: Debug> Debug for Polygon<T> where
    T: CoordinateType
[src]

Formats the value using the given formatter. Read more

impl<T: CoordinateType> From<Polygon<T>> for Geometry<T>
[src]

Performs the conversion.

Auto Trait Implementations

impl<T> Send for Polygon<T> where
    T: Send

impl<T> Sync for Polygon<T> where
    T: Sync