Struct shapefile::record::multipoint::GenericMultipoint [−][src]
pub struct GenericMultipoint<PointType> { /* fields omitted */ }
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
impl<PointType: ShrinkablePoint + GrowablePoint + Copy> GenericMultipoint<PointType>
[src]
impl<PointType: ShrinkablePoint + GrowablePoint + Copy> GenericMultipoint<PointType>
[src]pub fn new(points: Vec<PointType>) -> Self
[src]
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);
impl<PointType> GenericMultipoint<PointType>
[src]
impl<PointType> GenericMultipoint<PointType>
[src]pub fn bbox(&self) -> &GenericBBox<PointType>
[src]
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])
pub fn points(&self) -> &[PointType]
[src]
Returns a non-mutable slice of point
pub fn point(&self, index: usize) -> Option<&PointType>
[src]
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);
pub fn into_inner(self) -> Vec<PointType>
[src]
Consumes the shape, returning the points
Trait Implementations
impl<PointType: Clone> Clone for GenericMultipoint<PointType>
[src]
impl<PointType: Clone> Clone for GenericMultipoint<PointType>
[src]fn clone(&self) -> GenericMultipoint<PointType>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<PointType: Debug> Debug for GenericMultipoint<PointType>
[src]
impl<PointType: Debug> Debug for GenericMultipoint<PointType>
[src]impl From<GenericMultipoint<Point>> for Shape
[src]
impl From<GenericMultipoint<Point>> for Shape
[src]fn from(concrete: Multipoint) -> Self
[src]
impl From<GenericMultipoint<PointM>> for Shape
[src]
impl From<GenericMultipoint<PointM>> for Shape
[src]fn from(concrete: MultipointM) -> Self
[src]
impl From<GenericMultipoint<PointZ>> for Shape
[src]
impl From<GenericMultipoint<PointZ>> for Shape
[src]fn from(concrete: MultipointZ) -> Self
[src]
impl<PointType> From<MultiPoint<f64>> for GenericMultipoint<PointType> where
PointType: From<Point<f64>> + ShrinkablePoint + GrowablePoint + Copy,
[src]
impl<PointType> From<MultiPoint<f64>> for GenericMultipoint<PointType> where
PointType: From<Point<f64>> + ShrinkablePoint + GrowablePoint + Copy,
[src]fn from(mp: MultiPoint<f64>) -> Self
[src]
impl<PointType> From<Vec<PointType, Global>> for GenericMultipoint<PointType> where
PointType: ShrinkablePoint + GrowablePoint + Copy,
[src]
impl<PointType> From<Vec<PointType, Global>> for GenericMultipoint<PointType> where
PointType: ShrinkablePoint + GrowablePoint + Copy,
[src]impl<PointType, I: SliceIndex<[PointType]>> Index<I> for GenericMultipoint<PointType>
[src]
impl<PointType, I: SliceIndex<[PointType]>> Index<I> for GenericMultipoint<PointType>
[src]impl<PointType: PartialEq> PartialEq<GenericMultipoint<PointType>> for GenericMultipoint<PointType>
[src]
impl<PointType: PartialEq> PartialEq<GenericMultipoint<PointType>> for GenericMultipoint<PointType>
[src]fn eq(&self, other: &GenericMultipoint<PointType>) -> bool
[src]
fn ne(&self, other: &GenericMultipoint<PointType>) -> bool
[src]
impl<PointType> StructuralPartialEq for GenericMultipoint<PointType>
[src]
impl<PointType> StructuralPartialEq for GenericMultipoint<PointType>
[src]Auto Trait Implementations
impl<PointType> RefUnwindSafe for GenericMultipoint<PointType> where
PointType: RefUnwindSafe,
impl<PointType> RefUnwindSafe for GenericMultipoint<PointType> where
PointType: RefUnwindSafe,
impl<PointType> Send for GenericMultipoint<PointType> where
PointType: Send,
impl<PointType> Send for GenericMultipoint<PointType> where
PointType: Send,
impl<PointType> Sync for GenericMultipoint<PointType> where
PointType: Sync,
impl<PointType> Sync for GenericMultipoint<PointType> where
PointType: Sync,
impl<PointType> Unpin for GenericMultipoint<PointType> where
PointType: Unpin,
impl<PointType> Unpin for GenericMultipoint<PointType> where
PointType: Unpin,
impl<PointType> UnwindSafe for GenericMultipoint<PointType> where
PointType: UnwindSafe,
impl<PointType> UnwindSafe for GenericMultipoint<PointType> where
PointType: UnwindSafe,