PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ gserialized1_from_lwpoly()

static size_t gserialized1_from_lwpoly ( const LWPOLY poly,
uint8_t *  buf 
)
static

Definition at line 817 of file gserialized1.c.

818{
819 uint32_t i;
820 uint8_t *loc;
821 int ptsize;
822 int type = POLYGONTYPE;
823
824 assert(poly);
825 assert(buf);
826
827 LWDEBUGF(2, "%s called", __func__);
828
829 ptsize = sizeof(double) * FLAGS_NDIMS(poly->flags);
830 loc = buf;
831
832 /* Write in the type. */
833 memcpy(loc, &type, sizeof(uint32_t));
834 loc += sizeof(uint32_t);
835
836 /* Write in the nrings. */
837 memcpy(loc, &(poly->nrings), sizeof(uint32_t));
838 loc += sizeof(uint32_t);
839
840 /* Write in the npoints per ring. */
841 for ( i = 0; i < poly->nrings; i++ )
842 {
843 memcpy(loc, &(poly->rings[i]->npoints), sizeof(uint32_t));
844 loc += sizeof(uint32_t);
845 }
846
847 /* Add in padding if necessary to remain double aligned. */
848 if ( poly->nrings % 2 )
849 {
850 memset(loc, 0, sizeof(uint32_t));
851 loc += sizeof(uint32_t);
852 }
853
854 /* Copy in the ordinates. */
855 for ( i = 0; i < poly->nrings; i++ )
856 {
857 POINTARRAY *pa = poly->rings[i];
858 size_t pasize;
859
860 if ( FLAGS_GET_ZM(poly->flags) != FLAGS_GET_ZM(pa->flags) )
861 lwerror("Dimensions mismatch in lwpoly");
862
863 pasize = pa->npoints * ptsize;
864 if ( pa->npoints > 0 )
865 memcpy(loc, getPoint_internal(pa, 0), pasize);
866 loc += pasize;
867 }
868 return (size_t)(loc - buf);
869}
#define FLAGS_NDIMS(flags)
Definition liblwgeom.h:193
#define POLYGONTYPE
Definition liblwgeom.h:118
#define FLAGS_GET_ZM(flags)
Definition liblwgeom.h:194
#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
static uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition lwinline.h:67
POINTARRAY ** rings
Definition liblwgeom.h:505
uint32_t nrings
Definition liblwgeom.h:510
lwflags_t flags
Definition liblwgeom.h:507
lwflags_t flags
Definition liblwgeom.h:417
uint32_t npoints
Definition liblwgeom.h:413

References POINTARRAY::flags, LWPOLY::flags, FLAGS_GET_ZM, FLAGS_NDIMS, getPoint_internal(), LWDEBUGF, lwerror(), POINTARRAY::npoints, LWPOLY::nrings, POLYGONTYPE, and LWPOLY::rings.

Referenced by gserialized1_from_lwgeom_any().

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