Convert LWGEOM to a char* in WKB format.
Caller is responsible for freeing the returned array.
- Parameters
-
variant. | Unsigned bitmask value. Accepts one of: WKB_ISO, WKB_EXTENDED, WKB_SFSQL. Accepts any of: WKB_NDR, WKB_HEX. For example: Variant = ( WKB_ISO | WKB_NDR ) would return the little-endian ISO form of WKB. For Example: Variant = ( WKB_EXTENDED | WKB_HEX ) would return the big-endian extended form of WKB, as hex-encoded ASCII (the "canonical form"). |
size_out | If supplied, will return the size of the returned memory segment, including the null terminator in the case of ASCII. |
Definition at line 764 of file lwout_wkb.c.
References getMachineEndian(), lwalloc(), LWDEBUG, LWDEBUGF, lwerror(), lwfree(), lwgeom_to_wkb_buf(), lwgeom_to_wkb_size(), NDR, WKB_HEX, WKB_NDR, and WKB_XDR.
Referenced by cu_wkb(), cu_wkb_from_hexwkb(), cu_wkb_in(), geography_send(), LWGEOM_asBinary(), lwgeom_to_hexwkb(), polyhedralsurface_parse(), RASTER_asRaster(), RASTER_clip(), RASTER_setPixelValuesGeomval(), rt_raster_gdal_polygonize(), and WKBFromLWGEOM().
771 if ( size_out ) *size_out = 0;
775 LWDEBUG(4,
"Cannot convert NULL into WKB.");
776 lwerror(
"Cannot convert NULL into WKB.");
782 LWDEBUGF(4,
"WKB output size: %d", buf_size);
786 LWDEBUG(4,
"Error calculating output WKB buffer size.");
787 lwerror(
"Error calculating output WKB buffer size.");
794 buf_size = 2 * buf_size + 1;
795 LWDEBUGF(4,
"Hex WKB output size: %d", buf_size);
813 LWDEBUGF(4,
"Unable to allocate %d bytes for WKB output buffer.", buf_size);
814 lwerror(
"Unable to allocate %d bytes for WKB output buffer.", buf_size);
831 LWDEBUGF(4,
"buf (%p) - wkb_out (%p) = %d", buf, wkb_out, buf - wkb_out);
834 if ( buf_size != (buf - wkb_out) )
836 LWDEBUG(4,
"Output WKB is not the same size as the allocated buffer.");
837 lwerror(
"Output WKB is not the same size as the allocated buffer.");
843 if ( size_out ) *size_out = buf_size;
#define LWDEBUG(level, msg)
static size_t lwgeom_to_wkb_size(const LWGEOM *geom, uint8_t variant)
static uint8_t * lwgeom_to_wkb_buf(const LWGEOM *geom, uint8_t *buf, uint8_t variant)
char getMachineEndian(void)
void * lwalloc(size_t size)
#define LWDEBUGF(level, msg,...)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.