PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void test_ptarray_insert_point ( void  )
static

Definition at line 60 of file cu_ptarray.c.

References lwfree(), lwgeom_as_lwline(), lwgeom_from_text(), lwgeom_to_text(), lwline_as_lwgeom(), lwline_free(), LWLINE::points, ptarray_insert_point(), POINT4D::x, and POINT4D::y.

Referenced by ptarray_suite_setup().

61 {
62  LWLINE *line;
63  char *wkt;
64  POINT4D p;
65 
66  line = lwgeom_as_lwline(lwgeom_from_text("LINESTRING EMPTY"));
67  p.x = 1;
68  p.y = 1;
69  ptarray_insert_point(line->points, &p, 0);
70  wkt = lwgeom_to_text(lwline_as_lwgeom(line));
71  CU_ASSERT_STRING_EQUAL(wkt,"LINESTRING(1 1)");
72  lwfree(wkt);
73 
74  p.x = 2;
75  p.y = 20;
76  ptarray_insert_point(line->points, &p, 0);
77  wkt = lwgeom_to_text(lwline_as_lwgeom(line));
78  CU_ASSERT_STRING_EQUAL(wkt,"LINESTRING(2 20,1 1)");
79  lwfree(wkt);
80 
81  p.x = 3;
82  p.y = 30;
83  ptarray_insert_point(line->points, &p, 1);
84  wkt = lwgeom_to_text(lwline_as_lwgeom(line));
85  CU_ASSERT_STRING_EQUAL(wkt,"LINESTRING(2 20,3 30,1 1)");
86  lwfree(wkt);
87 
88  p.x = 4;
89  p.y = 40;
90  ptarray_insert_point(line->points, &p, 0);
91  wkt = lwgeom_to_text(lwline_as_lwgeom(line));
92  CU_ASSERT_STRING_EQUAL(wkt,"LINESTRING(4 40,2 20,3 30,1 1)");
93  lwfree(wkt);
94 
95  p.x = 5;
96  p.y = 50;
97  ptarray_insert_point(line->points, &p, 4);
98  wkt = lwgeom_to_text(lwline_as_lwgeom(line));
99  CU_ASSERT_STRING_EQUAL(wkt,"LINESTRING(4 40,2 20,3 30,1 1,5 50)");
100  lwfree(wkt);
101 
102  lwline_free(line);
103 }
double x
Definition: liblwgeom.h:308
void lwfree(void *mem)
Definition: lwutil.c:190
void lwline_free(LWLINE *line)
Definition: lwline.c:63
static LWGEOM * lwgeom_from_text(const char *str)
Definition: cu_ptarray.c:25
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:249
static char * lwgeom_to_text(const LWGEOM *geom)
Definition: cu_ptarray.c:33
int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, int where)
Insert a point into an existing POINTARRAY.
Definition: ptarray.c:84
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition: lwgeom.c:89
double y
Definition: liblwgeom.h:308
POINTARRAY * points
Definition: liblwgeom.h:378

Here is the call graph for this function:

Here is the caller graph for this function: