pub struct ShapeFileReader<T: Reader, P: MValueCompatible = Properties> { /* private fields */ }Expand description
§The Shapefile Reader
§Description
Reads data from a shapefile
Implements the FeatureReader trait
§Usage
NOTE: It’s recommended to not parse the shapefile directly but instead:
This ensures the other files paired with the shapefile are loaded to properly handle the projection and properties data.
§Usage
The methods you have access to:
ShapeFileReader::new: Create a new ShapeFileReaderShapeFileReader::get_header: Get the file header dataShapeFileReader::iter: Iterate over the features in the shapefile
§From Path (Recommended as it will ensure to pull in associated files):
use gistools::{parsers::{FileReader, FeatureReader}, readers::{ShapeFileReader, file::shapefile_from_path}};
use s2json::MValue;
use std::{collections::BTreeMap, path::PathBuf};
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("tests/readers/shapefile/fixtures/utf.shp");
let path_str = path.to_str().unwrap();
#[derive(Default, Debug, Clone, MValue, PartialEq)]
struct Props {
field: String,
}
let shp: ShapeFileReader<FileReader, Props> =
shapefile_from_path(path_str, BTreeMap::from([("a".into(), "b".into())]));
let features: Vec<_> = shp.iter().collect();
assert_eq!(features.len(), 2);§Links
Implementations§
Source§impl<T: Reader, P: MValueCompatible> ShapeFileReader<T, P>
impl<T: Reader, P: MValueCompatible> ShapeFileReader<T, P>
Sourcepub fn new(
reader: T,
dbf: Option<DataBaseFile<T, P>>,
transform: Option<Transformer>,
) -> ShapeFileReader<T, P>
pub fn new( reader: T, dbf: Option<DataBaseFile<T, P>>, transform: Option<Transformer>, ) -> ShapeFileReader<T, P>
Create a new Shapefile Reader
Sourcepub fn get_header(&self) -> &SHPHeader
pub fn get_header(&self) -> &SHPHeader
Return a reference to the header
Trait Implementations§
Source§impl<T: Clone + Reader, P: Clone + MValueCompatible> Clone for ShapeFileReader<T, P>
impl<T: Clone + Reader, P: Clone + MValueCompatible> Clone for ShapeFileReader<T, P>
Source§fn clone(&self) -> ShapeFileReader<T, P>
fn clone(&self) -> ShapeFileReader<T, P>
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug + Reader, P: Debug + MValueCompatible> Debug for ShapeFileReader<T, P>
impl<T: Debug + Reader, P: Debug + MValueCompatible> Debug for ShapeFileReader<T, P>
Source§impl<T: Reader, P: MValueCompatible> FeatureReader<(), P, Map<String, ValueType>> for ShapeFileReader<T, P>
A feature reader trait with a callback-based approach
impl<T: Reader, P: MValueCompatible> FeatureReader<(), P, Map<String, ValueType>> for ShapeFileReader<T, P>
A feature reader trait with a callback-based approach
Source§type FeatureIterator<'a> = ShapefileIterator<'a, T, P>
where
T: 'a,
P: 'a
type FeatureIterator<'a> = ShapefileIterator<'a, T, P> where T: 'a, P: 'a
The Feature Reader should implement an iterator of some kind
Source§fn iter(&self) -> Self::FeatureIterator<'_>
fn iter(&self) -> Self::FeatureIterator<'_>
All readers have an iter function that returns a Iterator struct
Auto Trait Implementations§
impl<T, P> Freeze for ShapeFileReader<T, P>where
T: Freeze,
impl<T, P = Map<String, ValueType>> !RefUnwindSafe for ShapeFileReader<T, P>
impl<T, P = Map<String, ValueType>> !Send for ShapeFileReader<T, P>
impl<T, P = Map<String, ValueType>> !Sync for ShapeFileReader<T, P>
impl<T, P> Unpin for ShapeFileReader<T, P>
impl<T, P = Map<String, ValueType>> !UnwindSafe for ShapeFileReader<T, P>
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more