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

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

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

Here is the call graph for this function:

Here is the caller graph for this function: