Struct shapefile::record::multipoint::GenericMultipoint
source · pub struct GenericMultipoint<PointType> { /* private fields */ }
Expand description
Generic struct to create the Multipoint, MultipointM, MultipointZ types
Multipoints are a collection of… multiple points,
they can be created from Vec
of points using the From
trait
or using the new
method.
Multipoint
shapes only offers non-mutable access to the points data,
to be able to mutate it you have to move the points data out of the struct.
use shapefile::{Multipoint, Point};
let multipoint = Multipoint::from(vec![
Point::new(1.0, 1.0),
Point::new(2.0, 2.0),
]);
assert_eq!(multipoint[0], Point::new(1.0, 1.0));
let points: Vec<Point> = multipoint.into();
assert_eq!(points.len(), 2);
§geo-types
Multipoints are convertible to the geo-types’s Multipoint
let mut multipoints = shapefile::read_shapes_as::<_, shapefile::Multipoint>("tests/data/multipoint.shp")?;
let geo_multipoint: geo_types::MultiPoint<f64> = multipoints.pop().unwrap().into();
let multipoint = shapefile::Multipoint::from(geo_multipoint);
Implementations§
source§impl<PointType: ShrinkablePoint + GrowablePoint + Copy> GenericMultipoint<PointType>
impl<PointType: ShrinkablePoint + GrowablePoint + Copy> GenericMultipoint<PointType>
sourcepub fn new(points: Vec<PointType>) -> Self
pub fn new(points: Vec<PointType>) -> Self
Creates a new Multipoint shape
§Examples
Creating Multipoint
use shapefile::{Multipoint, Point};
let points = vec![
Point::new(1.0, 1.0),
Point::new(2.0, 2.0),
];
let multipoint = Multipoint::new(points);
Creating a MultipointM
use shapefile::{MultipointM, PointM, NO_DATA};
let points = vec![
PointM::new(1.0, 1.0, NO_DATA),
PointM::new(2.0, 2.0, NO_DATA),
];
let multipointm = MultipointM::new(points);
Creating a MultipointZ
use shapefile::{MultipointZ, PointZ, NO_DATA};
let points = vec![
PointZ::new(1.0, 1.0, 1.0, NO_DATA),
PointZ::new(2.0, 2.0, 2.0, NO_DATA),
];
let multipointz = MultipointZ::new(points);
source§impl<PointType> GenericMultipoint<PointType>
impl<PointType> GenericMultipoint<PointType>
sourcepub fn bbox(&self) -> &GenericBBox<PointType>
pub fn bbox(&self) -> &GenericBBox<PointType>
Returns the bbox
§Example
use shapefile::{MultipointZ, PointZ, NO_DATA};
let multipointz = MultipointZ::new(vec![
PointZ::new(1.0, 4.0, 1.2, 4.2),
PointZ::new(2.0, 6.0, 4.0, 13.37),
]);
let bbox = multipointz.bbox();
assert_eq!(bbox.min.x, 1.0);
assert_eq!(bbox.max.x, 2.0);
assert_eq!(bbox.m_range(), [4.2, 13.37])
sourcepub fn points(&self) -> &[PointType]
pub fn points(&self) -> &[PointType]
Returns a non-mutable slice of point
sourcepub fn point(&self, index: usize) -> Option<&PointType>
pub fn point(&self, index: usize) -> Option<&PointType>
Returns a reference to a point
§Example
use shapefile::{MultipointZ, PointZ};
let multipointz = MultipointZ::new(vec![
PointZ::new(1.0, 4.0, 1.2, 4.2),
PointZ::new(2.0, 6.0, 4.0, 13.37),
]);
assert_eq!(multipointz.point(0), Some(&PointZ::new(1.0, 4.0, 1.2, 4.2)));
assert_eq!(multipointz.point(2), None);
sourcepub fn into_inner(self) -> Vec<PointType>
pub fn into_inner(self) -> Vec<PointType>
Consumes the shape, returning the points
Trait Implementations§
source§impl<PointType: Clone> Clone for GenericMultipoint<PointType>
impl<PointType: Clone> Clone for GenericMultipoint<PointType>
source§fn clone(&self) -> GenericMultipoint<PointType>
fn clone(&self) -> GenericMultipoint<PointType>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<PointType: Debug> Debug for GenericMultipoint<PointType>
impl<PointType: Debug> Debug for GenericMultipoint<PointType>
source§impl From<GenericMultipoint<Point>> for Shape
impl From<GenericMultipoint<Point>> for Shape
source§fn from(concrete: Multipoint) -> Self
fn from(concrete: Multipoint) -> Self
Converts to this type from the input type.
source§impl From<GenericMultipoint<Point>> for Vec<Point>
impl From<GenericMultipoint<Point>> for Vec<Point>
source§fn from(multipoints: GenericMultipoint<Point>) -> Self
fn from(multipoints: GenericMultipoint<Point>) -> Self
Converts to this type from the input type.
source§impl From<GenericMultipoint<PointM>> for Shape
impl From<GenericMultipoint<PointM>> for Shape
source§fn from(concrete: MultipointM) -> Self
fn from(concrete: MultipointM) -> Self
Converts to this type from the input type.
source§impl From<GenericMultipoint<PointM>> for Vec<PointM>
impl From<GenericMultipoint<PointM>> for Vec<PointM>
source§fn from(multipoints: GenericMultipoint<PointM>) -> Self
fn from(multipoints: GenericMultipoint<PointM>) -> Self
Converts to this type from the input type.
source§impl<PointType> From<GenericMultipoint<PointType>> for MultiPoint<f64>
impl<PointType> From<GenericMultipoint<PointType>> for MultiPoint<f64>
source§fn from(multi_points: GenericMultipoint<PointType>) -> Self
fn from(multi_points: GenericMultipoint<PointType>) -> Self
Converts to this type from the input type.
source§impl From<GenericMultipoint<PointZ>> for Shape
impl From<GenericMultipoint<PointZ>> for Shape
source§fn from(concrete: MultipointZ) -> Self
fn from(concrete: MultipointZ) -> Self
Converts to this type from the input type.
source§impl From<GenericMultipoint<PointZ>> for Vec<PointZ>
impl From<GenericMultipoint<PointZ>> for Vec<PointZ>
source§fn from(multipoints: GenericMultipoint<PointZ>) -> Self
fn from(multipoints: GenericMultipoint<PointZ>) -> Self
Converts to this type from the input type.
source§impl<PointType> From<MultiPoint> for GenericMultipoint<PointType>
impl<PointType> From<MultiPoint> for GenericMultipoint<PointType>
source§fn from(mp: MultiPoint<f64>) -> Self
fn from(mp: MultiPoint<f64>) -> Self
Converts to this type from the input type.
source§impl<PointType> From<Vec<PointType>> for GenericMultipoint<PointType>
impl<PointType> From<Vec<PointType>> for GenericMultipoint<PointType>
source§impl<PointType, I: SliceIndex<[PointType]>> Index<I> for GenericMultipoint<PointType>
impl<PointType, I: SliceIndex<[PointType]>> Index<I> for GenericMultipoint<PointType>
§type Output = <I as SliceIndex<[PointType]>>::Output
type Output = <I as SliceIndex<[PointType]>>::Output
The returned type after indexing.
source§impl<PointType: PartialEq> PartialEq for GenericMultipoint<PointType>
impl<PointType: PartialEq> PartialEq for GenericMultipoint<PointType>
source§fn eq(&self, other: &GenericMultipoint<PointType>) -> bool
fn eq(&self, other: &GenericMultipoint<PointType>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl<PointType> StructuralPartialEq for GenericMultipoint<PointType>
Auto Trait Implementations§
impl<PointType> Freeze for GenericMultipoint<PointType>where
PointType: Freeze,
impl<PointType> RefUnwindSafe for GenericMultipoint<PointType>where
PointType: RefUnwindSafe,
impl<PointType> Send for GenericMultipoint<PointType>where
PointType: Send,
impl<PointType> Sync for GenericMultipoint<PointType>where
PointType: Sync,
impl<PointType> Unpin for GenericMultipoint<PointType>where
PointType: Unpin,
impl<PointType> UnwindSafe for GenericMultipoint<PointType>where
PointType: UnwindSafe,
Blanket Implementations§
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
Mutably borrows from an owned value. Read more