pub struct GeoJsonReader { /* private fields */ }Implementations§
Source§impl GeoJsonReader
impl GeoJsonReader
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Open a file in streaming mode. Issues two scans over the file:
- 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. - 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.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
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.
Sourcepub fn from_value(root: Json) -> Result<Self>
pub fn from_value(root: Json) -> Result<Self>
In-memory path: parse a serde_json::Value tree into a
Vec<Feature>.
pub fn schema(&self) -> &Schema
pub fn feature_count(&self) -> usize
Sourcepub fn features(&self) -> &[Feature]
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).
Sourcepub fn into_features(self) -> FeatureIter ⓘ
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).
Sourcepub fn iter_results(&self) -> impl Iterator<Item = Result<Feature>> + '_
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).