Skip to main content

Crate geonative_geojson

Crate geonative_geojson 

Source
Expand description

§geonative-geojson

Pure-Rust reader and writer for GeoJSON (RFC 7946), part of the geonative geospatial library.

§What v0.1 covers

Reader:

  • Top-level FeatureCollection, bare Feature, or bare geometry object
  • All seven RFC 7946 geometry types (Point/Multi*/Polygon/Multi*/Collection)
  • Schema inference from properties (one pass; widening rules in properties)
  • CRS detection: default EPSG:4326, honours legacy 2008 crs.properties.name URNs like urn:ogc:def:crs:EPSG::3857
  • String / numeric idFeature::fid (i64 only — string ids that don’t parse as integers fall back to row index)

Writer:

  • Streaming — O(one feature) memory regardless of input size
  • Compact output (no whitespace); wrap your sink in a pretty-printer if you need indentation
  • Always writes FeatureCollection; no crs member (RFC 7946 removed it)

§v0.1 scope cuts

  • Z/M coordinates silently truncated on read; never emitted on write. GeoJSON’s third position is optional and underspecified across tools; v0.2 will add an opt-in --preserve-z switch.
  • Foreign members (bbox, custom top-level keys) are read but not round-tripped on write — only spec-defined fields are emitted.
  • Streaming reader (v0.4)GeoJsonReader::open(path) now scans the file in two streaming passes (schema inference + feature yield) instead of materialising the whole JSON tree. Peak RAM is bounded to ~one feature regardless of file size; the previous in-memory path (from_bytes / from_value) is still available for callers who already have the bytes and want the eager features() slice.

§Usage

let r = geonative_geojson::GeoJsonReader::open("things.geojson")?;
println!("{} features, schema: {:?}", r.feature_count(), r.schema());
for f in r.features() {
    // f.fid, f.geometry, f.attributes
}

Re-exports§

pub use error::GeoJsonError;
pub use error::Result;
pub use reader::GeoJsonReader;
pub use writer::write_features_to_path;
pub use writer::GeoJsonWriter;

Modules§

error
GeoJSON-specific error type.
geometry
Convert between RFC 7946 JSON shapes and the geonative-core Geometry tree. 2D only in v0.1 — Z/M coordinates are silently truncated on read, and never emitted on write.
properties
GeoJSON properties object handling: schema inference on read, Value ↔ JSON conversion on read+write.
reader
GeoJSON reader.
writer
GeoJSON writer — streams a FeatureCollection to any Write sink, one feature at a time. Memory use is O(one feature), so multi-GB outputs are fine to produce.

Constants§

VERSION