Skip to content

Repository files navigation

jsonfg

Crates.io docs.rs CI License: MIT OR Apache-2.0

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 place member and coordRefSys;
  • geometry types beyond GeoJSON: 3D solids (Polyhedron, Prism, …) and curves (CircularString, CompoundCurve, CurvePolygon, …);
  • temporal information via time;
  • feature classification via featureType and featureSchema.

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.

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`; 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.

Feature flags

  • geojsonFrom/TryFrom conversions to and from geojson::Geometry. (Arcs and solids have no GeoJSON equivalent and return an error when converting to GeoJSON.)

Status

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.

Releasing

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:

  1. Land your changes on main, move the relevant CHANGELOG.md entries out of [Unreleased] into a new version heading, and make sure CI is green.
  2. 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.
  3. .github/workflows/publish.yaml fires on the release, stamps the version from the tag into Cargo.toml, mints a short-lived token via OIDC, and runs cargo 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.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

About

Rust types for OGC Features and Geometries JSON (JSON-FG), a GeoJSON superset supporting arbitrary CRS, 3D solids, and curved geometries.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages