Skip to main content

Crate jsonfg

Crate jsonfg 

Source
Expand description

Types for OGC Features and Geometries JSON (JSON-FG), the OGC extension of GeoJSON standardized as OGC 21-045r1 (version 1.0).

JSON-FG is a strict superset of GeoJSON. It adds, as GeoJSON foreign members, the ability to convey:

This crate is the JSON-FG counterpart to the geojson crate: a serde-based data model, with no I/O or content-negotiation logic. Enable the geojson feature for conversions to and from geojson::Geometry.

§Example

use jsonfg::{conformance, CoordRefSys, Feature, Geometry};

// A feature whose geometry is a point in a projected CRS (EPSG:3857): the native
// geometry goes in `place`, and `geometry` (the GeoJSON member) is left null.
let mut feature = Feature::new();
feature.conforms_to = Some(vec![conformance::CORE.to_owned()]);
feature.coord_ref_sys = Some(CoordRefSys::from_epsg(3857));
feature.place = Some(Geometry::point(vec![100.0, 200.0]));

let json = serde_json::to_value(&feature).unwrap();
assert_eq!(json["place"]["type"], "Point");
assert!(json["geometry"].is_null());

Modules§

conformance
Conformance-class URIs and the JSON-FG media type.

Structs§

Feature
A JSON-FG feature.
FeatureCollection
A JSON-FG feature collection.
GeometryMeta
Optional members common to every JSON-FG geometry object.
Measures
Declares that positions in a geometry carry a trailing measure (m) value, and optionally describes it.
Reference
A {"type": "Reference", "href": …, "epoch": …} coordinate reference system object.
Time
The value of a feature’s time member: a temporal instant (as a date and/or a timestamp) and/or an interval. At least one member must be present.

Enums§

CoordRefSys
The value of a coordRefSys member: a single reference, or (for a compound CRS) an array of at least two references.
FeatureCollectionKind
Marker for the type member of a FeatureCollection; always serializes as "FeatureCollection".
FeatureKind
Marker for the type member of a Feature; always serializes as "Feature".
FeatureSchema
The value of the featureSchema member: a single schema URI, or a map from feature type name to schema URI (for multi-typed features).
FeatureType
The value of the featureType member: a single classifier, or several.
Geometry
A JSON-FG geometry.
Id
A feature identifier: a string or a number.
RefSys
A single coordinate reference system: either a plain URI, or a by-reference object that may pin a dynamic CRS to an epoch.
ReferenceKind
Marker for the type member of a Reference; always serializes as "Reference".

Constants§

CRS84
The OGC URI for WGS 84 longitude/latitude (2D), the JSON-FG default CRS.
CRS84H
The OGC URI for WGS 84 longitude/latitude/height (3D).
UNBOUNDED
The marker used for an unbounded end of a time Time::interval.

Type Aliases§

Bbox
A bounding box: four numbers (2D) or six numbers (3D).
JsonObject
A JSON object: an ordered map of string keys to arbitrary JSON values. Used for feature properties and for preserved foreign members.
Position
A single coordinate: [x, y], [x, y, z], or [x, y, z, m] (the trailing m value requires the Measures conformance class).