geometry-io-ewkb
Part of the boost_geometry workspace — a Rust port of Boost.Geometry. Most users should depend on the facade crate, which re-exports this one; depend on this crate directly only for a slimmer build.
PostGIS Extended Well-Known Binary (EWKB) reader and writer.
EWKB is OGC Well-Known Binary with a PostGIS header dialect: four
flag bits in the 32-bit type word, and an optional 32-bit
spatial-reference id between the type word and the body. Everything
after that header is byte-identical OGC WKB, so this crate is a
header codec — it delegates every body to geometry-io-wkb rather
than carrying a second parser.
Only the outermost record carries an SRID, which is what
PostGIS writes. This is a strictly-2D reader: the Z, M and
bounding-box flags are refused by name rather than silently dropped.
Empty polygons use zero rings, including inside collections. Other geometry structure is preserved without validation; consumers can reject short or unclosed rings and holes without an exterior.
use Cartesian;
use ;
use Point2D;
let p = new;
let bytes = to_ewkb;
let read = from_ewkb.unwrap;
assert_eq!;
assert_eq!;
// The text form of a PostGIS `geometry` column is hex EWKB.
assert_eq!;
Bringing your own polygon
use Cartesian;
use ;
use ;
type Pt = ;
let pg = new;
let bytes = to_ewkb_polygon;
assert_eq!; // big-endian
License
BSL-1.0 — see LICENSE.