Skip to content

feat: add GeozeroGeometry and FromWkb support for postgis_diesel types#284

Open
georgeboot wants to merge 4 commits intogeorust:mainfrom
georgeboot:diesel-postgis
Open

feat: add GeozeroGeometry and FromWkb support for postgis_diesel types#284
georgeboot wants to merge 4 commits intogeorust:mainfrom
georgeboot:diesel-postgis

Conversation

@georgeboot
Copy link
Copy Markdown

Summary

  • Implements GeozeroGeometry for all postgis_diesel types (Point, PointZ, PointM, PointZM, AnyPoint, LineString<P>, Polygon<P>, MultiPoint<P>, MultiLineString<P>, MultiPolygon<P>, GeometryCollection<P>, GeometryContainer<P>), enabling conversion to any geozero-supported format (GeoJSON, WKT, WKB, SVG, geo-types, etc.)
  • Adds PostgisDieselWriter (GeomProcessor) and FromWkb for GeometryContainer<P>, enabling construction of postgis_diesel types from any geozero source
  • Adds wkb::Decode<T> / wkb::Encode<T> Diesel FromSql/ToSql impls and impl_diesel_postgis_decode! / impl_diesel_postgis_encode! macros (mirroring existing postgres/sqlx patterns)
  • Fully backwards-compatible: existing Ewkb<B> Diesel impls and sql_types are preserved

Motivation

The existing with-postgis-diesel feature only provided raw Ewkb<Vec<u8>> support — opaque WKB bytes with no typed geometry conversion. This meant downstream users had to write hundreds of lines of manual conversion code to bridge postgis_diesel geometries with other formats.

This PR brings the diesel integration to parity with the existing postgres and sqlx integrations, which already have full GeozeroGeometry / FromWkb support via wkb::Encode<T> / wkb::Decode<T>.

Test plan

  • 34 unit tests covering all geometry types, dimensions (XY, XYZ, XYM, XYZM), SRID preservation
  • Read direction: all postgis_diesel types → WKT and GeoJSON
  • Write direction: EWKB roundtrip and GeoJSON → postgis_diesel for Point, PointZ, PointZM, AnyPoint, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, GeometryCollection
  • cargo clippy clean, cargo test -p geozero passes, all existing tests unaffected
  • Compiles with all PostGIS feature combinations (with-postgis-diesel, with-postgis-postgres, with-postgis-sqlx)

@georgeboot georgeboot force-pushed the diesel-postgis branch 2 times, most recently from 78a5fdd to d8125ea Compare March 18, 2026 14:41
Bridge postgis_diesel geometry types with geozero's trait system,
enabling zero-copy conversion between postgis_diesel and any format
geozero supports (GeoJSON, WKT, WKB, SVG, geo-types, etc.).

- Implement GeozeroGeometry for all postgis_diesel types (Point, PointZ,
  PointM, PointZM, AnyPoint, LineString, Polygon, MultiPoint,
  MultiLineString, MultiPolygon, GeometryCollection, GeometryContainer)
- Add PostgisDieselWriter GeomProcessor for building postgis_diesel types
  from any geozero source
- Implement FromWkb for GeometryContainer<P> for all point types
- Add wkb::Decode<T>/wkb::Encode<T> Diesel FromSql/ToSql impls
- Add impl_diesel_postgis_decode!/impl_diesel_postgis_encode! macros
- Preserve existing Ewkb<B> Diesel impls for backwards compatibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant