PostGIS  2.1.10dev-r@@SVN_REVISION@@
static size_t gserialized_from_lwpoint ( const LWPOINT point,
uint8_t *  buf 
)
static

Definition at line 563 of file g_serialized.c.

References POINTARRAY::flags, LWPOINT::flags, FLAGS_GET_ZM, getPoint_internal(), LWDEBUGF, lwerror(), POINTARRAY::npoints, LWPOINT::point, POINTTYPE, and ptarray_point_size().

Referenced by gserialized_from_lwgeom_any().

564 {
565  uint8_t *loc;
566  int ptsize = ptarray_point_size(point->point);
567  int type = POINTTYPE;
568 
569  assert(point);
570  assert(buf);
571 
572  if ( FLAGS_GET_ZM(point->flags) != FLAGS_GET_ZM(point->point->flags) )
573  lwerror("Dimensions mismatch in lwpoint");
574 
575  LWDEBUGF(2, "lwpoint_to_gserialized(%p, %p) called", point, buf);
576 
577  loc = buf;
578 
579  /* Write in the type. */
580  memcpy(loc, &type, sizeof(uint32_t));
581  loc += sizeof(uint32_t);
582  /* Write in the number of points (0 => empty). */
583  memcpy(loc, &(point->point->npoints), sizeof(uint32_t));
584  loc += sizeof(uint32_t);
585 
586  /* Copy in the ordinates. */
587  if ( point->point->npoints > 0 )
588  {
589  memcpy(loc, getPoint_internal(point->point, 0), ptsize);
590  loc += ptsize;
591  }
592 
593  return (size_t)(loc - buf);
594 }
int npoints
Definition: liblwgeom.h:327
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:119
POINTARRAY * point
Definition: liblwgeom.h:367
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
uint8_t flags
Definition: liblwgeom.h:325
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1645
int ptarray_point_size(const POINTARRAY *pa)
Definition: ptarray.c:41
uint8_t flags
Definition: liblwgeom.h:364
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:60
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55

Here is the call graph for this function:

Here is the caller graph for this function: