PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ test_ptarray_insert_point()

static void test_ptarray_insert_point ( void  )
static

Definition at line 59 of file cu_ptarray.c.

60{
61 LWLINE *line;
62 char *wkt;
63 POINT4D p;
64
65 line = lwgeom_as_lwline(lwgeom_from_text("LINESTRING EMPTY"));
66 p.x = 1;
67 p.y = 1;
68 ptarray_insert_point(line->points, &p, 0);
70 ASSERT_STRING_EQUAL(wkt,"LINESTRING(1 1)");
71 lwfree(wkt);
72
73 p.x = 2;
74 p.y = 20;
75 ptarray_insert_point(line->points, &p, 0);
77 ASSERT_STRING_EQUAL(wkt,"LINESTRING(2 20,1 1)");
78 lwfree(wkt);
79
80 p.x = 3;
81 p.y = 30;
82 ptarray_insert_point(line->points, &p, 1);
84 ASSERT_STRING_EQUAL(wkt,"LINESTRING(2 20,3 30,1 1)");
85 lwfree(wkt);
86
87 p.x = 4;
88 p.y = 40;
89 ptarray_insert_point(line->points, &p, 0);
91 ASSERT_STRING_EQUAL(wkt,"LINESTRING(4 40,2 20,3 30,1 1)");
92 lwfree(wkt);
93
94 p.x = 5;
95 p.y = 50;
96 ptarray_insert_point(line->points, &p, 4);
98 ASSERT_STRING_EQUAL(wkt,"LINESTRING(4 40,2 20,3 30,1 1,5 50)");
99 lwfree(wkt);
100
101 lwline_free(line);
102}
static char * lwgeom_to_text(const LWGEOM *geom)
Definition cu_ptarray.c:32
static LWGEOM * lwgeom_from_text(const char *str)
Definition cu_ptarray.c:24
#define ASSERT_STRING_EQUAL(o, e)
int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, uint32_t where)
Insert a point into an existing POINTARRAY.
Definition ptarray.c:85
void lwfree(void *mem)
Definition lwutil.c:248
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition lwgeom.c:367
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition lwgeom.c:207
void lwline_free(LWLINE *line)
Definition lwline.c:67
POINTARRAY * points
Definition liblwgeom.h:483
double x
Definition liblwgeom.h:414
double y
Definition liblwgeom.h:414

References ASSERT_STRING_EQUAL, 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().

Here is the call graph for this function:
Here is the caller graph for this function: