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

Definition at line 275 of file cu_ptarray.c.

References LW_PARSER_CHECK_NONE, lwgeom_as_lwline(), lwgeom_as_lwpoly(), lwgeom_from_hexwkb(), lwgeom_from_text(), lwline_free(), lwpoly_free(), LWLINE::points, ptarray_isccw(), and LWPOLY::rings.

Referenced by ptarray_suite_setup().

276 {
277  LWLINE *line;
278  LWPOLY* poly;
279  int ccw;
280 
281  /* clockwise rectangle */
282  line = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(0 0,0 10,10 10,10 0, 0 0)"));
283  ccw = ptarray_isccw(line->points);
284  CU_ASSERT_EQUAL(ccw, 0);
285  lwline_free(line);
286 
287  /* clockwise triangle */
288  line = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(0 3,20 4,20 3, 0 3)"));
289  ccw = ptarray_isccw(line->points);
290  CU_ASSERT_EQUAL(ccw, 0);
291  lwline_free(line);
292 
293  /* counterclockwise triangle */
294  line = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(0 3,20 3,20 4, 0 3)"));
295  ccw = ptarray_isccw(line->points);
296  CU_ASSERT_EQUAL(ccw, 1);
297  lwline_free(line);
298 
299  /* counterclockwise narrow ring (see ticket #1302) */
300  line = lwgeom_as_lwline(lwgeom_from_hexwkb("01020000000500000000917E9BA468294100917E9B8AEA284137894120A4682941C976BE9F8AEA2841B39ABE1FA46829415ACCC29F8AEA2841C976BE1FA4682941C976BE9F8AEA284100917E9BA468294100917E9B8AEA2841", LW_PARSER_CHECK_NONE));
301  ccw = ptarray_isccw(line->points);
302  CU_ASSERT_EQUAL(ccw, 1);
303  lwline_free(line);
304 
305  /* clockwise narrow ring (see ticket #1302) */
306  line = lwgeom_as_lwline(lwgeom_from_hexwkb("01020000000500000000917E9BA468294100917E9B8AEA2841C976BE1FA4682941C976BE9F8AEA2841B39ABE1FA46829415ACCC29F8AEA284137894120A4682941C976BE9F8AEA284100917E9BA468294100917E9B8AEA2841", LW_PARSER_CHECK_NONE));
307  ccw = ptarray_isccw(line->points);
308  CU_ASSERT_EQUAL(ccw, 0);
309  lwline_free(line);
310 
311  /* Clockwise narrow ring (see ticket #1302) */
312  poly = lwgeom_as_lwpoly(lwgeom_from_hexwkb("0103000000010000000500000000917E9BA468294100917E9B8AEA2841C976BE1FA4682941C976BE9F8AEA2841B39ABE1FA46829415ACCC29F8AEA284137894120A4682941C976BE9F8AEA284100917E9BA468294100917E9B8AEA2841", LW_PARSER_CHECK_NONE));
313  ccw = ptarray_isccw(poly->rings[0]);
314  CU_ASSERT_EQUAL(ccw, 0);
315  lwpoly_free(poly);
316 }
int ptarray_isccw(const POINTARRAY *pa)
Definition: ptarray.c:990
void lwline_free(LWLINE *line)
Definition: lwline.c:63
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:125
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:1706
static LWGEOM * lwgeom_from_text(const char *str)
Definition: cu_ptarray.c:25
void lwpoly_free(LWPOLY *poly)
Definition: lwpoly.c:79
POINTARRAY ** rings
Definition: liblwgeom.h:413
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition: lwgeom.c:89
LWGEOM * lwgeom_from_hexwkb(const char *hexwkb, const char check)
Definition: lwin_wkb.c:753
POINTARRAY * points
Definition: liblwgeom.h:378

Here is the call graph for this function:

Here is the caller graph for this function: