Skip to main content

Crate oxigeo_geojson

Crate oxigeo_geojson 

Source
Expand description

OxiGeo GeoJSON Driver - RFC 7946 Implementation

This crate provides a pure Rust implementation of GeoJSON (RFC 7946) reading and writing for the OxiGeo ecosystem. It supports all geometry types, features, feature collections, and coordinate reference systems.

§Features

  • Full RFC 7946 compliance
  • Support for all geometry types (Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, GeometryCollection)
  • Feature and FeatureCollection support
  • CRS (Coordinate Reference System) handling
  • GeoJSONL / newline-delimited GeoJSON reading with O(1) memory per feature
  • Efficient writer with customizable formatting
  • Comprehensive validation
  • Zero-copy optimizations where possible
  • No unwrap() or panic!() in production code

§Example

use oxigeo_geojson::{GeoJsonReader, GeoJsonWriter, FeatureCollection};
use std::fs::File;
use std::io::{BufReader, BufWriter};

// Reading GeoJSON
let file = File::open(&input_path)?;
let reader = BufReader::new(file);
let mut geojson_reader = GeoJsonReader::new(reader);
let feature_collection = geojson_reader.read_feature_collection()?;

// Writing GeoJSON
let file = File::create(&output_path)?;
let writer = BufWriter::new(file);
let mut geojson_writer = GeoJsonWriter::new(writer);
geojson_writer.write_feature_collection(&feature_collection)?;

§RFC 7946 Compliance

This implementation follows RFC 7946 strictly:

  • Right-hand rule for polygon orientation
  • WGS84 as default CRS (EPSG:4326)
  • Longitude-latitude order for coordinates
  • Validation of geometry topologies
  • Support for bounding boxes
  • Foreign members preserved during round-trip

§Performance

  • GeoJSONL (read_geojsonl) streaming for O(1) memory per feature on newline-delimited input; standard FeatureCollection reads (read_feature_collection, iter_features) fully buffer and parse the document up front
  • Zero-copy deserialization where possible
  • Efficient buffering and I/O
  • Parallel processing support (with async feature)

§COOLJAPAN Policies

  • Pure Rust implementation (no C/C++ dependencies)
  • No unwrap() or expect() in production code
  • Comprehensive error handling
  • Extensive testing (unit + integration + property-based)
  • Clean API design following Rust idioms

Re-exports§

pub use error::GeoJsonError;
pub use error::Result;
pub use reader::GeoJsonReader;
pub use types::Coordinate;
pub use types::CoordinateSequence;
pub use types::Crs;
pub use types::Feature;
pub use types::FeatureCollection;
pub use types::Geometry;
pub use types::GeometryType;
pub use types::Position;
pub use types::Properties;
pub use validation::RingRole;
pub use validation::Validator;
pub use writer::GeoJsonWriter;
pub use reader::feature_bbox_intersects;
pub use reader::features_in_bbox;
pub use reader::geometry_bbox;
pub use reader::open;
pub use reader::open_geojsonl;
pub use reader::read_geojsonl;
pub use writer::write_geojsonl;
pub use writer::write_geojsonl_to_file;

Modules§

error
Error types for GeoJSON operations
reader
GeoJSON reader implementation
types
GeoJSON type definitions
utils
Utility modules for GeoJSON operations
validation
RFC 7946 validation utilities
writer
GeoJSON writer implementation

Constants§

DEFAULT_CRS
Default CRS for GeoJSON (WGS84)
FILE_EXTENSION
GeoJSON file extension
MIME_TYPE
GeoJSON MIME type
NAME
Crate name
VERSION
Crate version