Rust 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. Where GeoJSON can only carry WGS 84 geometry of seven simple types, JSON-FG adds — as GeoJSON foreign members, so plain GeoJSON readers still work — the ability to convey:
- geometry in any coordinate reference system, not just WGS 84, via the
placemember andcoordRefSys; - geometry types beyond GeoJSON: 3D solids (
Polyhedron,Prism, …) and curves (CircularString,CompoundCurve,CurvePolygon, …); - temporal information via
time; - feature classification via
featureTypeandfeatureSchema.
This crate is the JSON-FG counterpart to the geojson crate: a small,
serde-based data model with no I/O or HTTP content-negotiation logic. It models every
member of the JSON-FG 1.0 schema and preserves unknown members (e.g. OGC API links)
verbatim, so documents round-trip losslessly.
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`; the GeoJSON `geometry` 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_string(&feature).unwrap();The place/geometry split is the producer's choice: put WGS 84 geometry in
geometry, and geometry in any other CRS (or of a non-GeoJSON type) in place with
coordRefSys. CoordRefSys::is_wgs84() helps decide.
geojson—From/TryFromconversions to and fromgeojson::Geometry. (Arcs and solids have no GeoJSON equivalent and return an error when converting to GeoJSON.)
Covers the JSON-FG 1.0 Core plus the Polyhedra, Prisms, Circular Arcs and Measures geometry types. Validated by round-tripping the normative OGC example corpus.
Releases are published to crates.io automatically by
GitHub Actions using crates.io Trusted Publishing (OIDC) — there is no API-token
secret to manage. One-time setup: on the crate's crates.io Settings → Trusted
Publishing page, add this repository (360-geo/jsonfg), the workflow
publish.yaml, and the github environment if you use one.
To cut a release:
- Land your changes on
main, move the relevantCHANGELOG.mdentries out of[Unreleased]into a new version heading, and make sure CI is green. - Publish a GitHub Release with a tag of the form
vX.Y.Z(e.g.v0.1.0); use the changelog entry as the release notes. .github/workflows/publish.yamlfires on the release, stamps the version from the tag intoCargo.toml, mints a short-lived token via OIDC, and runscargo publish.
The Cargo.toml version is set from the tag at publish time, so the tag is the source of
truth; keep the committed version in sync for local builds.
Licensed under either of Apache License, Version 2.0 or MIT license at your option.