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

◆ test_lwgeom_clip_by_rect()

static void test_lwgeom_clip_by_rect ( void  )
static

Definition at line 19 of file cu_clip_by_rect.c.

20{
21 LWGEOM *in, *out;
22 const char *wkt;
23 char *tmp;
24
25 /* Because i don't trust that much prior tests... ;) */
27
28 wkt = "LINESTRING(0 0, 5 5, 10 0)";
30 out = lwgeom_clip_by_rect(in, 5, 0, 10, 10);
31 tmp = lwgeom_to_ewkt(out);
32 /* printf("%s\n", tmp); */
33 ASSERT_STRING_EQUAL(tmp, "LINESTRING(5 5,10 0)");
34 lwfree(tmp); lwgeom_free(out); lwgeom_free(in);
35
36 wkt = "LINESTRING EMPTY";
38 out = lwgeom_clip_by_rect(in, 5, 0, 10, 10);
39 tmp = lwgeom_to_ewkt(out);
40 /* printf("%s\n", tmp); */
41 ASSERT_STRING_EQUAL(tmp, wkt);
42 lwfree(tmp); lwgeom_free(out); lwgeom_free(in);
43
44 wkt = "MULTIPOINT EMPTY";
46 out = lwgeom_clip_by_rect(in, 5, 0, 10, 10);
47 tmp = lwgeom_to_ewkt(out);
48 /* printf("%s\n", tmp); */
49 ASSERT_STRING_EQUAL(tmp, wkt);
50 lwfree(tmp); lwgeom_free(out); lwgeom_free(in);
51
52 wkt = "MULTIPOINT(0 0, 6 6, 7 5)";
54 out = lwgeom_clip_by_rect(in, 5, 0, 10, 10);
55 tmp = lwgeom_to_ewkt(out);
56 /* printf("%s\n", tmp); */
57 ASSERT_STRING_EQUAL(tmp, "MULTIPOINT(6 6,7 5)");
58 lwfree(tmp); lwgeom_free(out); lwgeom_free(in);
59
60 /* Disjoint polygon */
61 wkt = "POLYGON((311017 4773762,311016 4773749,311006 4773744,310990 4773748,310980 4773758,310985 4773771,311003 4773776,311017 4773762))";
63 out = lwgeom_clip_by_rect(in, -80, -80, 80, 80);
64 //tmp = lwgeom_to_ewkt(out); printf("%s\n", tmp); lwfree(tmp);
65 CU_ASSERT(lwgeom_is_empty(out));
66 lwgeom_free(out); lwgeom_free(in);
67
68 /* Returns NULL with an invalid polygon (line) */
69 wkt = "POLYGON((1410 2055, 1410 2056, 1410 2057, 1410 2055))";
71 out = lwgeom_clip_by_rect(in, -8.000000, -8.000000, 2056.000000, 2056.000000);
72 CU_ASSERT_PTR_NULL(out);
73 lwgeom_free(in);
74}
void cu_error_msg_reset()
#define ASSERT_STRING_EQUAL(o, e)
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1246
#define LW_PARSER_CHECK_NONE
Definition liblwgeom.h:2149
LWGEOM * lwgeom_clip_by_rect(const LWGEOM *geom1, double x0, double y0, double x1, double y1)
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an allocated string.
Definition lwgeom.c:593
void lwfree(void *mem)
Definition lwutil.c:248
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition lwin_wkt.c:940
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition lwinline.h:199

References ASSERT_STRING_EQUAL, cu_error_msg_reset(), LW_PARSER_CHECK_NONE, lwfree(), lwgeom_clip_by_rect(), lwgeom_free(), lwgeom_from_wkt(), lwgeom_is_empty(), and lwgeom_to_ewkt().

Referenced by clip_by_rect_suite_setup().

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