PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ test_ptarray_scale()

static void test_ptarray_scale ( )
static

Definition at line 570 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(), ptarray_suite_setup(), POINT4D::x, POINT4D::y, and POINT4D::z.

Referenced by ptarray_suite_setup().

571 {
572  LWLINE *line;
573  POINTARRAY *pa;
574  POINT4D factor;
575  const char *wkt;
576  char *wktout;
577 
578  wkt = "LINESTRING ZM (0 1 2 3,1 2 3 0,-2 -3 0 -1,-3 0 -1 -2)";
579  line = lwgeom_as_lwline(lwgeom_from_text(wkt));
580  pa = line->points;
581 
582  factor.x = factor.y = factor.z = factor.m = 1;
583  ptarray_scale(pa, &factor);
584  wktout = lwgeom_to_text(lwline_as_lwgeom(line));
585  ASSERT_STRING_EQUAL(wktout, wkt);
586  lwfree(wktout);
587 
588  factor.x = 2;
589  wkt = "LINESTRING ZM (0 1 2 3,2 2 3 0,-4 -3 0 -1,-6 0 -1 -2)";
590  ptarray_scale(pa, &factor);
591  wktout = lwgeom_to_text(lwline_as_lwgeom(line));
592  ASSERT_STRING_EQUAL(wktout, wkt);
593  lwfree(wktout);
594 
595  factor.x = 1; factor.y = 3;
596  wkt = "LINESTRING ZM (0 3 2 3,2 6 3 0,-4 -9 0 -1,-6 0 -1 -2)";
597  ptarray_scale(pa, &factor);
598  wktout = lwgeom_to_text(lwline_as_lwgeom(line));
599  ASSERT_STRING_EQUAL(wktout, wkt);
600  lwfree(wktout);
601 
602  factor.x = 1; factor.y = 1; factor.z = -2;
603  wkt = "LINESTRING ZM (0 3 -4 3,2 6 -6 0,-4 -9 0 -1,-6 0 2 -2)";
604  ptarray_scale(pa, &factor);
605  wktout = lwgeom_to_text(lwline_as_lwgeom(line));
606  ASSERT_STRING_EQUAL(wktout, wkt);
607  lwfree(wktout);
608 
609  factor.x = 1; factor.y = 1; factor.z = 1; factor.m = 2;
610  wkt = "LINESTRING ZM (0 3 -4 6,2 6 -6 0,-4 -9 0 -2,-6 0 2 -4)";
611  ptarray_scale(pa, &factor);
612  wktout = lwgeom_to_text(lwline_as_lwgeom(line));
613  ASSERT_STRING_EQUAL(wktout, wkt);
614  lwfree(wktout);
615 
616  lwline_free(line);
617 }
double x
Definition: liblwgeom.h:354
double m
Definition: liblwgeom.h:354
void lwfree(void *mem)
Definition: lwutil.c:244
void ptarray_scale(POINTARRAY *pa, const POINT4D *factor)
WARNING, make sure you send in only 16-member double arrays or obviously things will go pear-shaped f...
Definition: ptarray.c:1976
#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:330
static char * lwgeom_to_text(const LWGEOM *geom)
Definition: cu_ptarray.c:32
double z
Definition: liblwgeom.h:354
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition: lwgeom.c:170
double y
Definition: liblwgeom.h:354
POINTARRAY * points
Definition: liblwgeom.h:424
Here is the call graph for this function:
Here is the caller graph for this function: