PostGIS  2.2.7dev-r@@SVN_REVISION@@
static size_t lwgeom_to_wkb_size ( const LWGEOM geom,
uint8_t  variant 
)
static

Definition at line 634 of file lwout_wkb.c.

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, and WKB_EXTENDED.

Referenced by lwcollection_to_wkb_size(), and lwgeom_to_wkb().

635 {
636  size_t size = 0;
637 
638  if ( geom == NULL )
639  return 0;
640 
641  /* Short circuit out empty geometries */
642  if ( (!(variant & WKB_EXTENDED)) && lwgeom_is_empty(geom) )
643  {
644  return empty_to_wkb_size(geom, variant);
645  }
646 
647  switch ( geom->type )
648  {
649  case POINTTYPE:
650  size += lwpoint_to_wkb_size((LWPOINT*)geom, variant);
651  break;
652 
653  /* LineString and CircularString both have points elements */
654  case CIRCSTRINGTYPE:
655  case LINETYPE:
656  size += lwline_to_wkb_size((LWLINE*)geom, variant);
657  break;
658 
659  /* Polygon has nrings and rings elements */
660  case POLYGONTYPE:
661  size += lwpoly_to_wkb_size((LWPOLY*)geom, variant);
662  break;
663 
664  /* Triangle has one ring of three points */
665  case TRIANGLETYPE:
666  size += lwtriangle_to_wkb_size((LWTRIANGLE*)geom, variant);
667  break;
668 
669  /* All these Collection types have ngeoms and geoms elements */
670  case MULTIPOINTTYPE:
671  case MULTILINETYPE:
672  case MULTIPOLYGONTYPE:
673  case COMPOUNDTYPE:
674  case CURVEPOLYTYPE:
675  case MULTICURVETYPE:
676  case MULTISURFACETYPE:
677  case COLLECTIONTYPE:
679  case TINTYPE:
681  break;
682 
683  /* Unknown type! */
684  default:
685  lwerror("Unsupported geometry type: %s [%d]", lwtype_name(geom->type), geom->type);
686  }
687 
688  return size;
689 }
#define LINETYPE
Definition: liblwgeom.h:71
#define MULTICURVETYPE
Definition: liblwgeom.h:80
uint8_t variant
Definition: cu_in_twkb.c:26
#define POLYGONTYPE
Definition: liblwgeom.h:72
#define CURVEPOLYTYPE
Definition: liblwgeom.h:79
#define COMPOUNDTYPE
Definition: liblwgeom.h:78
#define MULTIPOINTTYPE
Definition: liblwgeom.h:73
#define TRIANGLETYPE
Definition: liblwgeom.h:83
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:82
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:188
#define TINTYPE
Definition: liblwgeom.h:84
static size_t lwpoly_to_wkb_size(const LWPOLY *poly, uint8_t variant)
Definition: lwout_wkb.c:533
#define WKB_EXTENDED
Definition: liblwgeom.h:1932
static size_t empty_to_wkb_size(const LWGEOM *geom, uint8_t variant)
Definition: lwout_wkb.c:277
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:75
static size_t lwpoint_to_wkb_size(const LWPOINT *pt, uint8_t variant)
Definition: lwout_wkb.c:401
#define MULTISURFACETYPE
Definition: liblwgeom.h:81
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
uint8_t type
Definition: liblwgeom.h:380
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:77
static size_t lwcollection_to_wkb_size(const LWCOLLECTION *col, uint8_t variant)
Definition: lwout_wkb.c:588
static size_t lwtriangle_to_wkb_size(const LWTRIANGLE *tri, uint8_t variant)
Definition: lwout_wkb.c:486
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:1297
#define MULTILINETYPE
Definition: liblwgeom.h:74
static size_t lwline_to_wkb_size(const LWLINE *line, uint8_t variant)
Definition: lwout_wkb.c:447
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
#define COLLECTIONTYPE
Definition: liblwgeom.h:76

Here is the call graph for this function:

Here is the caller graph for this function: