[][src]Trait shapefile::record::traits::MultipartShape

pub trait MultipartShape<PointType>: MultipointShape<PointType> {
    fn parts_indices(&self) -> &[i32];

    fn part(&self, index: usize) -> Option<&[PointType]> { ... }
fn parts(&self) -> PartIterator<PointType, Self> { ... } }

Trait for the Shapes that may have multiple parts

Required methods

fn parts_indices(&self) -> &[i32]

Returns a non mutable slice of the parts as written in the file:

An array of length NumParts. Stores, for each PolyLine, the index of its first point in the points array. Array indexes are with respect to 0

Examples

use shapefile::record::MultipartShape;
let filepath = "tests/data/linez.shp";
let polylines_z = shapefile::read_as::<&str, shapefile::PolylineZ>(filepath).unwrap();

let poly_z = &polylines_z[0];
assert_eq!(poly_z.parts_indices(), &[0, 5, 7]);
Loading content...

Provided methods

fn part(&self, index: usize) -> Option<&[PointType]>

Returns the slice of points corresponding to part n°ìndex if the shape actually has multiple parts

Examples

use shapefile::record::MultipartShape;
let filepath = "tests/data/linez.shp";
let polylines_z = shapefile::read_as::<&str, shapefile::PolylineZ>(filepath).unwrap();

let poly_z = &polylines_z[0];
for points in poly_z.parts() {
    println!("{} points", points.len());
}

Important traits for PartIterator<'a, PointType, Shape>
fn parts(&self) -> PartIterator<PointType, Self>

Returns an iterator over the parts of a MultipartShape

Examples

use shapefile::record::MultipartShape;
let filepath = "tests/data/linez.shp";
let polylines_z = shapefile::read_as::<&str, shapefile::PolylineZ>(filepath).unwrap();

let poly_z = &polylines_z[0];
let poly_z_parts: Vec<&[shapefile::PointZ]> = poly_z.parts().collect();
assert_eq!(poly_z_parts.len(), 3);
Loading content...

Implementors

impl MultipartShape<PointZ> for Multipatch[src]

impl<PointType> MultipartShape<PointType> for GenericPolygon<PointType>[src]

impl<PointType> MultipartShape<PointType> for GenericPolyline<PointType>[src]

Loading content...