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§
- Ewkb
Header - 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 recursiveto_geo/to_wkt/to_jsonoverflow 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::Geometryvalue (for diagnostics). - ensure_
ewkb_ nesting_ ok - Reject EWKB whose nesting exceeds
MAX_NESTING_DEPTH, guarding the recursivegeozerodecoders 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
Geometryenum. - 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::Geometryenum 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.