PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwgeom_to_wkb_buf()

static uint8_t * lwgeom_to_wkb_buf ( const LWGEOM geom,
uint8_t buf,
uint8_t  variant 
)
static

Definition at line 707 of file lwout_wkb.c.

References CIRCSTRINGTYPE, COLLECTIONTYPE, COMPOUNDTYPE, CURVEPOLYTYPE, empty_to_wkb_buf(), LINETYPE, lwcollection_to_wkb_buf(), lwerror(), lwgeom_is_empty(), lwline_to_wkb_buf(), lwpoint_to_wkb_buf(), lwpoly_to_wkb_buf(), lwtriangle_to_wkb_buf(), lwtype_name(), MULTICURVETYPE, MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, MULTISURFACETYPE, POINTTYPE, POLYGONTYPE, POLYHEDRALSURFACETYPE, TINTYPE, TRIANGLETYPE, LWGEOM::type, LWCOLLECTION::type, and WKB_EXTENDED.

Referenced by lwcollection_to_wkb_buf(), and lwgeom_to_wkb().

708 {
709 
710  /* Do not simplify empties when outputting to canonical form */
711  if ( lwgeom_is_empty(geom) & ! (variant & WKB_EXTENDED) )
712  return empty_to_wkb_buf(geom, buf, variant);
713 
714  switch ( geom->type )
715  {
716  case POINTTYPE:
717  return lwpoint_to_wkb_buf((LWPOINT*)geom, buf, variant);
718 
719  /* LineString and CircularString both have 'points' elements */
720  case CIRCSTRINGTYPE:
721  case LINETYPE:
722  return lwline_to_wkb_buf((LWLINE*)geom, buf, variant);
723 
724  /* Polygon has 'nrings' and 'rings' elements */
725  case POLYGONTYPE:
726  return lwpoly_to_wkb_buf((LWPOLY*)geom, buf, variant);
727 
728  /* Triangle has one ring of three points */
729  case TRIANGLETYPE:
730  return lwtriangle_to_wkb_buf((LWTRIANGLE*)geom, buf, variant);
731 
732  /* All these Collection types have 'ngeoms' and 'geoms' elements */
733  case MULTIPOINTTYPE:
734  case MULTILINETYPE:
735  case MULTIPOLYGONTYPE:
736  case COMPOUNDTYPE:
737  case CURVEPOLYTYPE:
738  case MULTICURVETYPE:
739  case MULTISURFACETYPE:
740  case COLLECTIONTYPE:
742  case TINTYPE:
743  return lwcollection_to_wkb_buf((LWCOLLECTION*)geom, buf, variant);
744 
745  /* Unknown type! */
746  default:
747  lwerror("Unsupported geometry type: %s [%d]", lwtype_name(geom->type), geom->type);
748  }
749  /* Return value to keep compiler happy. */
750  return 0;
751 }
#define LINETYPE
Definition: liblwgeom.h:86
static uint8_t * empty_to_wkb_buf(const LWGEOM *geom, uint8_t *buf, uint8_t variant)
Definition: lwout_wkb.c:315
#define MULTICURVETYPE
Definition: liblwgeom.h:95
uint8_t variant
Definition: cu_in_twkb.c:26
static uint8_t * lwline_to_wkb_buf(const LWLINE *line, uint8_t *buf, uint8_t variant)
Definition: lwout_wkb.c:479
static uint8_t * lwpoly_to_wkb_buf(const LWPOLY *poly, uint8_t *buf, uint8_t variant)
Definition: lwout_wkb.c:570
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
#define COMPOUNDTYPE
Definition: liblwgeom.h:93
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
static uint8_t * lwpoint_to_wkb_buf(const LWPOINT *pt, uint8_t *buf, uint8_t variant)
Definition: lwout_wkb.c:433
#define TRIANGLETYPE
Definition: liblwgeom.h:98
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:97
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
#define TINTYPE
Definition: liblwgeom.h:99
#define WKB_EXTENDED
Definition: liblwgeom.h:2076
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define MULTISURFACETYPE
Definition: liblwgeom.h:96
static uint8_t * lwcollection_to_wkb_buf(const LWCOLLECTION *col, uint8_t *buf, uint8_t variant)
Definition: lwout_wkb.c:621
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
uint8_t type
Definition: liblwgeom.h:396
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1346
#define MULTILINETYPE
Definition: liblwgeom.h:89
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
static uint8_t * lwtriangle_to_wkb_buf(const LWTRIANGLE *tri, uint8_t *buf, uint8_t variant)
Definition: lwout_wkb.c:519
Here is the call graph for this function:
Here is the caller graph for this function: