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

Definition at line 577 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, and LWGEOM::type.

Referenced by lwcollection_to_wkb_size(), and lwgeom_to_wkb().

578 {
579  size_t size = 0;
580 
581  if ( geom == NULL )
582  return 0;
583 
584  /* Short circuit out empty geometries */
585  if ( lwgeom_is_empty(geom) )
586  {
587  return empty_to_wkb_size(geom, variant);
588  }
589 
590  switch ( geom->type )
591  {
592  case POINTTYPE:
593  size += lwpoint_to_wkb_size((LWPOINT*)geom, variant);
594  break;
595 
596  /* LineString and CircularString both have points elements */
597  case CIRCSTRINGTYPE:
598  case LINETYPE:
599  size += lwline_to_wkb_size((LWLINE*)geom, variant);
600  break;
601 
602  /* Polygon has nrings and rings elements */
603  case POLYGONTYPE:
604  size += lwpoly_to_wkb_size((LWPOLY*)geom, variant);
605  break;
606 
607  /* Triangle has one ring of three points */
608  case TRIANGLETYPE:
609  size += lwtriangle_to_wkb_size((LWTRIANGLE*)geom, variant);
610  break;
611 
612  /* All these Collection types have ngeoms and geoms elements */
613  case MULTIPOINTTYPE:
614  case MULTILINETYPE:
615  case MULTIPOLYGONTYPE:
616  case COMPOUNDTYPE:
617  case CURVEPOLYTYPE:
618  case MULTICURVETYPE:
619  case MULTISURFACETYPE:
620  case COLLECTIONTYPE:
622  case TINTYPE:
623  size += lwcollection_to_wkb_size((LWCOLLECTION*)geom, variant);
624  break;
625 
626  /* Unknown type! */
627  default:
628  lwerror("Unsupported geometry type: %s [%d]", lwtype_name(geom->type), geom->type);
629  }
630 
631  return size;
632 }
#define LINETYPE
Definition: liblwgeom.h:61
#define MULTICURVETYPE
Definition: liblwgeom.h:70
#define POLYGONTYPE
Definition: liblwgeom.h:62
#define CURVEPOLYTYPE
Definition: liblwgeom.h:69
#define COMPOUNDTYPE
Definition: liblwgeom.h:68
#define MULTIPOINTTYPE
Definition: liblwgeom.h:63
#define TRIANGLETYPE
Definition: liblwgeom.h:73
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:72
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:164
#define TINTYPE
Definition: liblwgeom.h:74
static size_t lwpoly_to_wkb_size(const LWPOLY *poly, uint8_t variant)
Definition: lwout_wkb.c:484
static size_t empty_to_wkb_size(const LWGEOM *geom, uint8_t variant)
Definition: lwout_wkb.c:275
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:65
static size_t lwpoint_to_wkb_size(const LWPOINT *pt, uint8_t variant)
Definition: lwout_wkb.c:376
#define MULTISURFACETYPE
Definition: liblwgeom.h:71
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:60
uint8_t type
Definition: liblwgeom.h:352
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:67
static size_t lwcollection_to_wkb_size(const LWCOLLECTION *col, uint8_t variant)
Definition: lwout_wkb.c:531
static size_t lwtriangle_to_wkb_size(const LWTRIANGLE *tri, uint8_t variant)
Definition: lwout_wkb.c:445
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:1229
#define MULTILINETYPE
Definition: liblwgeom.h:64
static size_t lwline_to_wkb_size(const LWLINE *line, uint8_t variant)
Definition: lwout_wkb.c:414
#define COLLECTIONTYPE
Definition: liblwgeom.h:66

Here is the call graph for this function:

Here is the caller graph for this function: