Skip to main content

Module ewkb

Module ewkb 

Source
Expand description

EWKB (Extended Well-Known Binary) wire format encoder and decoder, used as the on-disk and over-the-wire representation for geometry BLOBs. EWKB (Extended Well-Known Binary) parser and writer.

Wire format: [0x01|0x00]: byte order marker (little-endian or big-endian) [u32]: geometry type with flags (in the declared byte order) Bit 29 (0x20000000): SRID present Bit 31 (0x80000000): Z dimension Bit 30 (0x40000000): M dimension Bits 0-28: geometry type (1=Point, 2=LineString, etc.) [i32]: SRID (only when SRID flag set, in declared byte order) [rest]: ISO WKB geometry payload

Structs§

EwkbHeader
Parsed EWKB header metadata.

Constants§

EWKB_M_FLAG
EWKB type flag: coordinates include an M (measure) dimension.
EWKB_SRID_FLAG
EWKB type flag: SRID is present immediately after the type word.
EWKB_Z_FLAG
EWKB type flag: coordinates include a Z dimension.
MAX_NESTING_DEPTH
Max container nesting the EWKB parsers accept. geozero’s recursive to_geo/to_wkt/to_json overflow the stack around depth ~1500 (lower on WASM), so a crafted ~9 KB blob aborts the process. Real geometries nest a handful of levels, so this never bites legitimate data.
WKB_GEOMETRYCOLLECTION
ISO WKB geometry type code: GeometryCollection.
WKB_LINESTRING
ISO WKB geometry type code: LineString.
WKB_MULTILINESTRING
ISO WKB geometry type code: MultiLineString.
WKB_MULTIPOINT
ISO WKB geometry type code: MultiPoint.
WKB_MULTIPOLYGON
ISO WKB geometry type code: MultiPolygon.
WKB_POINT
ISO WKB geometry type code: Point.
WKB_POLYGON
ISO WKB geometry type code: Polygon.

Functions§

concat_multipolygon_bodies
Return a static string naming the variant of a geo::Geometry value (for diagnostics).
ensure_ewkb_nesting_ok
Reject EWKB whose nesting exceeds MAX_NESTING_DEPTH, guarding the recursive geozero decoders against stack overflow. Reads only structural counts, never the coordinate payload.
ensure_matching_srid
Enforce equal SRIDs for binary geometry operations.
ensure_xy_only
Reject Z/M coordinate layouts when the operation can only process XY.
extract_mbr
Compute the planar minimum bounding rectangle of an EWKB blob without allocating a Geometry enum.
extract_srid
Extract only the SRID from an EWKB blob (cheap, no geometry parsing).
geom_type_name
Return a human-readable geometry type name (PostGIS convention).
geometry_type_name
Return the human-readable name of a geo::Geometry enum variant.
is_empty_point_blob
Return true when the EWKB blob encodes POINT EMPTY.
parse_ewkb
Parse an EWKB blob into a geo::Geometry<f64>. Returns (geometry, srid).
parse_ewkb_header
Peek at the EWKB header without fully parsing the geometry.
parse_ewkb_pair
Parse two EWKB blobs and enforce matching SRID.
set_srid
Rewrite the SRID in an existing EWKB blob without re-parsing the geometry.
validate_ewkb_payload
Validate EWKB header + payload structure without forcing XY-only dimensions and without deserializing through geozero.
validate_xy_ewkb_payload
Validate EWKB header + payload and enforce XY-only coordinate dimensions.
write_ewkb
Serialise a geo::Geometry<f64> to EWKB with an optional SRID.