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]

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]

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: Debug> Debug for GenericMultipoint<PointType>[src]

impl From<GenericMultipoint<Point>> for Shape[src]

impl From<GenericMultipoint<PointM>> for Shape[src]

impl From<GenericMultipoint<PointZ>> for Shape[src]

impl<PointType> From<MultiPoint<f64>> for GenericMultipoint<PointType> where
    PointType: From<Point<f64>> + 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]

type Output = I::Output

The returned type after indexing.

impl<PointType: PartialEq> PartialEq<GenericMultipoint<PointType>> 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> 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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<S> ReadableShape for S where
    S: ConcreteReadableShape
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.