A WKB (Well-Known Binary) serializer for Nimgeos. See also: docs/serialization/wkb.md.
Types
WkbByteOrder = enum wkbXDR = 0, ## Big-Endian (network byte order) wkbNDR = 1 ## Little-Endian (x86/ARM native)
Procs
proc fromHexWKB(ctx: var GeosContext; hex: string): Geometry {. ...raises: [GeosParseError, GeosInitError, GeosGeomError], tags: [], forbids: [].}
- Parse the hex-encoded WKB string hex into the corresponding concrete Geometry. Raises GeosParseError if hex is empty, of odd length, or contains a non-hex character; GeosInitError if ctx is destroyed.
proc fromWKB(ctx: var GeosContext; wkb: openArray[byte]): Geometry {. ...raises: [GeosInitError, GeosParseError, GeosGeomError], tags: [], forbids: [].}
- Parse the WKB byte sequence wkb into the corresponding concrete Geometry. Raises GeosInitError if ctx is destroyed; GeosParseError if the input is empty or malformed.
proc toHexWKB(g: Geometry; byteOrder: WkbByteOrder = wkbNDR): string {. ...raises: [GeosGeomError, GeosInitError], tags: [], forbids: [].}
- Serialize g to an uppercase hex-encoded WKB string. Raises GeosGeomError if g is nil or serialization fails.
proc toWKB(g: Geometry; byteOrder: WkbByteOrder = wkbNDR): seq[byte] {. ...raises: [GeosGeomError, GeosInitError], tags: [], forbids: [].}
-
Serialize g to a WKB byte sequence. byteOrder selects Little-Endian NDR (default) or Big-Endian XDR.
var ctx = initGeosContext() let bytes = ctx.createPoint(1.0, 2.0).toWKB() let back = ctx.fromWKB(bytes) echo back.toWKT() # POINT (1 2)
Raises GeosGeomError if g is nil or serialization fails.