Skip to main content

GeoJsonReader

Struct GeoJsonReader 

Source
pub struct GeoJsonReader { /* private fields */ }

Implementations§

Source§

impl GeoJsonReader

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Open a file in streaming mode. Issues two scans over the file:

  1. Schema inference pass — walks each feature’s properties map (without holding the whole tree) and accumulates types via FieldsAccumulator. Also counts features and detects geometry kind + CRS.
  2. Feature yield pass — done lazily by into_features; reopens the file and streams one feature at a time.

Peak memory ≈ schema accumulator + one feature. An 86 MB GeoJSON that previously OOM-killed worker pods now uses ~ tens of MB.

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self>

In-memory path: parse bytes fully into a Vec<Feature>. Use for small blobs, tests, or when you already have the bytes resident and want random access via features.

Source

pub fn from_value(root: Json) -> Result<Self>

In-memory path: parse a serde_json::Value tree into a Vec<Feature>.

Source

pub fn schema(&self) -> &Schema

Source

pub fn feature_count(&self) -> usize

Source

pub fn features(&self) -> &[Feature]

Eager-only convenience: get the loaded features as a slice. Returns &[] for streaming-backed readers (the slice would imply we’d loaded everything in RAM, which is the bug we’re avoiding).

Source

pub fn into_features(self) -> FeatureIter

Iterate features. Yields Result<Feature> to match the other readers in the workspace. The streaming variant returns errors for I/O / parse failures encountered while reading; the eager variant only ever yields Ok (errors were already raised at construction).

Source

pub fn iter_results(&self) -> impl Iterator<Item = Result<Feature>> + '_

Alias for [into_features] kept for downstream code that wants per-item Results without consuming the reader. Implemented in terms of cloning the eager features; for streaming readers it errors out (would require holding two file handles open).

Trait Implementations§

Source§

impl Debug for GeoJsonReader

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

type Error = <U as TryFrom<T>>::Error

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

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

Performs the conversion.