PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ gserialized_from_lwpoint()

static size_t gserialized_from_lwpoint ( const LWPOINT point,
uint8_t buf 
)
static

Definition at line 832 of file g_serialized.c.

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

Referenced by gserialized_from_lwgeom_any().

833 {
834  uint8_t *loc;
835  int ptsize = ptarray_point_size(point->point);
836  int type = POINTTYPE;
837 
838  assert(point);
839  assert(buf);
840 
841  if ( FLAGS_GET_ZM(point->flags) != FLAGS_GET_ZM(point->point->flags) )
842  lwerror("Dimensions mismatch in lwpoint");
843 
844  LWDEBUGF(2, "lwpoint_to_gserialized(%p, %p) called", point, buf);
845 
846  loc = buf;
847 
848  /* Write in the type. */
849  memcpy(loc, &type, sizeof(uint32_t));
850  loc += sizeof(uint32_t);
851  /* Write in the number of points (0 => empty). */
852  memcpy(loc, &(point->point->npoints), sizeof(uint32_t));
853  loc += sizeof(uint32_t);
854 
855  /* Copy in the ordinates. */
856  if ( point->point->npoints > 0 )
857  {
858  memcpy(loc, getPoint_internal(point->point, 0), ptsize);
859  loc += ptsize;
860  }
861 
862  return (size_t)(loc - buf);
863 }
int npoints
Definition: liblwgeom.h:371
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:153
POINTARRAY * point
Definition: liblwgeom.h:411
unsigned int uint32_t
Definition: uthash.h:78
uint8_t flags
Definition: liblwgeom.h:369
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1753
int ptarray_point_size(const POINTARRAY *pa)
Definition: ptarray.c:54
uint8_t flags
Definition: liblwgeom.h:408
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
type
Definition: ovdump.py:41
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
unsigned char uint8_t
Definition: uthash.h:79
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
Here is the call graph for this function:
Here is the caller graph for this function: