GISReader

Enum GISReader 

Source
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 format
  • GeoTIFFReader: 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 object
  • JSONReader: Parse (Geo|S2)JSON. Can handle millions of features.
  • NewLineDelimitedJSONReader: Parse (Geo|S2)JSON from a file that is in a newline-delimited format
  • SequenceJSONReader: Parse GeoJSON from a file that is in the geojson-text-sequences format.
  • 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 the OSMFileReader as well
  • ShapeFileReader: Reads data from a shapefile implementing the {@link FeatureIterator} interface
  • WKTGeometryReader: 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>

Source

pub fn get_type(&self) -> ReaderType

Get the type of the reader

Source§

impl GISReader<BufferReader>

Source

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 parse
  • file_type: The file type to parse the data as
  • epsg_codes: The EPSG codes to use. E.g. {"4326": "...WKT STRING..."}
§Returns

The GISReader using a BufferReader for fast parsing

Source§

impl GISReader<FileReader>

Source

pub 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.

Given a file and a file type (or inferred if not provided), return a reader

§Parameters
  • file: The path to the file
  • file_type: The file type if specified, otherwise it will be inferred. Useful for zip files
  • epsg_codes: The EPSG codes to use. E.g. {"4326": "...WKT STRING..."}
§Returns

The GISReader using a FileReader

Trait Implementations§

Source§

impl<T: Clone + Reader + Debug> Clone for GISReader<T>

Source§

fn clone(&self) -> GISReader<T>

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Reader + Debug> Debug for GISReader<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Reader + Debug> FeatureReader<(), Map<String, ValueType>, Map<String, ValueType>> for GISReader<T>

Source§

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<'_>

All readers have an iter function that returns a Iterator struct
Source§

fn par_iter( &self, pool_size: usize, thread_id: usize, ) -> Self::FeatureIterator<'_>

All readers have a par_iter function that returns a ParallelIterator 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> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V