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

Definition at line 829 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().

830 {
831  uint8_t *loc;
832  int ptsize = ptarray_point_size(point->point);
833  int type = POINTTYPE;
834 
835  assert(point);
836  assert(buf);
837 
838  if ( FLAGS_GET_ZM(point->flags) != FLAGS_GET_ZM(point->point->flags) )
839  lwerror("Dimensions mismatch in lwpoint");
840 
841  LWDEBUGF(2, "lwpoint_to_gserialized(%p, %p) called", point, buf);
842 
843  loc = buf;
844 
845  /* Write in the type. */
846  memcpy(loc, &type, sizeof(uint32_t));
847  loc += sizeof(uint32_t);
848  /* Write in the number of points (0 => empty). */
849  memcpy(loc, &(point->point->npoints), sizeof(uint32_t));
850  loc += sizeof(uint32_t);
851 
852  /* Copy in the ordinates. */
853  if ( point->point->npoints > 0 )
854  {
855  memcpy(loc, getPoint_internal(point->point, 0), ptsize);
856  loc += ptsize;
857  }
858 
859  return (size_t)(loc - buf);
860 }
size_t ptarray_point_size(const POINTARRAY *pa)
Definition: ptarray.c:54
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:152
POINTARRAY * point
Definition: liblwgeom.h:410
unsigned int uint32_t
Definition: uthash.h:78
uint8_t flags
Definition: liblwgeom.h:368
uint8_t flags
Definition: liblwgeom.h:407
uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition: ptarray.c:1745
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
#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
uint32_t npoints
Definition: liblwgeom.h:370

Here is the call graph for this function:

Here is the caller graph for this function: