PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ gserialized_from_lwline()

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

Definition at line 865 of file g_serialized.c.

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().

866 {
867  uint8_t *loc;
868  int ptsize;
869  size_t size;
870  int type = LINETYPE;
871 
872  assert(line);
873  assert(buf);
874 
875  LWDEBUGF(2, "lwline_to_gserialized(%p, %p) called", line, buf);
876 
877  if ( FLAGS_GET_Z(line->flags) != FLAGS_GET_Z(line->points->flags) )
878  lwerror("Dimensions mismatch in lwline");
879 
880  ptsize = ptarray_point_size(line->points);
881 
882  loc = buf;
883 
884  /* Write in the type. */
885  memcpy(loc, &type, sizeof(uint32_t));
886  loc += sizeof(uint32_t);
887 
888  /* Write in the npoints. */
889  memcpy(loc, &(line->points->npoints), sizeof(uint32_t));
890  loc += sizeof(uint32_t);
891 
892  LWDEBUGF(3, "lwline_to_gserialized added npoints (%d)", line->points->npoints);
893 
894  /* Copy in the ordinates. */
895  if ( line->points->npoints > 0 )
896  {
897  size = line->points->npoints * ptsize;
898  memcpy(loc, getPoint_internal(line->points, 0), size);
899  loc += size;
900  }
901  LWDEBUGF(3, "lwline_to_gserialized copied serialized_pointlist (%d bytes)", ptsize * line->points->npoints);
902 
903  return (size_t)(loc - buf);
904 }
#define LINETYPE
Definition: liblwgeom.h:86
int npoints
Definition: liblwgeom.h:371
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
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
type
Definition: ovdump.py:41
uint8_t flags
Definition: liblwgeom.h:419
#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
POINTARRAY * points
Definition: liblwgeom.h:422
Here is the call graph for this function:
Here is the caller graph for this function: