PostGIS  2.5.0dev-r@@SVN_REVISION@@
static void test_ptarray_scale ( )
static

Definition at line 695 of file cu_ptarray.c.

References ASSERT_STRING_EQUAL, lwfree(), lwgeom_as_lwline(), lwgeom_from_text(), lwgeom_to_text(), lwline_as_lwgeom(), lwline_free(), POINT4D::m, LWLINE::points, ptarray_scale(), POINT4D::x, POINT4D::y, and POINT4D::z.

Referenced by ptarray_suite_setup().

696 {
697  LWLINE *line;
698  POINTARRAY *pa;
699  POINT4D factor;
700  const char *wkt;
701  char *wktout;
702 
703  wkt = "LINESTRING ZM (0 1 2 3,1 2 3 0,-2 -3 0 -1,-3 0 -1 -2)";
704  line = lwgeom_as_lwline(lwgeom_from_text(wkt));
705  pa = line->points;
706 
707  factor.x = factor.y = factor.z = factor.m = 1;
708  ptarray_scale(pa, &factor);
709  wktout = lwgeom_to_text(lwline_as_lwgeom(line));
710  ASSERT_STRING_EQUAL(wktout, wkt);
711  lwfree(wktout);
712 
713  factor.x = 2;
714  wkt = "LINESTRING ZM (0 1 2 3,2 2 3 0,-4 -3 0 -1,-6 0 -1 -2)";
715  ptarray_scale(pa, &factor);
716  wktout = lwgeom_to_text(lwline_as_lwgeom(line));
717  ASSERT_STRING_EQUAL(wktout, wkt);
718  lwfree(wktout);
719 
720  factor.x = 1; factor.y = 3;
721  wkt = "LINESTRING ZM (0 3 2 3,2 6 3 0,-4 -9 0 -1,-6 0 -1 -2)";
722  ptarray_scale(pa, &factor);
723  wktout = lwgeom_to_text(lwline_as_lwgeom(line));
724  ASSERT_STRING_EQUAL(wktout, wkt);
725  lwfree(wktout);
726 
727  factor.x = 1; factor.y = 1; factor.z = -2;
728  wkt = "LINESTRING ZM (0 3 -4 3,2 6 -6 0,-4 -9 0 -1,-6 0 2 -2)";
729  ptarray_scale(pa, &factor);
730  wktout = lwgeom_to_text(lwline_as_lwgeom(line));
731  ASSERT_STRING_EQUAL(wktout, wkt);
732  lwfree(wktout);
733 
734  factor.x = 1; factor.y = 1; factor.z = 1; factor.m = 2;
735  wkt = "LINESTRING ZM (0 3 -4 6,2 6 -6 0,-4 -9 0 -2,-6 0 2 -4)";
736  ptarray_scale(pa, &factor);
737  wktout = lwgeom_to_text(lwline_as_lwgeom(line));
738  ASSERT_STRING_EQUAL(wktout, wkt);
739  lwfree(wktout);
740 
741  lwline_free(line);
742 }
double x
Definition: liblwgeom.h:351
double m
Definition: liblwgeom.h:351
void lwfree(void *mem)
Definition: lwutil.c:244
void ptarray_scale(POINTARRAY *pa, const POINT4D *factor)
Scale a pointarray.
Definition: ptarray.c:1840
#define ASSERT_STRING_EQUAL(o, e)
void lwline_free(LWLINE *line)
Definition: lwline.c:76
static LWGEOM * lwgeom_from_text(const char *str)
Definition: cu_ptarray.c:24
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:329
static char * lwgeom_to_text(const LWGEOM *geom)
Definition: cu_ptarray.c:32
double z
Definition: liblwgeom.h:351
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition: lwgeom.c:169
double y
Definition: liblwgeom.h:351
POINTARRAY * points
Definition: liblwgeom.h:421

Here is the call graph for this function:

Here is the caller graph for this function: