Enum shapefile::record::Shape

source ·
pub enum Shape {
Show 14 variants NullShape, Point(Point), PointM(PointM), PointZ(PointZ), Polyline(Polyline), PolylineM(PolylineM), PolylineZ(PolylineZ), Polygon(Polygon), PolygonM(PolygonM), PolygonZ(PolygonZ), Multipoint(Multipoint), MultipointM(MultipointM), MultipointZ(MultipointZ), Multipatch(Multipatch),
}
Expand description

enum of Shapes that can be read or written to a shapefile

§geo-types

shapefile::Shape and geo_types::Geometry<f64> can be converted from one to another, however this conversion is not infallible so it is done using TryFrom

use std::convert::TryFrom;
use shapefile::Shape;
let mut shapes = shapefile::read_shapes("tests/data/line.shp")?;
let last_shape = shapes.pop().unwrap();
let geometry = geo_types::Geometry::<f64>::try_from(last_shape);

assert_eq!(geometry.is_ok(), true);
assert_eq!(geo_types::Geometry::<f64>::try_from(Shape::NullShape).is_err(), true);

Variants§

§

NullShape

§

Point(Point)

§

PointM(PointM)

§

PointZ(PointZ)

§

Polyline(Polyline)

§

PolylineM(PolylineM)

§

PolylineZ(PolylineZ)

§

Polygon(Polygon)

§

PolygonM(PolygonM)

§

PolygonZ(PolygonZ)

§

Multipoint(Multipoint)

§

MultipointM(MultipointM)

§

MultipointZ(MultipointZ)

§

Multipatch(Multipatch)

Implementations§

source§

impl Shape

source

pub fn shapetype(&self) -> ShapeType

Returns the shapetype

Trait Implementations§

source§

impl Display for Shape

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<PointM>> for Shape

source§

fn from(concrete: MultipointM) -> 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<GenericPolygon<Point>> for Shape

source§

fn from(concrete: Polygon) -> Self

Converts to this type from the input type.
source§

impl From<GenericPolygon<PointM>> for Shape

source§

fn from(concrete: PolygonM) -> Self

Converts to this type from the input type.
source§

impl From<GenericPolygon<PointZ>> for Shape

source§

fn from(concrete: PolygonZ) -> Self

Converts to this type from the input type.
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 From<GenericPolyline<PointZ>> for Shape

source§

fn from(concrete: PolylineZ) -> Self

Converts to this type from the input type.
source§

impl From<Multipatch> for Shape

source§

fn from(concrete: Multipatch) -> Self

Converts to this type from the input type.
source§

impl From<Point> for Shape

source§

fn from(concrete: Point) -> Self

Converts to this type from the input type.
source§

impl From<PointM> for Shape

source§

fn from(concrete: PointM) -> Self

Converts to this type from the input type.
source§

impl From<PointZ> for Shape

source§

fn from(concrete: PointZ) -> Self

Converts to this type from the input type.
source§

impl HasShapeType for Shape

source§

fn shapetype() -> ShapeType

Returns the ShapeType
source§

impl ReadableShape for Shape

source§

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

source§

impl TryFrom<Geometry> for Shape

Converts a Geometry to a Shape

Since all Geometries are in 2D, the resulting shape will be 2D (Polygon, Polyline, etc and not PolylineM, PolylineZ, etc)

Fails if the geometry is a GeometryCollection, Rect, or Triangle

§

type Error = &'static str

The type returned in the event of a conversion error.
source§

fn try_from(geometry: Geometry<f64>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Shape> for Multipoint

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(shape: Shape) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Shape> for MultipointM

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(shape: Shape) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Shape> for MultipointZ

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(shape: Shape) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Shape> for Polygon

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(shape: Shape) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Shape> for PolygonM

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(shape: Shape) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Shape> for PolygonZ

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(shape: Shape) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Shape> for Polyline

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(shape: Shape) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Shape> for PolylineM

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(shape: Shape) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Shape> for PolylineZ

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(shape: Shape) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Shape> for Geometry<f64>

Tries to convert a shapefile’s Shape into a geo_types::Geometry

This conversion can fail because the conversion of shapefile’s polygons & multipatch into their geo_types counter parts can fail. And the NullShape has no equivalent Geometry;

§

type Error = &'static str

The type returned in the event of a conversion error.
source§

fn try_from(shape: Shape) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Shape> for Multipatch

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(shape: Shape) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Shape> for Point

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(shape: Shape) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Shape> for PointM

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(shape: Shape) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Shape> for PointZ

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(shape: Shape) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Shape

§

impl RefUnwindSafe for Shape

§

impl Send for Shape

§

impl Sync for Shape

§

impl Unpin for Shape

§

impl UnwindSafe for Shape

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