Struct shapefile::writer::ShapeWriter
source · 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>
impl<T: Write + Seek> ShapeWriter<T>
sourcepub fn new(shp_dest: T) -> Self
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
pub fn with_shx(shp_dest: T, shx_dest: T) -> Self
sourcepub fn write_shape<S: EsriShape>(&mut self, shape: &S) -> Result<(), Error>
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))?;
sourcepub fn write_shapes<'a, S: EsriShape + 'a, C: IntoIterator<Item = &'a S>>(
self,
container: C
) -> Result<(), Error>
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])?;
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more