PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_lwline_crossing_long_lines()

static void test_lwline_crossing_long_lines ( void  )
static

Definition at line 324 of file cu_algorithm.c.

References LINE_CROSS_LEFT, LINE_MULTICROSS_END_LEFT, LINE_MULTICROSS_END_SAME_FIRST_LEFT, LINE_NO_CROSS, LW_PARSER_CHECK_NONE, lwgeom_from_wkt(), lwline_crossing_direction(), and lwline_free().

Referenced by algorithms_suite_setup().

325 {
326  LWLINE *l51;
327  LWLINE *l52;
328  /*
329  ** More complex test, longer lines and multiple crossings
330  */
331  /* Vertical line with vertices at y integers */
332  l51 = (LWLINE*)lwgeom_from_wkt("LINESTRING(0 0, 0 1, 0 2, 0 3, 0 4)", LW_PARSER_CHECK_NONE);
333 
334  /* Two crossings at segment midpoints */
335  l52 = (LWLINE*)lwgeom_from_wkt("LINESTRING(1 1, -1 1.5, 1 3, 1 4, 1 5)", LW_PARSER_CHECK_NONE);
337  lwline_free(l52);
338 
339  /* One crossing at interior vertex */
340  l52 = (LWLINE*)lwgeom_from_wkt("LINESTRING(1 1, 0 1, -1 1, -1 2, -1 3)", LW_PARSER_CHECK_NONE);
341  CU_ASSERT( lwline_crossing_direction(l51, l52) == LINE_CROSS_LEFT );
342  lwline_free(l52);
343 
344  /* Two crossings at interior vertices */
345  l52 = (LWLINE*)lwgeom_from_wkt("LINESTRING(1 1, 0 1, -1 1, 0 3, 1 3)", LW_PARSER_CHECK_NONE);
347  lwline_free(l52);
348 
349  /* Two crossings, one at the first vertex on at interior vertex */
350  l52 = (LWLINE*)lwgeom_from_wkt("LINESTRING(1 0, 0 0, -1 1, 0 3, 1 3)", LW_PARSER_CHECK_NONE);
352  lwline_free(l52);
353 
354  /* Two crossings, one at the first vertex on the next interior vertex */
355  l52 = (LWLINE*)lwgeom_from_wkt("LINESTRING(1 0, 0 0, -1 1, 0 1, 1 2)", LW_PARSER_CHECK_NONE);
357  lwline_free(l52);
358 
359  /* Three crossings, two at midpoints, one at vertex */
360  l52 = (LWLINE*)lwgeom_from_wkt("LINESTRING(0.5 1, -1 0.5, 1 2, -1 2, -1 3)", LW_PARSER_CHECK_NONE);
361  CU_ASSERT( lwline_crossing_direction(l51, l52) == LINE_MULTICROSS_END_LEFT );
362  lwline_free(l52);
363 
364  /* One mid-point co-linear crossing */
365  l52 = (LWLINE*)lwgeom_from_wkt("LINESTRING(1 1, 0 1.5, 0 2.5, -1 3, -1 4)", LW_PARSER_CHECK_NONE);
366  CU_ASSERT( lwline_crossing_direction(l51, l52) == LINE_CROSS_LEFT );
367  lwline_free(l52);
368 
369  /* One on-vertices co-linear crossing */
370  l52 = (LWLINE*)lwgeom_from_wkt("LINESTRING(1 1, 0 1, 0 2, -1 4, -1 4)", LW_PARSER_CHECK_NONE);
371  CU_ASSERT( lwline_crossing_direction(l51, l52) == LINE_CROSS_LEFT );
372  lwline_free(l52);
373 
374  /* No crossing, but end on a co-linearity. */
375  l52 = (LWLINE*)lwgeom_from_wkt("LINESTRING(1 1, 1 2, 1 3, 0 3, 0 4)", LW_PARSER_CHECK_NONE);
376  CU_ASSERT( lwline_crossing_direction(l51, l52) == LINE_NO_CROSS );
377  lwline_free(l52);
378 
379  lwline_free(l51);
380 
381 }
int lwline_crossing_direction(const LWLINE *l1, const LWLINE *l2)
Given two lines, characterize how (and if) they cross each other.
Definition: lwalgorithm.c:460
void lwline_free(LWLINE *line)
Definition: lwline.c:76
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2013
Here is the call graph for this function:
Here is the caller graph for this function: