Skip to main content

Crate projjson

Crate projjson 

Source
Expand description

Typed read/write support for PROJJSON (schema v0.7).

Every member of the schema has a Rust type, and each object keeps the form it was read in (optional type, id vs ids, number vs value-and-unit, integer vs float), so reading and writing a document gives back the same JSON.

let json = r#"{"type":"GeographicCRS","name":"WGS 84","datum":{"type":"GeodeticReferenceFrame","name":"World Geodetic System 1984","ellipsoid":{"name":"WGS 84","semi_major_axis":6378137,"inverse_flattening":298.257223563}},"id":{"authority":"EPSG","code":4326}}"#;

let doc: projjson::ProjJson = json.parse().unwrap();
assert_eq!(doc.to_string(), json);

§The type member

Each PROJJSON object may carry a type string naming what it is, such as {"type": "Axis", ...}. It is optional, so every struct has an r#type: Option<...Type> field: None when the document leaves it out, in which case it is also left out when written back. The ...Type enums list the strings the schema allows for that object (usually one, e.g. cs::AxisType::Axis is "Axis"), so a wrong type is rejected. They also let crs::Crs and the other enums tell apart objects whose other members look alike.

Modules§

common
Identifiers, units, measures and usage extents shared by all objects.
crs
Coordinate reference systems.
cs
Coordinate systems and axes.
datum
Datums, ellipsoids, prime meridians and datum ensembles.
number
operation
Coordinate operations: conversions, transformations and their parameters.
validate
Schema constraints that the types alone do not enforce.

Structs§

CoordinateMetadata

Enums§

CoordinateMetadataType
The type of a CoordinateMetadata: "CoordinateMetadata".
ProjJson
A PROJJSON document: any object allowed at the root of the schema.
ProjJsonError