PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ gserialized_from_lwline()

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

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

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