PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ 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.

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

20 {
21 #if POSTGIS_GEOS_VERSION >= 35
22  LWGEOM *in, *out;
23  const char *wkt;
24  char *tmp;
25 
26  /* Because i don't trust that much prior tests... ;) */
28 
29  wkt = "LINESTRING(0 0, 5 5, 10 0)";
31  out = lwgeom_clip_by_rect(in, 5, 0, 10, 10);
32  tmp = lwgeom_to_ewkt(out);
33  /* printf("%s\n", tmp); */
34  CU_ASSERT_STRING_EQUAL("LINESTRING(5 5,10 0)", tmp)
35  lwfree(tmp); lwgeom_free(out); lwgeom_free(in);
36 
37  wkt = "LINESTRING EMPTY";
39  out = lwgeom_clip_by_rect(in, 5, 0, 10, 10);
40  tmp = lwgeom_to_ewkt(out);
41  /* printf("%s\n", tmp); */
42  CU_ASSERT_STRING_EQUAL(wkt, tmp)
43  lwfree(tmp); lwgeom_free(out); lwgeom_free(in);
44 
45  wkt = "MULTIPOINT EMPTY";
47  out = lwgeom_clip_by_rect(in, 5, 0, 10, 10);
48  tmp = lwgeom_to_ewkt(out);
49  /* printf("%s\n", tmp); */
50  CU_ASSERT_STRING_EQUAL(wkt, tmp)
51  lwfree(tmp); lwgeom_free(out); lwgeom_free(in);
52 
53  wkt = "MULTIPOINT(0 0, 6 6, 7 5)";
55  out = lwgeom_clip_by_rect(in, 5, 0, 10, 10);
56  tmp = lwgeom_to_ewkt(out);
57  /* printf("%s\n", tmp); */
58  CU_ASSERT_STRING_EQUAL("MULTIPOINT(6 6,7 5)", tmp)
59  lwfree(tmp); lwgeom_free(out); lwgeom_free(in);
60 
61  /* Disjoint polygon */
62  wkt = "POLYGON((311017 4773762,311016 4773749,311006 4773744,310990 4773748,310980 4773758,310985 4773771,311003 4773776,311017 4773762))";
64  out = lwgeom_clip_by_rect(in, -80, -80, 80, 80);
65  //tmp = lwgeom_to_ewkt(out); printf("%s\n", tmp); lwfree(tmp);
66  CU_ASSERT(lwgeom_is_empty(out));
67  lwgeom_free(out); lwgeom_free(in);
68 
69 #endif /* POSTGIS_GEOS_VERSION >= 35 */
70 }
void lwfree(void *mem)
Definition: lwutil.c:244
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
Definition: lwgeom.c:518
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
LWGEOM * lwgeom_clip_by_rect(const LWGEOM *geom1, double x0, double y0, double x1, double y1)
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2013
void cu_error_msg_reset()
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1346
Here is the call graph for this function:
Here is the caller graph for this function: