PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ test_lwgeom_wrapx()

static void test_lwgeom_wrapx ( void  )
static

Definition at line 20 of file cu_wrapx.c.

21 {
22  LWGEOM *geom, *ret, *tmp, *tmp2;
23  char *exp_wkt, *obt_wkt;
24 
25  geom = lwgeom_from_wkt(
26  "POLYGON EMPTY",
28  CU_ASSERT_FATAL(geom != NULL);
29  ret = lwgeom_wrapx(geom, 0, 20);
30  CU_ASSERT_FATAL(ret != NULL);
31  obt_wkt = lwgeom_to_ewkt(ret);
32  exp_wkt = "POLYGON EMPTY";
33  ASSERT_STRING_EQUAL(obt_wkt, exp_wkt);
34  lwfree(obt_wkt);
35  lwgeom_free(ret);
36  lwgeom_free(geom);
37 
38  geom = lwgeom_from_wkt(
39  "POINT(0 0)",
41  CU_ASSERT_FATAL(geom != NULL);
42  ret = lwgeom_wrapx(geom, 2, 10);
43  CU_ASSERT_FATAL(ret != NULL);
44  obt_wkt = lwgeom_to_ewkt(ret);
45  exp_wkt = "POINT(10 0)";
46  ASSERT_STRING_EQUAL(obt_wkt, exp_wkt);
47  lwfree(obt_wkt);
48  lwgeom_free(ret);
49  lwgeom_free(geom);
50 
51  geom = lwgeom_from_wkt(
52  "POINT(0 0)",
54  CU_ASSERT_FATAL(geom != NULL);
55  ret = lwgeom_wrapx(geom, 0, 20);
56  CU_ASSERT_FATAL(ret != NULL);
57  obt_wkt = lwgeom_to_ewkt(ret);
58  exp_wkt = "POINT(0 0)";
59  ASSERT_STRING_EQUAL(obt_wkt, exp_wkt);
60  lwfree(obt_wkt);
61  lwgeom_free(ret);
62  lwgeom_free(geom);
63 
64  geom = lwgeom_from_wkt(
65  "POINT(0 0)",
67  CU_ASSERT_FATAL(geom != NULL);
68  ret = lwgeom_wrapx(geom, 0, -20);
69  CU_ASSERT_FATAL(ret != NULL);
70  obt_wkt = lwgeom_to_ewkt(ret);
71  exp_wkt = "POINT(0 0)";
72  ASSERT_STRING_EQUAL(obt_wkt, exp_wkt);
73  lwfree(obt_wkt);
74  lwgeom_free(ret);
75  lwgeom_free(geom);
76 
77  geom = lwgeom_from_wkt(
78  "LINESTRING(0 0,10 0)",
80  CU_ASSERT_FATAL(geom != NULL);
81  tmp = lwgeom_wrapx(geom, 8, -10);
82  ret = lwgeom_normalize(tmp);
83  lwgeom_free(tmp);
84  CU_ASSERT_FATAL(ret != NULL);
85  obt_wkt = lwgeom_to_ewkt(ret);
86  tmp = lwgeom_from_wkt(
87  "MULTILINESTRING((0 0,8 0),(-2 0,0 0))",
89  tmp2 = lwgeom_normalize(tmp);
90  lwgeom_free(tmp);
91  exp_wkt = lwgeom_to_ewkt(tmp2);
92  lwgeom_free(tmp2);
93  ASSERT_STRING_EQUAL(obt_wkt, exp_wkt);
94  lwfree(obt_wkt);
95  lwfree(exp_wkt);
96  lwgeom_free(ret);
97  lwgeom_free(geom);
98 
99  geom = lwgeom_from_wkt(
100  "MULTILINESTRING((-5 -2,0 0),(0 0,10 10))",
102  CU_ASSERT_FATAL(geom != NULL);
103  tmp = lwgeom_wrapx(geom, 0, 20);
104  ret = lwgeom_normalize(tmp);
105  lwgeom_free(tmp);
106  CU_ASSERT_FATAL(ret != NULL);
107  obt_wkt = lwgeom_to_ewkt(ret);
108  tmp = lwgeom_from_wkt("MULTILINESTRING((15 -2,20 0),(0 0,10 10))", LW_PARSER_CHECK_NONE);
109  tmp2 = lwgeom_normalize(tmp);
110  lwgeom_free(tmp);
111  exp_wkt = lwgeom_to_ewkt(tmp2);
112  lwgeom_free(tmp2);
113  ASSERT_STRING_EQUAL(obt_wkt, exp_wkt);
114  lwfree(obt_wkt);
115  lwfree(exp_wkt);
116  lwgeom_free(ret);
117  lwgeom_free(geom);
118 
119  geom = lwgeom_from_wkt(
120  "MULTIPOLYGON("
121  " ((0 0,10 0,10 10,0 10,0 0),(2 2,4 2,4 4,2 4,2 2)),"
122  " ((0 11,10 11,10 21,0 21,0 11),(2 13,4 13,4 15,2 15,2 13))"
123  ")",
125  CU_ASSERT_FATAL(geom != NULL);
126  tmp = lwgeom_wrapx(geom, 2, 20);
127  ret = lwgeom_normalize(tmp);
128  lwgeom_free(tmp);
129  CU_ASSERT_FATAL(ret != NULL);
130  obt_wkt = lwgeom_to_ewkt(ret);
131  tmp = lwgeom_from_wkt("GEOMETRYCOLLECTION("
132  "MULTIPOLYGON("
133  "((22 0,20 0,20 10,22 10,22 4,22 2,22 0)),"
134  "((2 10,10 10,10 0,2 0,2 2,4 2,4 4,2 4,2 10))"
135  "),"
136  "MULTIPOLYGON("
137  "((22 11,20 11,20 21,22 21,22 15,22 13,22 11)),"
138  "((2 21,10 21,10 11,2 11,2 13,4 13,4 15,2 15,2 21))"
139  ")"
140  ")",
142  tmp2 = lwgeom_normalize(tmp);
143  lwgeom_free(tmp);
144  exp_wkt = lwgeom_to_ewkt(tmp2);
145  lwgeom_free(tmp2);
146  ASSERT_STRING_EQUAL(obt_wkt, exp_wkt);
147  lwfree(obt_wkt);
148  lwfree(exp_wkt);
149  lwgeom_free(ret);
150  lwgeom_free(geom);
151 
152  geom = lwgeom_from_wkt(
153  "GEOMETRYCOLLECTION("
154  " MULTILINESTRING((-5 -2,0 0),(0 0,10 10)),"
155  " POINT(-5 0),"
156  " POLYGON EMPTY"
157  ")",
159  CU_ASSERT_FATAL(geom != NULL);
160  tmp = lwgeom_wrapx(geom, 0, 20);
161  ret = lwgeom_normalize(tmp);
162  lwgeom_free(tmp);
163  CU_ASSERT_FATAL(ret != NULL);
164  obt_wkt = lwgeom_to_ewkt(ret);
165  tmp = lwgeom_from_wkt(
166  "GEOMETRYCOLLECTION("
167  "MULTILINESTRING((15 -2,20 0),(0 0,10 10)),"
168  "POINT(15 0),"
169  "POLYGON EMPTY"
170  ")",
172  tmp2 = lwgeom_normalize(tmp);
173  lwgeom_free(tmp);
174  exp_wkt = lwgeom_to_ewkt(tmp2);
175  lwgeom_free(tmp2);
176  ASSERT_STRING_EQUAL(obt_wkt, exp_wkt);
177  lwfree(obt_wkt);
178  lwfree(exp_wkt);
179  lwgeom_free(ret);
180  lwgeom_free(geom);
181 }
#define ASSERT_STRING_EQUAL(o, e)
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1138
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2060
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
Definition: lwgeom.c:547
void lwfree(void *mem)
Definition: lwutil.c:242
LWGEOM * lwgeom_normalize(const LWGEOM *geom)
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:905
LWGEOM * lwgeom_wrapx(const LWGEOM *lwgeom, double cutx, double amount)
wrap geometry on given cut x value
Definition: lwgeom_wrapx.c:169

References ASSERT_STRING_EQUAL, LW_PARSER_CHECK_NONE, lwfree(), lwgeom_free(), lwgeom_from_wkt(), lwgeom_normalize(), lwgeom_to_ewkt(), and lwgeom_wrapx().

Referenced by wrapx_suite_setup().

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