PostGIS  2.5.2dev-r@@SVN_REVISION@@

◆ gserialized_from_lwpoint()

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

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

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