[−][src]Enum shapefile::record::polygon::PolygonRing
Rings composing a Polygon
Inner
rings define holes in polygons.
In shapefile, the point ordering is what is used to know if a ring is an outer or inner one:
- Outer ring => points in clockwise order
- Inner ring => points in counter-clockwise order
Note
Rings you get access from a GenericPolygon
will always have its points ordered
according to its type (outer, inner).
But PolygonRing
s you create won't be reordered until you move them into
a GenericPolygon
.
Example
use shapefile::{PolygonRing, Polygon, Point}; // Here the points are not in the correct order to be an Outer ring for a shapefile let mut points = vec![ Point::new(-12.0, 6.0), Point::new(-12.0, -6.0), Point::new(12.0, -6.0), Point::new(12.0, 6.0), Point::new(-12.0, 6.0), ]; let mut reversed_points = points.clone(); reversed_points.reverse(); let ring = PolygonRing::Outer(points); assert_ne!(ring.points(), reversed_points.as_slice()); // Now the points will be reversed let polygon = Polygon::new(ring); assert_eq!(polygon.rings()[0].points(), reversed_points.as_slice());
Variants
Outer(Vec<PointType>)
The outer ring of a polygon.
Inner(Vec<PointType>)
Defines a hole in a polygon
Methods
impl<PointType> PolygonRing<PointType>
[src]
pub fn len(&self) -> usize
[src]
Returns the number of points inside the ring
Example
use shapefile::{PolygonRing, Point}; let ring = PolygonRing::Inner(vec![ Point::new(-12.0, 6.0), Point::new(-12.0, -6.0), Point::new(12.0, -6.0), Point::new(12.0, 6.0), Point::new(-12.0, 6.0), ]); assert_eq!(ring.len(), 5);
pub fn points(&self) -> &[PointType]
[src]
Returns a non-mutable slice to the points inside the ring
use shapefile::{PolygonRing, Point}; let ring = PolygonRing::Inner(vec![ Point::new(-12.0, 6.0), Point::new(-12.0, -6.0), Point::new(12.0, -6.0), Point::new(12.0, 6.0), Point::new(-12.0, 6.0), ]); assert_eq!(ring.points()[2], Point::new(12.0, -6.0));
pub fn into_inner(self) -> Vec<PointType>
[src]
Consumes the ring and returns its points
Trait Implementations
impl<PointType> AsRef<[PointType]> for PolygonRing<PointType>
[src]
fn as_ref(&self) -> &[PointType]
[src]
impl<PointType: Clone> Clone for PolygonRing<PointType>
[src]
fn clone(&self) -> PolygonRing<PointType>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<PointType: Debug> Debug for PolygonRing<PointType>
[src]
impl<PointType: HasXY> From<Vec<PointType>> for PolygonRing<PointType>
[src]
impl<PointType: PartialEq> PartialEq<PolygonRing<PointType>> for PolygonRing<PointType>
[src]
fn eq(&self, other: &PolygonRing<PointType>) -> bool
[src]
fn ne(&self, other: &PolygonRing<PointType>) -> bool
[src]
impl<PointType> StructuralPartialEq for PolygonRing<PointType>
[src]
Auto Trait Implementations
impl<PointType> RefUnwindSafe for PolygonRing<PointType> where
PointType: RefUnwindSafe,
PointType: RefUnwindSafe,
impl<PointType> Send for PolygonRing<PointType> where
PointType: Send,
PointType: Send,
impl<PointType> Sync for PolygonRing<PointType> where
PointType: Sync,
PointType: Sync,
impl<PointType> Unpin for PolygonRing<PointType> where
PointType: Unpin,
PointType: Unpin,
impl<PointType> UnwindSafe for PolygonRing<PointType> where
PointType: UnwindSafe,
PointType: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,