Polygon

Struct Polygon 

Source
pub struct Polygon<P> {
    pub outer_contour: ClosedContour<P>,
    pub inner_contours: Vec<ClosedContour<P>>,
}
Expand description

Simple implementation of the Polygon trait.

Fields§

§outer_contour: ClosedContour<P>

Outer contour.

§inner_contours: Vec<ClosedContour<P>>

Inner contours.

Implementations§

Source§

impl<P> Polygon<P>

Source

pub fn new( outer_contour: ClosedContour<P>, inner_contours: Vec<ClosedContour<P>>, ) -> Self

Creates a new polygon.

Source

pub fn cast_points<T>(&self, cast: impl Fn(&P) -> T) -> Polygon<T>

Casts all points of the polygon into a different numeric type.

Trait Implementations§

Source§

impl<P: Clone> Clone for Polygon<P>

Source§

fn clone(&self) -> Polygon<P>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P: Debug> Debug for Polygon<P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<P: Default> Default for Polygon<P>

Source§

fn default() -> Polygon<P>

Returns the “default value” for a type. Read more
Source§

impl<'de, P> Deserialize<'de> for Polygon<P>
where P: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<P> From<ClosedContour<P>> for Polygon<P>

Source§

fn from(value: ClosedContour<P>) -> Self

Converts to this type from the input type.
Source§

impl<P> From<Polygon<P>> for Geom<P>

Source§

fn from(value: Polygon<P>) -> Self

Converts to this type from the input type.
Source§

impl<P> From<Vec<P>> for Polygon<P>

Source§

fn from(value: Vec<P>) -> Self

Converts to this type from the input type.
Source§

impl<P: GeometryType> GeometryType for Polygon<P>

Source§

type Type = PolygonGeometryType

Type of the geometry. Geometry trait is implemented for one of the following types: Read more
Source§

type Space = <P as GeometryType>::Space

Coordinate space that this geometry uses. This specifies what kind of coordinates the geometry uses. Read more
Source§

impl<P: Hash> Hash for Polygon<P>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<P: Ord> Ord for Polygon<P>

Source§

fn cmp(&self, other: &Polygon<P>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<P: PartialEq> PartialEq for Polygon<P>

Source§

fn eq(&self, other: &Polygon<P>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<P: PartialOrd> PartialOrd for Polygon<P>

Source§

fn partial_cmp(&self, other: &Polygon<P>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<P: Copy> Polygon for Polygon<P>

Source§

type Contour = ClosedContour<P>

Contour type.
Source§

fn outer_contour(&self) -> &Self::Contour

Outer contour of the polygon.
Source§

fn inner_contours(&self) -> impl Iterator<Item = &Self::Contour>

iterates over inner contours.
Source§

fn iter_contours(&self) -> impl Iterator<Item = &Self::Contour>

Iterates over all contours of the polygon starting with the outer one.
Source§

fn iter_segments( &self, ) -> impl Iterator<Item = Segment<<Self::Contour as Contour>::Point>>
where <Self::Contour as Contour>::Point: Copy,

Iterates over all segments of the polygon contour lines.
Source§

impl<P> Serialize for Polygon<P>
where P: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<P: Eq> Eq for Polygon<P>

Source§

impl<P> StructuralPartialEq for Polygon<P>

Auto Trait Implementations§

§

impl<P> Freeze for Polygon<P>

§

impl<P> RefUnwindSafe for Polygon<P>
where P: RefUnwindSafe,

§

impl<P> Send for Polygon<P>
where P: Send,

§

impl<P> Sync for Polygon<P>
where P: Sync,

§

impl<P> Unpin for Polygon<P>
where P: Unpin,

§

impl<P> UnwindSafe for Polygon<P>
where P: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<P, Poly> CartesianGeometry2dSpecialization<P, PolygonGeometryType> for Poly
where Poly: CartesianPolygon<Point = P> + GeometryType<Type = PolygonGeometryType, Space = CartesianSpace2d> + Geometry<Point = P> + Polygon, P: CartesianPoint2d + Copy, <Poly as Polygon>::Contour: Contour<Point = P> + CartesianGeometry2d<P>,

Source§

impl<P, C, T> CartesianPolygon for T
where P: CartesianPoint2d + Copy, C: ClosedContour<Point = P>, T: Polygon<Contour = C>,

Source§

type Point = P

Type of the points of the polygon.
Source§

fn contains_point<Point>(&self, point: &Point) -> bool
where Point: CartesianPoint2d<Num = <P as CartesianPoint2d>::Num>,

Returns true if the point lies inside or on one of the polygon’s sides.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> CoordinateMetadata for T
where T: ?Sized,

Source§

fn crs_id(&self) -> Option<MdIdentifier>

Source§

fn crs(&self) -> Option<Crs>

Source§

fn coordinate_epoch(&self) -> Option<DataEpoch>

Source§

fn is_valid(&self) -> bool

Source§

impl<T> Disambiguate for T
where T: GeometryType<Space = AmbiguousSpace>,

Source§

fn to_geo2d(self) -> Disambig<Self, GeoSpace2d>
where Self: Sized,

Specifies that the geometry is in geographic coordinates.
Source§

fn to_cartesian2d(self) -> Disambig<Self, CartesianSpace2d>
where Self: Sized,

Specifies that the geometry is in cartesian coordinates.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<Poly, Space> GeometrySpecialization<PolygonGeometryType, Space> for Poly
where Poly: Polygon + GeometryType<Type = PolygonGeometryType, Space = Space>, <Poly as Polygon>::Contour: Geometry,

Source§

type Point = <<Poly as Polygon>::Contour as Geometry>::Point

Type of the point of the geometry.
Source§

fn project_spec<Proj>( &self, projection: &Proj, ) -> Option<Geom<<Proj as Projection>::OutPoint>>
where Proj: Projection<InPoint = <Poly as GeometrySpecialization<PolygonGeometryType, Space>>::Point> + ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,