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

◆ test_ptarray_closest_segment_2d()

static void test_ptarray_closest_segment_2d ( )
static

Definition at line 688 of file cu_ptarray.c.

689{
690 LWLINE *line;
691 POINTARRAY *pa;
692 double dist;
693 POINT2D qp;
694 const char *wkt;
695 int rv;
696
697 wkt = "LINESTRING (0 0 0, 1 0 0, 2 0 0, 3 0 10)";
699 pa = line->points;
700
701 qp.x = qp.y = 0;
702 rv = ptarray_closest_segment_2d(pa, &qp, &dist);
703 ASSERT_INT_EQUAL(rv, 0);
704 ASSERT_DOUBLE_EQUAL(dist, 0);
705
706 qp.x = 1;
707 rv = ptarray_closest_segment_2d(pa, &qp, &dist);
708 ASSERT_INT_EQUAL(rv, 0);
709 ASSERT_DOUBLE_EQUAL(dist, 0);
710
711 qp.y = 1;
712 rv = ptarray_closest_segment_2d(pa, &qp, &dist);
713 ASSERT_INT_EQUAL(rv, 0);
714 ASSERT_DOUBLE_EQUAL(dist, 1);
715
716 qp.x = 5; qp.y = 0;
717 rv = ptarray_closest_segment_2d(pa, &qp, &dist);
718 ASSERT_INT_EQUAL(rv, 2);
719 ASSERT_DOUBLE_EQUAL(dist, 2);
720
721
722 lwline_free(line);
723
724 /* See https://trac.osgeo.org/postgis/ticket/4990 */
725 /* Test modified to give more stable results */
726 wkt = "LINESTRING(4 31,7 31,7 34,4 34,4 31)";
728 pa = line->points;
729 qp.x = 7.1; qp.y = 31.1;
730 rv = ptarray_closest_segment_2d(pa, &qp, &dist);
731 ASSERT_INT_EQUAL(rv, 1);
732 lwline_free(line);
733}
static LWGEOM * lwgeom_from_text(const char *str)
Definition cu_ptarray.c:24
#define ASSERT_DOUBLE_EQUAL(o, e)
#define ASSERT_INT_EQUAL(o, e)
int ptarray_closest_segment_2d(const POINTARRAY *pa, const POINT2D *qp, double *dist)
Definition ptarray.c:1452
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition lwgeom.c:207
void lwline_free(LWLINE *line)
Definition lwline.c:67
POINTARRAY * points
Definition liblwgeom.h:483
double y
Definition liblwgeom.h:390
double x
Definition liblwgeom.h:390

References ASSERT_DOUBLE_EQUAL, ASSERT_INT_EQUAL, lwgeom_as_lwline(), lwgeom_from_text(), lwline_free(), LWLINE::points, ptarray_closest_segment_2d(), POINT2D::x, and POINT2D::y.

Referenced by ptarray_suite_setup().

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