PostGIS  2.5.0dev-r@@SVN_REVISION@@
static void test_lw_dist2d_ptarray_ptarrayarc ( void  )
static

Definition at line 938 of file cu_measures.c.

References ASSERT_STRING_EQUAL, cu_error_msg, cu_error_msg_reset(), DIST_MIN, DISTPTS::distance, lw_dist2d_distpts_init(), lw_dist2d_ptarray_ptarrayarc(), LW_FAILURE, LW_SUCCESS, lwgeom_as_lwline(), lwgeom_from_text(), lwline_free(), and LWLINE::points.

Referenced by measures_suite_setup().

939 {
940  /* int lw_dist2d_ptarray_ptarrayarc(const POINTARRAY *pa, const POINTARRAY *pb, DISTPTS *dl) */
941  DISTPTS dl;
942  int rv;
943  LWLINE *lwline1;
944  LWLINE *lwline2;
945 
946  /* Unit semi-circle above X axis */
947  lwline1 = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(-1 0, 0 1, 1 0)"));
948 
949  /* Line above top of semi-circle */
950  lwline2 = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(-2 2, -1 2, 1 2, 2 2)"));
952  rv = lw_dist2d_ptarray_ptarrayarc(lwline2->points, lwline1->points, &dl);
953  CU_ASSERT_EQUAL( rv, LW_SUCCESS );
954  CU_ASSERT_DOUBLE_EQUAL(dl.distance, 1, 0.000001);
955 
956  /* Reversed arguments, should fail */
959  rv = lw_dist2d_ptarray_ptarrayarc(lwline1->points, lwline2->points, &dl);
960  //printf("%s\n", cu_error_msg);
961  CU_ASSERT_EQUAL( rv, LW_FAILURE );
963  cu_error_msg,
964  "lw_dist2d_ptarray_ptarrayarc called with non-arc input");
965 
966  lwline_free(lwline2);
967 
968  /* Line along side of semi-circle */
969  lwline2 = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(-2 -3, -2 -2, -2 2, -2 3)"));
971  rv = lw_dist2d_ptarray_ptarrayarc(lwline2->points, lwline1->points, &dl);
972  CU_ASSERT_EQUAL( rv, LW_SUCCESS );
973  CU_ASSERT_DOUBLE_EQUAL(dl.distance, 1, 0.000001);
974 
975  /* Four unit semi-circles surrounding the 2x2 box around origin */
976  lwline_free(lwline1);
977  lwline_free(lwline2);
978  lwline1 = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(-1 -1, -2 0, -1 1, 0 2, 1 1, 2 0, 1 -1, 0 -2, -1 -1)"));
979  lwline2 = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(-2.5 -3, -2.5 -2, -2.5 2, -2.5 3)"));
980  rv = lw_dist2d_ptarray_ptarrayarc(lwline2->points, lwline1->points, &dl);
981  CU_ASSERT_EQUAL( rv, LW_SUCCESS );
982  CU_ASSERT_DOUBLE_EQUAL(dl.distance, 0.5, 0.000001);
983 
984  lwline_free(lwline2);
985  lwline_free(lwline1);
986 }
#define ASSERT_STRING_EQUAL(o, e)
#define LW_SUCCESS
Definition: liblwgeom.h:79
void lwline_free(LWLINE *line)
Definition: lwline.c:76
static LWGEOM * lwgeom_from_text(const char *str)
Definition: cu_measures.c:24
#define LW_FAILURE
Definition: liblwgeom.h:78
#define DIST_MIN
Definition: measures.h:41
void cu_error_msg_reset()
int lw_dist2d_ptarray_ptarrayarc(const POINTARRAY *pa, const POINTARRAY *pb, DISTPTS *dl)
Test each segment of pa against each arc of pb for distance.
Definition: measures.c:1183
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition: lwgeom.c:169
double distance
Definition: measures.h:48
Structure used in distance-calculations.
Definition: measures.h:46
void lw_dist2d_distpts_init(DISTPTS *dl, int mode)
Definition: measures.c:67
char cu_error_msg[MAX_CUNIT_ERROR_LENGTH+1]
POINTARRAY * points
Definition: liblwgeom.h:421

Here is the call graph for this function:

Here is the caller graph for this function: