Function shapefile::reader::read_shapes_as
source · pub fn read_shapes_as<T: AsRef<Path>, S: ReadableShape>(
path: T
) -> Result<Vec<S>, Error>
Expand description
Function to read all the Shapes in a file as a certain type
It does not open the .dbf file.
Fails and return Err(Error:MismatchShapeType)
Examples
let polylines = shapefile::read_shapes_as::<_, shapefile::PolylineZ>("tests/data/polygon.shp");
assert_eq!(polylines.is_err(), true);
let polygons = shapefile::read_shapes_as::<_, shapefile::Polygon>("tests/data/polygon.shp");
assert_eq!(polygons.is_ok(), true);
If the reading is successful, the returned Vec<S:ReadShape>>
is a vector of actual structs
Useful if you know in at compile time which kind of shape you expect the file to have