pub struct Polygon<T = f64>where
T: CoordNum,{ /* private fields */ }
Expand description
A bounded two-dimensional area.
A Polygon
’s outer boundary (exterior ring) is represented by a
LineString
. It may contain zero or more holes (interior rings), also
represented by LineString
s.
A Polygon
can be created with the Polygon::new
constructor or the polygon!
macro.
§Semantics
The boundary of the polygon is the union of the boundaries of the exterior and interiors. The interior is all the points inside the polygon (not on the boundary).
The Polygon
structure guarantees that all exterior and interior rings will
be closed, such that the first and last Coord
of each ring has
the same value.
§Validity
-
The exterior and interior rings must be valid
LinearRing
s (seeLineString
). -
No two rings in the boundary may cross, and may intersect at a
Point
only as a tangent. In other words, the rings must be distinct, and for every pair of common points in two of the rings, there must be a neighborhood (a topological open set) around one that does not contain the other point. -
The closure of the interior of the
Polygon
must equal thePolygon
itself. For instance, the exterior may not contain a spike. -
The interior of the polygon must be a connected point-set. That is, any two distinct points in the interior must admit a curve between these two that lies in the interior.
Refer to section 6.1.11.1 of the OGC-SFA for a formal
definition of validity. Besides the closed LineString
guarantee, the Polygon
structure does not enforce
validity at this time. For example, it is possible to
construct a Polygon
that has:
- fewer than 3 coordinates per
LineString
ring - interior rings that intersect other interior rings
- interior rings that extend beyond the exterior ring
§LineString
closing operation
Some APIs on Polygon
result in a closing operation on a LineString
. The
operation is as follows:
If a LineString
’s first and last Coord
have different values, a
new Coord
will be appended to the LineString
with a value equal to
the first Coord
.
Implementations§
Source§impl<T> Polygon<T>where
T: CoordNum,
impl<T> Polygon<T>where
T: CoordNum,
Sourcepub fn new(exterior: LineString<T>, interiors: Vec<LineString<T>>) -> Polygon<T>
pub fn new(exterior: LineString<T>, interiors: Vec<LineString<T>>) -> Polygon<T>
Create a new Polygon
with the provided exterior LineString
ring and
interior LineString
rings.
Upon calling new
, the exterior and interior LineString
rings will
be closed.
§Examples
Creating a Polygon
with no interior rings:
use geo_types::{LineString, Polygon};
let polygon = Polygon::new(
LineString::from(vec![(0., 0.), (1., 1.), (1., 0.), (0., 0.)]),
vec![],
);
Creating a Polygon
with an interior ring:
use geo_types::{LineString, Polygon};
let polygon = Polygon::new(
LineString::from(vec![(0., 0.), (1., 1.), (1., 0.), (0., 0.)]),
vec![LineString::from(vec![
(0.1, 0.1),
(0.9, 0.9),
(0.9, 0.1),
(0.1, 0.1),
])],
);
If the first and last Coord
s of the exterior or interior
LineString
s no longer match, those LineString
s will be closed:
use geo_types::{coord, LineString, Polygon};
let mut polygon = Polygon::new(LineString::from(vec![(0., 0.), (1., 1.), (1., 0.)]), vec![]);
assert_eq!(
polygon.exterior(),
&LineString::from(vec![(0., 0.), (1., 1.), (1., 0.), (0., 0.),])
);
Sourcepub fn into_inner(self) -> (LineString<T>, Vec<LineString<T>>)
pub fn into_inner(self) -> (LineString<T>, Vec<LineString<T>>)
Consume the Polygon
, returning the exterior LineString
ring and
a vector of the interior LineString
rings.
§Examples
use geo_types::{LineString, Polygon};
let mut polygon = Polygon::new(
LineString::from(vec![(0., 0.), (1., 1.), (1., 0.), (0., 0.)]),
vec![LineString::from(vec![
(0.1, 0.1),
(0.9, 0.9),
(0.9, 0.1),
(0.1, 0.1),
])],
);
let (exterior, interiors) = polygon.into_inner();
assert_eq!(
exterior,
LineString::from(vec![(0., 0.), (1., 1.), (1., 0.), (0., 0.),])
);
assert_eq!(
interiors,
vec![LineString::from(vec![
(0.1, 0.1),
(0.9, 0.9),
(0.9, 0.1),
(0.1, 0.1),
])]
);
Sourcepub fn exterior(&self) -> &LineString<T>
pub fn exterior(&self) -> &LineString<T>
Return a reference to the exterior LineString
ring.
§Examples
use geo_types::{LineString, Polygon};
let exterior = LineString::from(vec![(0., 0.), (1., 1.), (1., 0.), (0., 0.)]);
let polygon = Polygon::new(exterior.clone(), vec![]);
assert_eq!(polygon.exterior(), &exterior);
Sourcepub fn exterior_mut<F>(&mut self, f: F)where
F: FnOnce(&mut LineString<T>),
pub fn exterior_mut<F>(&mut self, f: F)where
F: FnOnce(&mut LineString<T>),
Execute the provided closure f
, which is provided with a mutable
reference to the exterior LineString
ring.
After the closure executes, the exterior LineString
will be closed.
§Examples
use geo_types::{coord, LineString, Polygon};
let mut polygon = Polygon::new(
LineString::from(vec![(0., 0.), (1., 1.), (1., 0.), (0., 0.)]),
vec![],
);
polygon.exterior_mut(|exterior| {
exterior.0[1] = coord! { x: 1., y: 2. };
});
assert_eq!(
polygon.exterior(),
&LineString::from(vec![(0., 0.), (1., 2.), (1., 0.), (0., 0.),])
);
If the first and last Coord
s of the exterior LineString
no
longer match, the LineString
will be closed:
use geo_types::{coord, LineString, Polygon};
let mut polygon = Polygon::new(
LineString::from(vec![(0., 0.), (1., 1.), (1., 0.), (0., 0.)]),
vec![],
);
polygon.exterior_mut(|exterior| {
exterior.0[0] = coord! { x: 0., y: 1. };
});
assert_eq!(
polygon.exterior(),
&LineString::from(vec![(0., 1.), (1., 1.), (1., 0.), (0., 0.), (0., 1.),])
);
Sourcepub fn try_exterior_mut<F, E>(&mut self, f: F) -> Result<(), E>
pub fn try_exterior_mut<F, E>(&mut self, f: F) -> Result<(), E>
Fallible alternative to exterior_mut
.
Sourcepub fn interiors(&self) -> &[LineString<T>]
pub fn interiors(&self) -> &[LineString<T>]
Return a slice of the interior LineString
rings.
§Examples
use geo_types::{coord, LineString, Polygon};
let interiors = vec![LineString::from(vec![
(0.1, 0.1),
(0.9, 0.9),
(0.9, 0.1),
(0.1, 0.1),
])];
let polygon = Polygon::new(
LineString::from(vec![(0., 0.), (1., 1.), (1., 0.), (0., 0.)]),
interiors.clone(),
);
assert_eq!(interiors, polygon.interiors());
Sourcepub fn interiors_mut<F>(&mut self, f: F)where
F: FnOnce(&mut [LineString<T>]),
pub fn interiors_mut<F>(&mut self, f: F)where
F: FnOnce(&mut [LineString<T>]),
Execute the provided closure f
, which is provided with a mutable
reference to the interior LineString
rings.
After the closure executes, each of the interior LineString
s will be
closed.
§Examples
use geo_types::{coord, LineString, Polygon};
let mut polygon = Polygon::new(
LineString::from(vec![(0., 0.), (1., 1.), (1., 0.), (0., 0.)]),
vec![LineString::from(vec![
(0.1, 0.1),
(0.9, 0.9),
(0.9, 0.1),
(0.1, 0.1),
])],
);
polygon.interiors_mut(|interiors| {
interiors[0].0[1] = coord! { x: 0.8, y: 0.8 };
});
assert_eq!(
polygon.interiors(),
&[LineString::from(vec![
(0.1, 0.1),
(0.8, 0.8),
(0.9, 0.1),
(0.1, 0.1),
])]
);
If the first and last Coord
s of any interior LineString
no
longer match, those LineString
s will be closed:
use geo_types::{coord, LineString, Polygon};
let mut polygon = Polygon::new(
LineString::from(vec![(0., 0.), (1., 1.), (1., 0.), (0., 0.)]),
vec![LineString::from(vec![
(0.1, 0.1),
(0.9, 0.9),
(0.9, 0.1),
(0.1, 0.1),
])],
);
polygon.interiors_mut(|interiors| {
interiors[0].0[0] = coord! { x: 0.1, y: 0.2 };
});
assert_eq!(
polygon.interiors(),
&[LineString::from(vec![
(0.1, 0.2),
(0.9, 0.9),
(0.9, 0.1),
(0.1, 0.1),
(0.1, 0.2),
])]
);
Sourcepub fn try_interiors_mut<F, E>(&mut self, f: F) -> Result<(), E>
pub fn try_interiors_mut<F, E>(&mut self, f: F) -> Result<(), E>
Fallible alternative to interiors_mut
.
Sourcepub fn interiors_push(&mut self, new_interior: impl Into<LineString<T>>)
pub fn interiors_push(&mut self, new_interior: impl Into<LineString<T>>)
Add an interior ring to the Polygon
.
The new LineString
interior ring will be closed:
§Examples
use geo_types::{coord, LineString, Polygon};
let mut polygon = Polygon::new(
LineString::from(vec![(0., 0.), (1., 1.), (1., 0.), (0., 0.)]),
vec![],
);
assert_eq!(polygon.interiors().len(), 0);
polygon.interiors_push(vec![(0.1, 0.1), (0.9, 0.9), (0.9, 0.1)]);
assert_eq!(
polygon.interiors(),
&[LineString::from(vec![
(0.1, 0.1),
(0.9, 0.9),
(0.9, 0.1),
(0.1, 0.1),
])]
);
Sourcepub fn num_rings(&self) -> usize
pub fn num_rings(&self) -> usize
Count the total number of rings (interior and exterior) in the polygon
§Examples
use geo_types::{coord, LineString, Polygon};
let polygon = Polygon::new(
LineString::from(vec![(0., 0.), (1., 1.), (1., 0.), (0., 0.)]),
vec![],
);
assert_eq!(polygon.num_rings(), 1);
let polygon = Polygon::new(
LineString::from(vec![(0., 0.), (1., 1.), (1., 0.), (0., 0.)]),
vec![LineString::from(vec![(0.1, 0.1), (0.9, 0.9), (0.9, 0.1)])],
);
assert_eq!(polygon.num_rings(), 2);
Sourcepub fn num_interior_rings(&self) -> usize
pub fn num_interior_rings(&self) -> usize
Count the number of interior rings in the polygon
§Examples
use geo_types::{coord, LineString, Polygon};
let polygon = Polygon::new(
LineString::from(vec![(0., 0.), (1., 1.), (1., 0.), (0., 0.)]),
vec![],
);
assert_eq!(polygon.num_interior_rings(), 0);
let polygon = Polygon::new(
LineString::from(vec![(0., 0.), (1., 1.), (1., 0.), (0., 0.)]),
vec![LineString::from(vec![(0.1, 0.1), (0.9, 0.9), (0.9, 0.1)])],
);
assert_eq!(polygon.num_interior_rings(), 1);
Trait Implementations§
Source§impl<T> AbsDiffEq for Polygon<T>
impl<T> AbsDiffEq for Polygon<T>
Source§fn abs_diff_eq(
&self,
other: &Polygon<T>,
epsilon: <Polygon<T> as AbsDiffEq>::Epsilon,
) -> bool
fn abs_diff_eq( &self, other: &Polygon<T>, epsilon: <Polygon<T> as AbsDiffEq>::Epsilon, ) -> bool
Equality assertion with an absolute limit.
§Examples
use geo_types::{Polygon, polygon};
let a: Polygon<f32> = polygon![(x: 0., y: 0.), (x: 5., y: 0.), (x: 7., y: 9.), (x: 0., y: 0.)];
let b: Polygon<f32> = polygon![(x: 0., y: 0.), (x: 5., y: 0.), (x: 7.01, y: 9.), (x: 0., y: 0.)];
approx::assert_abs_diff_eq!(a, b, epsilon=0.1);
approx::assert_abs_diff_ne!(a, b, epsilon=0.001);
Source§fn default_epsilon() -> <Polygon<T> as AbsDiffEq>::Epsilon
fn default_epsilon() -> <Polygon<T> as AbsDiffEq>::Epsilon
Source§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
AbsDiffEq::abs_diff_eq
.Source§impl<T> Area<T> for Polygon<T>where
T: CoordFloat,
impl<T> Area<T> for Polygon<T>where
T: CoordFloat,
Note. The implementation handles polygons whose holes do not all have the same orientation. The sign of the output is the same as that of the exterior shell.
fn signed_area(&self) -> T
fn unsigned_area(&self) -> T
Source§impl<T: BoolOpsNum> BooleanOps for Polygon<T>
impl<T: BoolOpsNum> BooleanOps for Polygon<T>
type Scalar = T
Source§fn rings(&self) -> impl Iterator<Item = &LineString<Self::Scalar>>
fn rings(&self) -> impl Iterator<Item = &LineString<Self::Scalar>>
fn boolean_op( &self, other: &impl BooleanOps<Scalar = Self::Scalar>, op: OpType, ) -> MultiPolygon<Self::Scalar>
fn intersection( &self, other: &impl BooleanOps<Scalar = Self::Scalar>, ) -> MultiPolygon<Self::Scalar>
fn union( &self, other: &impl BooleanOps<Scalar = Self::Scalar>, ) -> MultiPolygon<Self::Scalar>
fn xor( &self, other: &impl BooleanOps<Scalar = Self::Scalar>, ) -> MultiPolygon<Self::Scalar>
fn difference( &self, other: &impl BooleanOps<Scalar = Self::Scalar>, ) -> MultiPolygon<Self::Scalar>
Source§fn clip(
&self,
multi_line_string: &MultiLineString<Self::Scalar>,
invert: bool,
) -> MultiLineString<Self::Scalar>
fn clip( &self, multi_line_string: &MultiLineString<Self::Scalar>, invert: bool, ) -> MultiLineString<Self::Scalar>
Source§impl<T> BoundingRect<T> for Polygon<T>where
T: CoordNum,
impl<T> BoundingRect<T> for Polygon<T>where
T: CoordNum,
Source§impl<T> Centroid for Polygon<T>where
T: GeoFloat,
impl<T> Centroid for Polygon<T>where
T: GeoFloat,
Source§impl<T> ChaikinSmoothing<T> for Polygon<T>where
T: CoordFloat + FromPrimitive,
impl<T> ChaikinSmoothing<T> for Polygon<T>where
T: CoordFloat + FromPrimitive,
Source§fn chaikin_smoothing(&self, n_iterations: usize) -> Self
fn chaikin_smoothing(&self, n_iterations: usize) -> Self
n_iterations
times.Source§impl<T> ChamberlainDuquetteArea<T> for Polygon<T>where
T: CoordFloat,
impl<T> ChamberlainDuquetteArea<T> for Polygon<T>where
T: CoordFloat,
fn chamberlain_duquette_signed_area(&self) -> T
fn chamberlain_duquette_unsigned_area(&self) -> T
Source§impl<F: GeoFloat> ClosestPoint<F> for Polygon<F>
impl<F: GeoFloat> ClosestPoint<F> for Polygon<F>
Source§fn closest_point(&self, p: &Point<F>) -> Closest<F>
fn closest_point(&self, p: &Point<F>) -> Closest<F>
self
and p
.Source§impl<T> ConcaveHull for Polygon<T>
impl<T> ConcaveHull for Polygon<T>
Source§impl<T> Contains<GeometryCollection<T>> for Polygon<T>where
T: GeoFloat,
impl<T> Contains<GeometryCollection<T>> for Polygon<T>where
T: GeoFloat,
fn contains(&self, target: &GeometryCollection<T>) -> bool
Source§impl<T> Contains<LineString<T>> for Polygon<T>where
T: GeoFloat,
impl<T> Contains<LineString<T>> for Polygon<T>where
T: GeoFloat,
fn contains(&self, target: &LineString<T>) -> bool
Source§impl<T> Contains<MultiLineString<T>> for Polygon<T>where
T: GeoFloat,
impl<T> Contains<MultiLineString<T>> for Polygon<T>where
T: GeoFloat,
fn contains(&self, target: &MultiLineString<T>) -> bool
Source§impl<T> Contains<MultiPoint<T>> for Polygon<T>where
T: GeoFloat,
impl<T> Contains<MultiPoint<T>> for Polygon<T>where
T: GeoFloat,
fn contains(&self, target: &MultiPoint<T>) -> bool
Source§impl<T> Contains<MultiPolygon<T>> for Polygon<T>where
T: GeoFloat,
impl<T> Contains<MultiPolygon<T>> for Polygon<T>where
T: GeoFloat,
fn contains(&self, target: &MultiPolygon<T>) -> bool
Source§impl<T> CoordinatePosition for Polygon<T>where
T: GeoNum,
impl<T> CoordinatePosition for Polygon<T>where
T: GeoNum,
Source§impl<T: CoordNum> CoordsIter for Polygon<T>
impl<T: CoordNum> CoordsIter for Polygon<T>
Source§fn coords_count(&self) -> usize
fn coords_count(&self) -> usize
Return the number of coordinates in the Polygon
.
type Iter<'a> = Chain<Copied<Iter<'a, Coord<T>>>, Flatten<MapCoordsIter<'a, T, Iter<'a, LineString<T>>, LineString<T>>>> where T: 'a
type ExteriorIter<'a> = Copied<Iter<'a, Coord<T>>> where T: 'a
type Scalar = T
Source§fn coords_iter(&self) -> Self::Iter<'_>
fn coords_iter(&self) -> Self::Iter<'_>
Source§fn exterior_coords_iter(&self) -> Self::ExteriorIter<'_>
fn exterior_coords_iter(&self) -> Self::ExteriorIter<'_>
Source§impl<F: CoordFloat + FromPrimitive> Densify<F> for Polygon<F>
impl<F: CoordFloat + FromPrimitive> Densify<F> for Polygon<F>
Source§impl<T> DensifyHaversine<T> for Polygon<T>where
T: CoordFloat + FromPrimitive,
Line<T>: HaversineLength<T>,
LineString<T>: HaversineLength<T>,
impl<T> DensifyHaversine<T> for Polygon<T>where
T: CoordFloat + FromPrimitive,
Line<T>: HaversineLength<T>,
LineString<T>: HaversineLength<T>,
Source§impl<F: GeoFloat> Distance<F, &GeometryCollection<F>, &Polygon<F>> for Euclidean
impl<F: GeoFloat> Distance<F, &GeometryCollection<F>, &Polygon<F>> for Euclidean
Source§fn distance(
iter_geometry: &GeometryCollection<F>,
to_geometry: &Polygon<F>,
) -> F
fn distance( iter_geometry: &GeometryCollection<F>, to_geometry: &Polygon<F>, ) -> F
Point
to Point
is supported.
See specific implementations for details. Read moreSource§impl<F: GeoFloat> Distance<F, &LineString<F>, &Polygon<F>> for Euclidean
impl<F: GeoFloat> Distance<F, &LineString<F>, &Polygon<F>> for Euclidean
Source§fn distance(line_string: &LineString<F>, polygon: &Polygon<F>) -> F
fn distance(line_string: &LineString<F>, polygon: &Polygon<F>) -> F
Point
to Point
is supported.
See specific implementations for details. Read moreSource§impl<F: GeoFloat> Distance<F, &MultiLineString<F>, &Polygon<F>> for Euclidean
impl<F: GeoFloat> Distance<F, &MultiLineString<F>, &Polygon<F>> for Euclidean
Source§fn distance(iter_geometry: &MultiLineString<F>, to_geometry: &Polygon<F>) -> F
fn distance(iter_geometry: &MultiLineString<F>, to_geometry: &Polygon<F>) -> F
Point
to Point
is supported.
See specific implementations for details. Read moreSource§impl<F: GeoFloat> Distance<F, &MultiPoint<F>, &Polygon<F>> for Euclidean
impl<F: GeoFloat> Distance<F, &MultiPoint<F>, &Polygon<F>> for Euclidean
Source§fn distance(iter_geometry: &MultiPoint<F>, to_geometry: &Polygon<F>) -> F
fn distance(iter_geometry: &MultiPoint<F>, to_geometry: &Polygon<F>) -> F
Point
to Point
is supported.
See specific implementations for details. Read moreSource§impl<F: GeoFloat> Distance<F, &MultiPolygon<F>, &Polygon<F>> for Euclidean
impl<F: GeoFloat> Distance<F, &MultiPolygon<F>, &Polygon<F>> for Euclidean
Source§fn distance(iter_geometry: &MultiPolygon<F>, to_geometry: &Polygon<F>) -> F
fn distance(iter_geometry: &MultiPolygon<F>, to_geometry: &Polygon<F>) -> F
Point
to Point
is supported.
See specific implementations for details. Read moreSource§impl<F> Distance<F, &Polygon<F>, &GeometryCollection<F>> for Euclideanwhere
F: GeoFloat,
impl<F> Distance<F, &Polygon<F>, &GeometryCollection<F>> for Euclideanwhere
F: GeoFloat,
Source§fn distance(a: &Polygon<F>, b: &GeometryCollection<F>) -> F
fn distance(a: &Polygon<F>, b: &GeometryCollection<F>) -> F
Point
to Point
is supported.
See specific implementations for details. Read moreSource§impl<F> Distance<F, &Polygon<F>, &LineString<F>> for Euclideanwhere
F: GeoFloat,
impl<F> Distance<F, &Polygon<F>, &LineString<F>> for Euclideanwhere
F: GeoFloat,
Source§fn distance(a: &Polygon<F>, b: &LineString<F>) -> F
fn distance(a: &Polygon<F>, b: &LineString<F>) -> F
Point
to Point
is supported.
See specific implementations for details. Read moreSource§impl<F> Distance<F, &Polygon<F>, &MultiLineString<F>> for Euclideanwhere
F: GeoFloat,
impl<F> Distance<F, &Polygon<F>, &MultiLineString<F>> for Euclideanwhere
F: GeoFloat,
Source§fn distance(a: &Polygon<F>, b: &MultiLineString<F>) -> F
fn distance(a: &Polygon<F>, b: &MultiLineString<F>) -> F
Point
to Point
is supported.
See specific implementations for details. Read moreSource§impl<F> Distance<F, &Polygon<F>, &MultiPoint<F>> for Euclideanwhere
F: GeoFloat,
impl<F> Distance<F, &Polygon<F>, &MultiPoint<F>> for Euclideanwhere
F: GeoFloat,
Source§fn distance(a: &Polygon<F>, b: &MultiPoint<F>) -> F
fn distance(a: &Polygon<F>, b: &MultiPoint<F>) -> F
Point
to Point
is supported.
See specific implementations for details. Read moreSource§impl<F> Distance<F, &Polygon<F>, &MultiPolygon<F>> for Euclideanwhere
F: GeoFloat,
impl<F> Distance<F, &Polygon<F>, &MultiPolygon<F>> for Euclideanwhere
F: GeoFloat,
Source§fn distance(a: &Polygon<F>, b: &MultiPolygon<F>) -> F
fn distance(a: &Polygon<F>, b: &MultiPolygon<F>) -> F
Point
to Point
is supported.
See specific implementations for details. Read moreSource§impl<T> EuclideanDistance<T> for Polygon<T>
impl<T> EuclideanDistance<T> for Polygon<T>
Source§fn euclidean_distance(&self, poly2: &Polygon<T>) -> T
fn euclidean_distance(&self, poly2: &Polygon<T>) -> T
Euclidean::distance
method from the Distance
trait insteadSource§impl<T> EuclideanDistance<T, Geometry<T>> for Polygon<T>
impl<T> EuclideanDistance<T, Geometry<T>> for Polygon<T>
Source§fn euclidean_distance(&self, geom: &Geometry<T>) -> T
fn euclidean_distance(&self, geom: &Geometry<T>) -> T
Euclidean::distance
method from the Distance
trait insteadSource§impl<T> EuclideanDistance<T, GeometryCollection<T>> for Polygon<T>
impl<T> EuclideanDistance<T, GeometryCollection<T>> for Polygon<T>
Source§fn euclidean_distance(&self, target: &GeometryCollection<T>) -> T
fn euclidean_distance(&self, target: &GeometryCollection<T>) -> T
Euclidean::distance
method from the Distance
trait insteadSource§impl<T> EuclideanDistance<T, Line<T>> for Polygon<T>
impl<T> EuclideanDistance<T, Line<T>> for Polygon<T>
Source§fn euclidean_distance(&self, other: &Line<T>) -> T
fn euclidean_distance(&self, other: &Line<T>) -> T
Euclidean::distance
method from the Distance
trait insteadSource§impl<T> EuclideanDistance<T, LineString<T>> for Polygon<T>
impl<T> EuclideanDistance<T, LineString<T>> for Polygon<T>
Polygon to LineString distance
Source§fn euclidean_distance(&self, other: &LineString<T>) -> T
fn euclidean_distance(&self, other: &LineString<T>) -> T
Euclidean::distance
method from the Distance
trait insteadSource§impl<T> EuclideanDistance<T, MultiLineString<T>> for Polygon<T>
impl<T> EuclideanDistance<T, MultiLineString<T>> for Polygon<T>
Source§fn euclidean_distance(&self, target: &MultiLineString<T>) -> T
fn euclidean_distance(&self, target: &MultiLineString<T>) -> T
Euclidean::distance
method from the Distance
trait insteadSource§impl<T> EuclideanDistance<T, MultiPoint<T>> for Polygon<T>
impl<T> EuclideanDistance<T, MultiPoint<T>> for Polygon<T>
Source§fn euclidean_distance(&self, target: &MultiPoint<T>) -> T
fn euclidean_distance(&self, target: &MultiPoint<T>) -> T
Euclidean::distance
method from the Distance
trait insteadSource§impl<T> EuclideanDistance<T, MultiPolygon<T>> for Polygon<T>
impl<T> EuclideanDistance<T, MultiPolygon<T>> for Polygon<T>
Source§fn euclidean_distance(&self, target: &MultiPolygon<T>) -> T
fn euclidean_distance(&self, target: &MultiPolygon<T>) -> T
Euclidean::distance
method from the Distance
trait insteadSource§impl<T> EuclideanDistance<T, Point<T>> for Polygon<T>where
T: GeoFloat,
impl<T> EuclideanDistance<T, Point<T>> for Polygon<T>where
T: GeoFloat,
Source§fn euclidean_distance(&self, point: &Point<T>) -> T
👎Deprecated since 0.29.0: Please use the Euclidean::distance
method from the Distance
trait instead
fn euclidean_distance(&self, point: &Point<T>) -> T
Euclidean::distance
method from the Distance
trait insteadMinimum distance from a Polygon to a Point
Source§impl<T> EuclideanDistance<T, Polygon<T>> for Geometry<T>
impl<T> EuclideanDistance<T, Polygon<T>> for Geometry<T>
Source§fn euclidean_distance(&self, other: &Polygon<T>) -> T
fn euclidean_distance(&self, other: &Polygon<T>) -> T
Euclidean::distance
method from the Distance
trait insteadSource§impl<T> EuclideanDistance<T, Polygon<T>> for GeometryCollection<T>
impl<T> EuclideanDistance<T, Polygon<T>> for GeometryCollection<T>
Source§fn euclidean_distance(&self, target: &Polygon<T>) -> T
fn euclidean_distance(&self, target: &Polygon<T>) -> T
Euclidean::distance
method from the Distance
trait insteadSource§impl<T> EuclideanDistance<T, Polygon<T>> for Line<T>
impl<T> EuclideanDistance<T, Polygon<T>> for Line<T>
Source§fn euclidean_distance(&self, other: &Polygon<T>) -> T
fn euclidean_distance(&self, other: &Polygon<T>) -> T
Euclidean::distance
method from the Distance
trait insteadSource§impl<T> EuclideanDistance<T, Polygon<T>> for LineString<T>
impl<T> EuclideanDistance<T, Polygon<T>> for LineString<T>
LineString to Polygon
Source§fn euclidean_distance(&self, other: &Polygon<T>) -> T
fn euclidean_distance(&self, other: &Polygon<T>) -> T
Euclidean::distance
method from the Distance
trait insteadSource§impl<T> EuclideanDistance<T, Polygon<T>> for MultiLineString<T>
impl<T> EuclideanDistance<T, Polygon<T>> for MultiLineString<T>
Source§fn euclidean_distance(&self, target: &Polygon<T>) -> T
fn euclidean_distance(&self, target: &Polygon<T>) -> T
Euclidean::distance
method from the Distance
trait insteadSource§impl<T> EuclideanDistance<T, Polygon<T>> for MultiPoint<T>
impl<T> EuclideanDistance<T, Polygon<T>> for MultiPoint<T>
Source§fn euclidean_distance(&self, target: &Polygon<T>) -> T
fn euclidean_distance(&self, target: &Polygon<T>) -> T
Euclidean::distance
method from the Distance
trait insteadSource§impl<T> EuclideanDistance<T, Polygon<T>> for MultiPolygon<T>
impl<T> EuclideanDistance<T, Polygon<T>> for MultiPolygon<T>
Source§fn euclidean_distance(&self, target: &Polygon<T>) -> T
fn euclidean_distance(&self, target: &Polygon<T>) -> T
Euclidean::distance
method from the Distance
trait insteadSource§impl<T> EuclideanDistance<T, Polygon<T>> for Point<T>where
T: GeoFloat,
impl<T> EuclideanDistance<T, Polygon<T>> for Point<T>where
T: GeoFloat,
Source§fn euclidean_distance(&self, polygon: &Polygon<T>) -> T
👎Deprecated since 0.29.0: Please use the Euclidean::distance
method from the Distance
trait instead
fn euclidean_distance(&self, polygon: &Polygon<T>) -> T
Euclidean::distance
method from the Distance
trait insteadMinimum distance from a Point to a Polygon
Source§impl<T> EuclideanDistance<T, Polygon<T>> for Rect<T>
impl<T> EuclideanDistance<T, Polygon<T>> for Rect<T>
Source§fn euclidean_distance(&self, other: &Polygon<T>) -> T
fn euclidean_distance(&self, other: &Polygon<T>) -> T
Euclidean::distance
method from the Distance
trait insteadSource§impl<T> EuclideanDistance<T, Polygon<T>> for Triangle<T>
impl<T> EuclideanDistance<T, Polygon<T>> for Triangle<T>
Source§fn euclidean_distance(&self, other: &Polygon<T>) -> T
fn euclidean_distance(&self, other: &Polygon<T>) -> T
Euclidean::distance
method from the Distance
trait insteadSource§impl<T> EuclideanDistance<T, Rect<T>> for Polygon<T>
impl<T> EuclideanDistance<T, Rect<T>> for Polygon<T>
Source§fn euclidean_distance(&self, other: &Rect<T>) -> T
fn euclidean_distance(&self, other: &Rect<T>) -> T
Euclidean::distance
method from the Distance
trait insteadSource§impl<T> EuclideanDistance<T, Triangle<T>> for Polygon<T>
impl<T> EuclideanDistance<T, Triangle<T>> for Polygon<T>
Source§fn euclidean_distance(&self, other: &Triangle<T>) -> T
fn euclidean_distance(&self, other: &Triangle<T>) -> T
Euclidean::distance
method from the Distance
trait insteadSource§impl GeodesicArea<f64> for Polygon
impl GeodesicArea<f64> for Polygon
Source§fn geodesic_perimeter(&self) -> f64
fn geodesic_perimeter(&self) -> f64
Source§fn geodesic_area_signed(&self) -> f64
fn geodesic_area_signed(&self) -> f64
Source§fn geodesic_area_unsigned(&self) -> f64
fn geodesic_area_unsigned(&self) -> f64
Source§impl<C: CoordNum> HasDimensions for Polygon<C>
impl<C: CoordNum> HasDimensions for Polygon<C>
Source§fn dimensions(&self) -> Dimensions
fn dimensions(&self) -> Dimensions
Rect
s are 2-dimensional, but it’s possible to create degenerate Rect
s which
have either 1 or 0 dimensions. Read moreSource§fn boundary_dimensions(&self) -> Dimensions
fn boundary_dimensions(&self) -> Dimensions
Geometry
’s boundary, as used by OGC-SFA. Read moreSource§impl<T> HaversineClosestPoint<T> for Polygon<T>where
T: GeoFloat + FromPrimitive,
impl<T> HaversineClosestPoint<T> for Polygon<T>where
T: GeoFloat + FromPrimitive,
fn haversine_closest_point(&self, from: &Point<T>) -> Closest<T>
Source§impl<T> InteriorPoint for Polygon<T>where
T: GeoFloat,
impl<T> InteriorPoint for Polygon<T>where
T: GeoFloat,
Source§impl<T> Intersects<Coord<T>> for Polygon<T>where
T: GeoNum,
impl<T> Intersects<Coord<T>> for Polygon<T>where
T: GeoNum,
fn intersects(&self, p: &Coord<T>) -> bool
Source§impl<T> Intersects<Geometry<T>> for Polygon<T>
impl<T> Intersects<Geometry<T>> for Polygon<T>
fn intersects(&self, rhs: &Geometry<T>) -> bool
Source§impl<T> Intersects<GeometryCollection<T>> for Polygon<T>
impl<T> Intersects<GeometryCollection<T>> for Polygon<T>
fn intersects(&self, rhs: &GeometryCollection<T>) -> bool
Source§impl<T> Intersects<Line<T>> for Polygon<T>where
T: GeoNum,
impl<T> Intersects<Line<T>> for Polygon<T>where
T: GeoNum,
fn intersects(&self, line: &Line<T>) -> bool
Source§impl<T> Intersects<LineString<T>> for Polygon<T>
impl<T> Intersects<LineString<T>> for Polygon<T>
fn intersects(&self, rhs: &LineString<T>) -> bool
Source§impl<T> Intersects<MultiLineString<T>> for Polygon<T>
impl<T> Intersects<MultiLineString<T>> for Polygon<T>
fn intersects(&self, rhs: &MultiLineString<T>) -> bool
Source§impl<T> Intersects<MultiPoint<T>> for Polygon<T>
impl<T> Intersects<MultiPoint<T>> for Polygon<T>
fn intersects(&self, rhs: &MultiPoint<T>) -> bool
Source§impl<T> Intersects<MultiPolygon<T>> for Polygon<T>
impl<T> Intersects<MultiPolygon<T>> for Polygon<T>
fn intersects(&self, rhs: &MultiPolygon<T>) -> bool
Source§impl<T> Intersects<Point<T>> for Polygon<T>
impl<T> Intersects<Point<T>> for Polygon<T>
fn intersects(&self, rhs: &Point<T>) -> bool
Source§impl<T> Intersects<Polygon<T>> for Coord<T>
impl<T> Intersects<Polygon<T>> for Coord<T>
fn intersects(&self, rhs: &Polygon<T>) -> bool
Source§impl<T> Intersects<Polygon<T>> for Line<T>
impl<T> Intersects<Polygon<T>> for Line<T>
fn intersects(&self, rhs: &Polygon<T>) -> bool
Source§impl<T> Intersects<Polygon<T>> for Rect<T>
impl<T> Intersects<Polygon<T>> for Rect<T>
fn intersects(&self, rhs: &Polygon<T>) -> bool
Source§impl<T> Intersects<Polygon<T>> for Triangle<T>
impl<T> Intersects<Polygon<T>> for Triangle<T>
fn intersects(&self, rhs: &Polygon<T>) -> bool
Source§impl<T> Intersects<Rect<T>> for Polygon<T>where
T: GeoNum,
impl<T> Intersects<Rect<T>> for Polygon<T>where
T: GeoNum,
fn intersects(&self, rect: &Rect<T>) -> bool
Source§impl<T> Intersects<Triangle<T>> for Polygon<T>where
T: GeoNum,
impl<T> Intersects<Triangle<T>> for Polygon<T>where
T: GeoNum,
fn intersects(&self, rect: &Triangle<T>) -> bool
Source§impl<T> Intersects for Polygon<T>where
T: GeoNum,
impl<T> Intersects for Polygon<T>where
T: GeoNum,
fn intersects(&self, polygon: &Polygon<T>) -> bool
Source§impl<'a, T: CoordNum + 'a> LinesIter<'a> for Polygon<T>
impl<'a, T: CoordNum + 'a> LinesIter<'a> for Polygon<T>
type Scalar = T
type Iter = Chain<LineStringIter<'a, <Polygon<T> as LinesIter<'a>>::Scalar>, Flatten<MapLinesIter<'a, Iter<'a, LineString<<Polygon<T> as LinesIter<'a>>::Scalar>>, LineString<<Polygon<T> as LinesIter<'a>>::Scalar>>>>
Source§fn lines_iter(&'a self) -> Self::Iter
fn lines_iter(&'a self) -> Self::Iter
Source§impl<T: CoordNum, NT: CoordNum> MapCoords<T, NT> for Polygon<T>
impl<T: CoordNum, NT: CoordNum> MapCoords<T, NT> for Polygon<T>
Source§impl<T: CoordNum> MapCoordsInPlace<T> for Polygon<T>
impl<T: CoordNum> MapCoordsInPlace<T> for Polygon<T>
Source§impl<T> RTreeObject for Polygon<T>
impl<T> RTreeObject for Polygon<T>
Source§impl<F: GeoFloat> Relate<F> for Polygon<F>
impl<F: GeoFloat> Relate<F> for Polygon<F>
Source§fn geometry_graph(&self, arg_index: usize) -> GeometryGraph<'_, F>
fn geometry_graph(&self, arg_index: usize) -> GeometryGraph<'_, F>
GeometryGraph
fn relate(&self, other: &impl Relate<F>) -> IntersectionMatrix
Source§impl<T> RelativeEq for Polygon<T>
impl<T> RelativeEq for Polygon<T>
Source§fn relative_eq(
&self,
other: &Polygon<T>,
epsilon: <Polygon<T> as AbsDiffEq>::Epsilon,
max_relative: <Polygon<T> as AbsDiffEq>::Epsilon,
) -> bool
fn relative_eq( &self, other: &Polygon<T>, epsilon: <Polygon<T> as AbsDiffEq>::Epsilon, max_relative: <Polygon<T> as AbsDiffEq>::Epsilon, ) -> bool
Equality assertion within a relative limit.
§Examples
use geo_types::{Polygon, polygon};
let a: Polygon<f32> = polygon![(x: 0., y: 0.), (x: 5., y: 0.), (x: 7., y: 9.), (x: 0., y: 0.)];
let b: Polygon<f32> = polygon![(x: 0., y: 0.), (x: 5., y: 0.), (x: 7.01, y: 9.), (x: 0., y: 0.)];
approx::assert_relative_eq!(a, b, max_relative=0.1);
approx::assert_relative_ne!(a, b, max_relative=0.001);
Source§fn default_max_relative() -> <Polygon<T> as AbsDiffEq>::Epsilon
fn default_max_relative() -> <Polygon<T> as AbsDiffEq>::Epsilon
Source§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
RelativeEq::relative_eq
.Source§impl<T> RemoveRepeatedPoints<T> for Polygon<T>where
T: CoordNum + FromPrimitive,
impl<T> RemoveRepeatedPoints<T> for Polygon<T>where
T: CoordNum + FromPrimitive,
Source§fn remove_repeated_points(&self) -> Self
fn remove_repeated_points(&self) -> Self
Create a Polygon with consecutive repeated points removed.
Source§fn remove_repeated_points_mut(&mut self)
fn remove_repeated_points_mut(&mut self)
Remove consecutive repeated points from a Polygon inplace.
Source§impl<T> SimplifyVw<T> for Polygon<T>where
T: CoordFloat,
impl<T> SimplifyVw<T> for Polygon<T>where
T: CoordFloat,
Source§fn simplify_vw(&self, epsilon: &T) -> Polygon<T>
fn simplify_vw(&self, epsilon: &T) -> Polygon<T>
Source§impl<T> SimplifyVwPreserve<T> for Polygon<T>
impl<T> SimplifyVwPreserve<T> for Polygon<T>
Source§fn simplify_vw_preserve(&self, epsilon: &T) -> Polygon<T>
fn simplify_vw_preserve(&self, epsilon: &T) -> Polygon<T>
Source§impl<T: CoordFloat> TriangulateEarcut<T> for Polygon<T>
impl<T: CoordFloat> TriangulateEarcut<T> for Polygon<T>
Source§fn earcut_triangles_raw(&self) -> RawTriangulation<T>
fn earcut_triangles_raw(&self) -> RawTriangulation<T>
earcutr
library: a one-dimensional vector of polygon
vertices (in XY order), and the indices of the triangles within the vertices vector. This
method is less ergonomic than the earcut_triangles
and earcut_triangles_iter
methods, but can be helpful when working in graphics contexts that expect flat vectors of
data. Read moreSource§impl<T> TryFrom<Geometry<T>> for Polygon<T>where
T: CoordNum,
impl<T> TryFrom<Geometry<T>> for Polygon<T>where
T: CoordNum,
Convert a Geometry enum into its inner type.
Fails if the enum case does not match the type you are trying to convert it to.
impl<T> Eq for Polygon<T>
impl<T> StructuralPartialEq for Polygon<T>where
T: CoordNum,
Auto Trait Implementations§
impl<T> Freeze for Polygon<T>
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§
Source§impl<T, M> AffineOps<T> for M
impl<T, M> AffineOps<T> for M
Source§fn affine_transform(&self, transform: &AffineTransform<T>) -> M
fn affine_transform(&self, transform: &AffineTransform<T>) -> M
transform
immutably, outputting a new geometry.Source§fn affine_transform_mut(&mut self, transform: &AffineTransform<T>)
fn affine_transform_mut(&mut self, transform: &AffineTransform<T>)
transform
to mutate self
.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<'a, T, G> ConvexHull<'a, T> for Gwhere
T: GeoNum,
G: CoordsIter<Scalar = T>,
impl<'a, T, G> ConvexHull<'a, T> for Gwhere
T: GeoNum,
G: CoordsIter<Scalar = T>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<'a, T, G> Extremes<'a, T> for Gwhere
G: CoordsIter<Scalar = T>,
T: CoordNum,
impl<'a, T, G> Extremes<'a, T> for Gwhere
G: CoordsIter<Scalar = T>,
T: CoordNum,
Source§impl<T, G> HausdorffDistance<T> for Gwhere
T: GeoFloat,
G: CoordsIter<Scalar = T>,
impl<T, G> HausdorffDistance<T> for Gwhere
T: GeoFloat,
G: CoordsIter<Scalar = T>,
fn hausdorff_distance<Rhs>(&self, rhs: &Rhs) -> Twhere
Rhs: CoordsIter<Scalar = T>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T, G> MinimumRotatedRect<T> for G
impl<T, G> MinimumRotatedRect<T> for G
type Scalar = T
fn minimum_rotated_rect( &self, ) -> Option<Polygon<<G as MinimumRotatedRect<T>>::Scalar>>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<G, IP, IR, T> Rotate<T> for G
impl<G, IP, IR, T> Rotate<T> for G
Source§fn rotate_around_centroid(&self, degrees: T) -> G
fn rotate_around_centroid(&self, degrees: T) -> G
Source§fn rotate_around_centroid_mut(&mut self, degrees: T)
fn rotate_around_centroid_mut(&mut self, degrees: T)
Self::rotate_around_centroid
Source§fn rotate_around_center(&self, degrees: T) -> G
fn rotate_around_center(&self, degrees: T) -> G
Source§fn rotate_around_center_mut(&mut self, degrees: T)
fn rotate_around_center_mut(&mut self, degrees: T)
Self::rotate_around_center
Source§fn rotate_around_point(&self, degrees: T, point: Point<T>) -> G
fn rotate_around_point(&self, degrees: T, point: Point<T>) -> G
Source§fn rotate_around_point_mut(&mut self, degrees: T, point: Point<T>)
fn rotate_around_point_mut(&mut self, degrees: T, point: Point<T>)
Self::rotate_around_point
Source§impl<T, IR, G> Scale<T> for Gwhere
T: CoordFloat,
IR: Into<Option<Rect<T>>>,
G: Clone + AffineOps<T> + BoundingRect<T, Output = IR>,
impl<T, IR, G> Scale<T> for Gwhere
T: CoordFloat,
IR: Into<Option<Rect<T>>>,
G: Clone + AffineOps<T> + BoundingRect<T, Output = IR>,
Source§fn scale(&self, scale_factor: T) -> G
fn scale(&self, scale_factor: T) -> G
Source§fn scale_xy(&self, x_factor: T, y_factor: T) -> G
fn scale_xy(&self, x_factor: T, y_factor: T) -> G
x_factor
and
y_factor
to distort the geometry’s aspect ratio. Read moreSource§fn scale_xy_mut(&mut self, x_factor: T, y_factor: T)
fn scale_xy_mut(&mut self, x_factor: T, y_factor: T)
scale_xy
.Source§fn scale_around_point(
&self,
x_factor: T,
y_factor: T,
origin: impl Into<Coord<T>>,
) -> G
fn scale_around_point( &self, x_factor: T, y_factor: T, origin: impl Into<Coord<T>>, ) -> G
origin
. Read moreSource§fn scale_around_point_mut(
&mut self,
x_factor: T,
y_factor: T,
origin: impl Into<Coord<T>>,
)
fn scale_around_point_mut( &mut self, x_factor: T, y_factor: T, origin: impl Into<Coord<T>>, )
scale_around_point
.Source§impl<T, IR, G> Skew<T> for Gwhere
T: CoordFloat,
IR: Into<Option<Rect<T>>>,
G: Clone + AffineOps<T> + BoundingRect<T, Output = IR>,
impl<T, IR, G> Skew<T> for Gwhere
T: CoordFloat,
IR: Into<Option<Rect<T>>>,
G: Clone + AffineOps<T> + BoundingRect<T, Output = IR>,
Source§fn skew(&self, degrees: T) -> G
fn skew(&self, degrees: T) -> G
Source§fn skew_xy(&self, degrees_x: T, degrees_y: T) -> G
fn skew_xy(&self, degrees_x: T, degrees_y: T) -> G
Source§fn skew_xy_mut(&mut self, degrees_x: T, degrees_y: T)
fn skew_xy_mut(&mut self, degrees_x: T, degrees_y: T)
skew_xy
.Source§fn skew_around_point(&self, xs: T, ys: T, origin: impl Into<Coord<T>>) -> G
fn skew_around_point(&self, xs: T, ys: T, origin: impl Into<Coord<T>>) -> G
origin
, sheared by an
angle along the x and y dimensions. Read moreSource§fn skew_around_point_mut(&mut self, xs: T, ys: T, origin: impl Into<Coord<T>>)
fn skew_around_point_mut(&mut self, xs: T, ys: T, origin: impl Into<Coord<T>>)
skew_around_point
.