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>

source

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>

source

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])
source

pub fn points(&self) -> &[PointType]

Returns a non-mutable slice of point

source

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);
source

pub fn into_inner(self) -> Vec<PointType>

Consumes the shape, returning the points

Trait Implementations§

source§

impl<PointType: Clone> Clone for GenericMultipoint<PointType>

source§

fn clone(&self) -> GenericMultipoint<PointType>

Returns a copy 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<PointType: Debug> Debug for GenericMultipoint<PointType>

source§

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

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

impl From<GenericMultipoint<Point>> for Shape

source§

fn from(concrete: Multipoint) -> Self

Converts to this type from the input type.
source§

impl From<GenericMultipoint<Point>> for Vec<Point>

source§

fn from(multipoints: GenericMultipoint<Point>) -> Self

Converts to this type from the input type.
source§

impl From<GenericMultipoint<PointM>> for Shape

source§

fn from(concrete: MultipointM) -> Self

Converts to this type from the input type.
source§

impl From<GenericMultipoint<PointM>> for Vec<PointM>

source§

fn from(multipoints: GenericMultipoint<PointM>) -> Self

Converts to this type from the input type.
source§

impl<PointType> From<GenericMultipoint<PointType>> for MultiPoint<f64>
where Point<f64>: From<PointType>,

source§

fn from(multi_points: GenericMultipoint<PointType>) -> Self

Converts to this type from the input type.
source§

impl From<GenericMultipoint<PointZ>> for Shape

source§

fn from(concrete: MultipointZ) -> Self

Converts to this type from the input type.
source§

impl From<GenericMultipoint<PointZ>> for Vec<PointZ>

source§

fn from(multipoints: GenericMultipoint<PointZ>) -> Self

Converts to this type from the input type.
source§

impl<PointType> From<MultiPoint> for GenericMultipoint<PointType>
where PointType: From<Point<f64>> + ShrinkablePoint + GrowablePoint + Copy,

source§

fn from(mp: MultiPoint<f64>) -> Self

Converts to this type from the input type.
source§

impl<PointType> From<Vec<PointType>> for GenericMultipoint<PointType>
where PointType: ShrinkablePoint + GrowablePoint + Copy,

source§

fn from(points: Vec<PointType>) -> Self

Converts to this type from the input type.
source§

impl<PointType, I: SliceIndex<[PointType]>> Index<I> for GenericMultipoint<PointType>

§

type Output = <I as SliceIndex<[PointType]>>::Output

The returned type after indexing.
source§

fn index(&self, index: I) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<PointType: PartialEq> PartialEq for GenericMultipoint<PointType>

source§

fn eq(&self, other: &GenericMultipoint<PointType>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

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> 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<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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<S> ReadableShape for S

source§

fn read_from<T>(source: &mut T, record_size: i32) -> Result<S, Error>
where T: Read,

source§

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

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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.