GenericPolyline

Struct GenericPolyline 

Source
pub struct GenericPolyline<PointType> { /* private fields */ }
Expand description

Generic struct to create Polyline; PolylineM, PolylineZ

Polylines can have multiple parts.

Polylines parts must have 2 at least 2 points

To create a polyline with only one part use new, to create a polyline with multiple parts use with_parts

§geo-types

shapefile’s Polyline can be converted to geo_types’s MultiLineString<f64>

geo-types’s Line, LineString, MultiLineString can be converted to shapefile’s Polyline

let mut polylines = shapefile::read_shapes_as::<_, shapefile::Polyline>("tests/data/line.shp")?;
let geo_polyline: geo_types::MultiLineString<f64> = polylines.pop().unwrap().into();
let polyline = shapefile::Polyline::from(geo_polyline);

Implementations§

Source§

impl<PointType: ShrinkablePoint + GrowablePoint + Copy> GenericPolyline<PointType>

Creating a Polyline

Source

pub fn new(points: Vec<PointType>) -> Self

§Examples

Polyline with single part

use shapefile::{Point, Polyline};
let points = vec![
    Point::new(1.0, 1.0),
    Point::new(2.0, 2.0),
];
let poly = Polyline::new(points);
§panic

This will panic if the vec has less than 2 points

Source

pub fn with_parts(parts: Vec<Vec<PointType>>) -> Self

§Examples

Polyline with multiple parts

use shapefile::{Point, Polyline};
let first_part = vec![
    Point::new(1.0, 1.0),
    Point::new(2.0, 2.0),
];

let second_part = vec![
    Point::new(3.0, 1.0),
    Point::new(5.0, 6.0),
];

let third_part = vec![
    Point::new(17.0, 15.0),
    Point::new(18.0, 19.0),
    Point::new(20.0, 19.0),
];
let poly = Polyline::with_parts(vec![first_part, second_part, third_part]);
§panic

This will panic if any of the parts are less than 2 points

Source§

impl<PointType> GenericPolyline<PointType>

Source

pub fn bbox(&self) -> &GenericBBox<PointType>

Returns the bounding box associated to the polyline

Source

pub fn parts(&self) -> &Vec<Vec<PointType>>

Returns a reference to all the parts

Source

pub fn part(&self, index: usize) -> Option<&Vec<PointType>>

Returns a reference to a part

Source

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

Consumes the polyline and returns the parts

Source

pub fn total_point_count(&self) -> usize

Returns the number of points contained in all the parts

Trait Implementations§

Source§

impl<PointType: Clone> Clone for GenericPolyline<PointType>

Source§

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

Returns a duplicate 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 GenericPolyline<PointType>

Source§

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

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

impl From<GenericPolyline<Point>> for Shape

Source§

fn from(concrete: Polyline) -> Self

Converts to this type from the input type.
Source§

impl From<GenericPolyline<PointM>> for Shape

Source§

fn from(concrete: PolylineM) -> Self

Converts to this type from the input type.
Source§

impl<PointType: HasXY> From<GenericPolyline<PointType>> for GenericPolygon<PointType>

Source§

fn from(polyline: GenericPolyline<PointType>) -> Self

Converts to this type from the input type.
Source§

impl<PointType> From<GenericPolyline<PointType>> for MultiLineString<f64>
where PointType: Copy, Coordinate<f64>: From<PointType>,

Available on crate feature geo-types only.
Source§

fn from(polyline: GenericPolyline<PointType>) -> Self

Converts to this type from the input type.
Source§

impl From<GenericPolyline<PointZ>> for Shape

Source§

fn from(concrete: PolylineZ) -> Self

Converts to this type from the input type.
Source§

impl<PointType> From<Line> for GenericPolyline<PointType>
where PointType: From<Point<f64>> + ShrinkablePoint + GrowablePoint + Copy,

Available on crate feature geo-types only.
Source§

fn from(line: Line<f64>) -> Self

Converts to this type from the input type.
Source§

impl<PointType> From<LineString> for GenericPolyline<PointType>

Available on crate feature geo-types only.
Source§

fn from(line: LineString<f64>) -> Self

Converts to this type from the input type.
Source§

impl<PointType> From<MultiLineString> for GenericPolyline<PointType>

Available on crate feature geo-types only.
Source§

fn from(mls: MultiLineString<f64>) -> Self

Converts to this type from the input type.
Source§

impl<PointType: PartialEq> PartialEq for GenericPolyline<PointType>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<PointType> StructuralPartialEq for GenericPolyline<PointType>

Auto Trait Implementations§

§

impl<PointType> Freeze for GenericPolyline<PointType>
where PointType: Freeze,

§

impl<PointType> RefUnwindSafe for GenericPolyline<PointType>
where PointType: RefUnwindSafe,

§

impl<PointType> Send for GenericPolyline<PointType>
where PointType: Send,

§

impl<PointType> Sync for GenericPolyline<PointType>
where PointType: Sync,

§

impl<PointType> Unpin for GenericPolyline<PointType>
where PointType: Unpin,

§

impl<PointType> UnwindSafe for GenericPolyline<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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, G> ToGeoMultiLineString<T> for G
where T: CoordNum, G: MultiLineStringTrait<T = T>,

Source§

fn to_multi_line_string(&self) -> MultiLineString<T>

Convert to a geo_types MultiLineString.
Source§

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

Source§

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§

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

Source§

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

Source§

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.