pub struct ShapeWriter<T: Write + Seek> { /* private fields */ }
Expand description

struct that handles the writing of the .shp and (optionally) the .idx

The recommended way to create a ShapeWriter by using ShapeWriter::from_path

§Important

As this writer does not write the .dbf, it does not write what is considered a complete (thus valid) shapefile.

Implementations§

source§

impl<T: Write + Seek> ShapeWriter<T>

source

pub fn new(shp_dest: T) -> Self

Creates a writer that can be used to write a new shapefile.

The dest argument is only for the .shp

source

pub fn with_shx(shp_dest: T, shx_dest: T) -> Self

source

pub fn write_shape<S: EsriShape>(&mut self, shape: &S) -> Result<(), Error>

Write the shape to the file

§Examples
use shapefile::Point;
let mut writer = shapefile::ShapeWriter::from_path("points.shp")?;

writer.write_shape(&Point::new(0.0, 0.0))?;
writer.write_shape(&Point::new(1.0, 0.0))?;
writer.write_shape(&Point::new(2.0, 0.0))?;
source

pub fn write_shapes<'a, S: EsriShape + 'a, C: IntoIterator<Item = &'a S>>( self, container: C ) -> Result<(), Error>

Writes a collection of shapes to the file

§Examples
use shapefile::Point;
let mut writer = shapefile::ShapeWriter::from_path("points.shp")?;
let points = vec![Point::new(0.0, 0.0), Point::new(1.0, 0.0), Point::new(2.0, 0.0)];

writer.write_shapes(&points)?;
use shapefile::{Point, Polyline};
let mut writer = shapefile::ShapeWriter::from_path("polylines.shp")?;
let points = vec![Point::new(0.0, 0.0), Point::new(1.0, 0.0), Point::new(2.0, 0.0)];
let polyline = Polyline::new(points);

writer.write_shapes(&vec![polyline])?;
source§

impl ShapeWriter<BufWriter<File>>

source

pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Creates a new writer from a path. Creates both a .shp and .shx files

§Examples
let writer = shapefile::ShapeWriter::from_path("new_file.shp");

Trait Implementations§

source§

impl<T: Write + Seek> Drop for ShapeWriter<T>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for ShapeWriter<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for ShapeWriter<T>
where T: RefUnwindSafe,

§

impl<T> Send for ShapeWriter<T>
where T: Send,

§

impl<T> Sync for ShapeWriter<T>
where T: Sync,

§

impl<T> Unpin for ShapeWriter<T>
where T: Unpin,

§

impl<T> UnwindSafe for ShapeWriter<T>
where T: 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<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.