pub enum GISReader<T: Reader + Debug> {
Show 15 variants
CSV(Box<CSVReader<T, Properties>>),
GeoTIFF(Box<GeoTIFFReader<T>>),
GPX(Box<GPXReader>),
GRIB2(Box<GRIB2Reader>),
GTFS(Box<GTFSScheduleReader>),
JSON(Box<JSONReader<T, (), Properties, MValue>>),
JSONLD(Box<NewLineDelimitedJSONReader<T, (), Properties, MValue>>),
JSONSQ(Box<SequenceJSONReader<T, (), Properties, MValue>>),
LAS(Box<LASReader<T>>),
LAZ(Box<LAZReader<T>>),
NADGrid(Box<NadGridReader<T>>),
NetCDF(Box<NetCDFReader<T>>),
OSM(Box<OSMLocalReader<T>>),
Shapefile(Box<ShapeFileReader<T, Properties>>),
WKT(Box<WKTGeometryReader>),
}Expand description
§GIS Reader
§Description
Parse all data types supported by this library
Implements the FeatureReader trait
It is recommended to use this reader for testing or ease of access, but the better alternative is to use the file type readers directly. Here is the list of readers:
CSVReader: Parse (Geo|S2)JSON from a file that is in the CSV formatGeoTIFFReader: This class reads a GeoTIFF file and returns a list of GeoTIFF images.GPXReader: The GPX Reader is an XML-based GPS Exchange Format (GPX) reader.GRIB2Reader: This class reads a GRIB2 file and returns a list of GRIB2 products.GTFSScheduleReader: Schedule class that pulls in all of the GTFS schedule files and parses them into a single objectJSONReader: Parse (Geo|S2)JSON. Can handle millions of features.NewLineDelimitedJSONReader: Parse (Geo|S2)JSON from a file that is in a newline-delimited formatSequenceJSONReader: Parse GeoJSON from a file that is in thegeojson-text-sequencesformat.LASReader: Reads LAS data. Supports up to the LAS 1.4 specification.LAZReader: Reads LAS zipped data. Supports LAS 1.4 specification although missing some support.NadGridReader: Loads/reads a binary NTv2 file (.gsb) implementing the {@link FeatureIterator} interface.NetCDFReader: Read the NetCDF v3.x file format.OSMLocalReader: OSM PBF Data. Direct use allows for the use of theOSMFileReaderas wellShapeFileReader: Reads data from a shapefile implementing the {@link FeatureIterator} interfaceWKTGeometryReader: Parse a collection of WKT geometries from a string
§Usage
§Read from a file
use gistools::{
parsers::{FeatureReader},
readers::{GISReader, ReaderType},
};
use s2json::{MValue, Properties, VectorFeature};
use std::path::PathBuf;
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("tests/readers/csv/fixtures/basic.csv");
let reader = GISReader::from_path(path, None, None);
assert_eq!(reader.get_type(), ReaderType::CSV);
let features: Vec<VectorFeature<(), Properties, MValue>> = reader.iter().collect();§Read from a buffer
It is recommended to use a Buffer Reader when the file is small because it is more efficient
use gistools::{
parsers::{FeatureReader},
readers::{GISReader, ReaderType},
};
use s2json::{MValue, Properties, VectorFeature};
// ignore the use of the filesystem, setup is just for the example
use std::path::PathBuf;
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("tests/readers/csv/fixtures/basic.csv");
let bytes = std::fs::read(path.clone()).unwrap();
let reader = GISReader::from_buffer(bytes, ReaderType::CSV, None);
let features: Vec<VectorFeature<(), Properties, MValue>> = reader.iter().collect();Variants§
CSV(Box<CSVReader<T, Properties>>)
CSV data
GeoTIFF(Box<GeoTIFFReader<T>>)
GeoTIFF data
GPX(Box<GPXReader>)
GPX data
GRIB2(Box<GRIB2Reader>)
GRIB 2 data
GTFS(Box<GTFSScheduleReader>)
GTFS data
JSON(Box<JSONReader<T, (), Properties, MValue>>)
JSON data
JSONLD(Box<NewLineDelimitedJSONReader<T, (), Properties, MValue>>)
JSON-LD data
JSONSQ(Box<SequenceJSONReader<T, (), Properties, MValue>>)
JSON-SQ data
LAS(Box<LASReader<T>>)
LAS data
LAZ(Box<LAZReader<T>>)
LAZ data
NADGrid(Box<NadGridReader<T>>)
NAD Grid data
NetCDF(Box<NetCDFReader<T>>)
NetCDF data
OSM(Box<OSMLocalReader<T>>)
OSM data
Shapefile(Box<ShapeFileReader<T, Properties>>)
Shapefile
WKT(Box<WKTGeometryReader>)
WKT
Implementations§
Source§impl<T: Reader + Debug> GISReader<T>
impl<T: Reader + Debug> GISReader<T>
Sourcepub fn get_type(&self) -> ReaderType
pub fn get_type(&self) -> ReaderType
Get the type of the reader
Source§impl GISReader<BufferReader>
impl GISReader<BufferReader>
Sourcepub fn from_buffer(
data: Vec<u8>,
file_type: ReaderType,
epsg_codes: Option<BTreeMap<String, String>>,
) -> GISReader<BufferReader>
pub fn from_buffer( data: Vec<u8>, file_type: ReaderType, epsg_codes: Option<BTreeMap<String, String>>, ) -> GISReader<BufferReader>
Given a raw data and a file type, return the appropriate reader
§Parameters
data: The data to parsefile_type: The file type to parse the data asepsg_codes: The EPSG codes to use. E.g.{"4326": "...WKT STRING..."}
§Returns
The GISReader using a BufferReader for fast parsing
Source§impl GISReader<FileReader>
impl GISReader<FileReader>
Sourcepub fn from_path<P: AsRef<Path>>(
file: P,
file_type: Option<ReaderType>,
epsg_codes: Option<BTreeMap<String, String>>,
) -> GISReader<FileReader>
Available on crate feature std only.
pub fn from_path<P: AsRef<Path>>( file: P, file_type: Option<ReaderType>, epsg_codes: Option<BTreeMap<String, String>>, ) -> GISReader<FileReader>
std only.Given a file and a file type (or inferred if not provided), return a reader
§Parameters
file: The path to the filefile_type: The file type if specified, otherwise it will be inferred. Useful forzipfilesepsg_codes: The EPSG codes to use. E.g.{"4326": "...WKT STRING..."}
§Returns
The GISReader using a FileReader
Trait Implementations§
Source§impl<T: Reader + Debug> FeatureReader<(), Map<String, ValueType>, Map<String, ValueType>> for GISReader<T>
impl<T: Reader + Debug> FeatureReader<(), Map<String, ValueType>, Map<String, ValueType>> for GISReader<T>
Source§type FeatureIterator<'a> = GISIterator<'a, T>
where
T: 'a
type FeatureIterator<'a> = GISIterator<'a, T> where T: '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> Freeze for GISReader<T>
impl<T> !RefUnwindSafe for GISReader<T>
impl<T> !Send for GISReader<T>
impl<T> !Sync for GISReader<T>
impl<T> Unpin for GISReader<T>
impl<T> !UnwindSafe for GISReader<T>
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