PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ gserialized_from_lwline()

static size_t gserialized_from_lwline ( const LWLINE line,
uint8_t buf 
)
static

Definition at line 863 of file g_serialized.c.

864 {
865  uint8_t *loc;
866  int ptsize;
867  size_t size;
868  int type = LINETYPE;
869 
870  assert(line);
871  assert(buf);
872 
873  LWDEBUGF(2, "lwline_to_gserialized(%p, %p) called", line, buf);
874 
875  if ( FLAGS_GET_Z(line->flags) != FLAGS_GET_Z(line->points->flags) )
876  lwerror("Dimensions mismatch in lwline");
877 
878  ptsize = ptarray_point_size(line->points);
879 
880  loc = buf;
881 
882  /* Write in the type. */
883  memcpy(loc, &type, sizeof(uint32_t));
884  loc += sizeof(uint32_t);
885 
886  /* Write in the npoints. */
887  memcpy(loc, &(line->points->npoints), sizeof(uint32_t));
888  loc += sizeof(uint32_t);
889 
890  LWDEBUGF(3, "lwline_to_gserialized added npoints (%d)", line->points->npoints);
891 
892  /* Copy in the ordinates. */
893  if ( line->points->npoints > 0 )
894  {
895  size = line->points->npoints * ptsize;
896  memcpy(loc, getPoint_internal(line->points, 0), size);
897  loc += size;
898  }
899  LWDEBUGF(3, "lwline_to_gserialized copied serialized_pointlist (%d bytes)", ptsize * line->points->npoints);
900 
901  return (size_t)(loc - buf);
902 }
#define LINETYPE
Definition: liblwgeom.h:86
uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition: ptarray.c:1750
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
size_t ptarray_point_size(const POINTARRAY *pa)
Definition: ptarray.c:54
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
type
Definition: ovdump.py:41
uint8_t flags
Definition: liblwgeom.h:422
POINTARRAY * points
Definition: liblwgeom.h:425
uint32_t npoints
Definition: liblwgeom.h:374
uint8_t flags
Definition: liblwgeom.h:372
unsigned int uint32_t
Definition: uthash.h:78
unsigned char uint8_t
Definition: uthash.h:79

References POINTARRAY::flags, LWLINE::flags, FLAGS_GET_Z, getPoint_internal(), LINETYPE, LWDEBUGF, lwerror(), POINTARRAY::npoints, LWLINE::points, ptarray_point_size(), and ovdump::type.

Referenced by gserialized_from_lwgeom_any().

Here is the call graph for this function:
Here is the caller graph for this function: