PostGIS 3.7.0dev-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 818 of file gserialized1.c.

819{
820 uint32_t i;
821 uint8_t *loc;
822 int ptsize;
823 int type = POLYGONTYPE;
824
825 assert(poly);
826 assert(buf);
827
828 LWDEBUGF(2, "%s called", __func__);
829
830 ptsize = sizeof(double) * FLAGS_NDIMS(poly->flags);
831 loc = buf;
832
833 /* Write in the type. */
834 memcpy(loc, &type, sizeof(uint32_t));
835 loc += sizeof(uint32_t);
836
837 /* Write in the nrings. */
838 memcpy(loc, &(poly->nrings), sizeof(uint32_t));
839 loc += sizeof(uint32_t);
840
841 /* Write in the npoints per ring. */
842 for ( i = 0; i < poly->nrings; i++ )
843 {
844 memcpy(loc, &(poly->rings[i]->npoints), sizeof(uint32_t));
845 loc += sizeof(uint32_t);
846 }
847
848 /* Add in padding if necessary to remain double aligned. */
849 if ( poly->nrings % 2 )
850 {
851 memset(loc, 0, sizeof(uint32_t));
852 loc += sizeof(uint32_t);
853 }
854
855 /* Copy in the ordinates. */
856 for ( i = 0; i < poly->nrings; i++ )
857 {
858 POINTARRAY *pa = poly->rings[i];
859 size_t pasize;
860
861 if ( FLAGS_GET_ZM(poly->flags) != FLAGS_GET_ZM(pa->flags) )
862 lwerror("Dimensions mismatch in lwpoly");
863
864 pasize = (size_t)pa->npoints * ptsize;
865 if ( pa->npoints > 0 )
866 memcpy(loc, getPoint_internal(pa, 0), pasize);
867 loc += pasize;
868 }
869 return (size_t)(loc - buf);
870}
#define FLAGS_NDIMS(flags)
Definition liblwgeom.h:179
#define POLYGONTYPE
Definition liblwgeom.h:104
#define FLAGS_GET_ZM(flags)
Definition liblwgeom.h:180
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:106
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition lwinline.h:75
POINTARRAY ** rings
Definition liblwgeom.h:519
uint32_t nrings
Definition liblwgeom.h:524
lwflags_t flags
Definition liblwgeom.h:521
lwflags_t flags
Definition liblwgeom.h:431
uint32_t npoints
Definition liblwgeom.h:427

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: