PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwgeom_to_wkb_size()

static size_t lwgeom_to_wkb_size ( const LWGEOM geom,
uint8_t  variant 
)
static

Definition at line 648 of file lwout_wkb.c.

649 {
650  size_t size = 0;
651 
652  if ( geom == NULL )
653  return 0;
654 
655  /* Short circuit out empty geometries */
656  if ( (!(variant & WKB_EXTENDED)) && lwgeom_is_empty(geom) )
657  {
658  return empty_to_wkb_size(geom, variant);
659  }
660 
661  switch ( geom->type )
662  {
663  case POINTTYPE:
664  size += lwpoint_to_wkb_size((LWPOINT*)geom, variant);
665  break;
666 
667  /* LineString and CircularString both have points elements */
668  case CIRCSTRINGTYPE:
669  case LINETYPE:
670  size += lwline_to_wkb_size((LWLINE*)geom, variant);
671  break;
672 
673  /* Polygon has nrings and rings elements */
674  case POLYGONTYPE:
675  size += lwpoly_to_wkb_size((LWPOLY*)geom, variant);
676  break;
677 
678  /* Triangle has one ring of three points */
679  case TRIANGLETYPE:
680  size += lwtriangle_to_wkb_size((LWTRIANGLE*)geom, variant);
681  break;
682 
683  /* All these Collection types have ngeoms and geoms elements */
684  case MULTIPOINTTYPE:
685  case MULTILINETYPE:
686  case MULTIPOLYGONTYPE:
687  case COMPOUNDTYPE:
688  case CURVEPOLYTYPE:
689  case MULTICURVETYPE:
690  case MULTISURFACETYPE:
691  case COLLECTIONTYPE:
693  case TINTYPE:
695  break;
696 
697  /* Unknown type! */
698  default:
699  lwerror("Unsupported geometry type: %s [%d]", lwtype_name(geom->type), geom->type);
700  }
701 
702  return size;
703 }
static uint8_t variant
Definition: cu_in_twkb.c:26
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
#define COMPOUNDTYPE
Definition: liblwgeom.h:93
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
#define MULTILINETYPE
Definition: liblwgeom.h:89
#define MULTISURFACETYPE
Definition: liblwgeom.h:96
#define LINETYPE
Definition: liblwgeom.h:86
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
#define TINTYPE
Definition: liblwgeom.h:99
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:97
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
#define WKB_EXTENDED
Definition: liblwgeom.h:2068
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
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:1393
#define MULTICURVETYPE
Definition: liblwgeom.h:95
#define TRIANGLETYPE
Definition: liblwgeom.h:98
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
static size_t lwcollection_to_wkb_size(const LWCOLLECTION *col, uint8_t variant)
Definition: lwout_wkb.c:602
static size_t lwtriangle_to_wkb_size(const LWTRIANGLE *tri, uint8_t variant)
Definition: lwout_wkb.c:500
static size_t lwpoint_to_wkb_size(const LWPOINT *pt, uint8_t variant)
Definition: lwout_wkb.c:415
static size_t empty_to_wkb_size(const LWGEOM *geom, uint8_t variant)
Definition: lwout_wkb.c:291
static size_t lwpoly_to_wkb_size(const LWPOLY *poly, uint8_t variant)
Definition: lwout_wkb.c:547
static size_t lwline_to_wkb_size(const LWLINE *line, uint8_t variant)
Definition: lwout_wkb.c:461
uint8_t type
Definition: liblwgeom.h:399

References CIRCSTRINGTYPE, COLLECTIONTYPE, COMPOUNDTYPE, CURVEPOLYTYPE, empty_to_wkb_size(), LINETYPE, lwcollection_to_wkb_size(), lwerror(), lwgeom_is_empty(), lwline_to_wkb_size(), lwpoint_to_wkb_size(), lwpoly_to_wkb_size(), lwtriangle_to_wkb_size(), lwtype_name(), MULTICURVETYPE, MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, MULTISURFACETYPE, POINTTYPE, POLYGONTYPE, POLYHEDRALSURFACETYPE, TINTYPE, TRIANGLETYPE, LWGEOM::type, LWPOINT::type, variant, and WKB_EXTENDED.

Referenced by lwcollection_to_wkb_size(), and lwgeom_to_wkb().

Here is the call graph for this function:
Here is the caller graph for this function: