PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ test_lw_dist2d_ptarray_ptarrayarc()

static void test_lw_dist2d_ptarray_ptarrayarc ( void  )
static

Definition at line 1200 of file cu_measures.c.

1201 {
1202  /* int lw_dist2d_ptarray_ptarrayarc(const POINTARRAY *pa, const POINTARRAY *pb, DISTPTS *dl) */
1203  DISTPTS dl;
1204  int rv;
1205  LWLINE *lwline1;
1206  LWLINE *lwline2;
1207 
1208  /* Unit semi-circle above X axis */
1209  lwline1 = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(-1 0, 0 1, 1 0)"));
1210 
1211  /* Line above top of semi-circle */
1212  lwline2 = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(-2 2, -1 2, 1 2, 2 2)"));
1214  rv = lw_dist2d_ptarray_ptarrayarc(lwline2->points, lwline1->points, &dl);
1215  CU_ASSERT_EQUAL( rv, LW_SUCCESS );
1216  CU_ASSERT_DOUBLE_EQUAL(dl.distance, 1, 0.000001);
1217 
1218  /* Reversed arguments, should fail */
1221  rv = lw_dist2d_ptarray_ptarrayarc(lwline1->points, lwline2->points, &dl);
1222  //printf("%s\n", cu_error_msg);
1223  CU_ASSERT_EQUAL( rv, LW_FAILURE );
1225  cu_error_msg,
1226  "lw_dist2d_ptarray_ptarrayarc called with non-arc input");
1227 
1228  lwline_free(lwline2);
1229 
1230  /* Line along side of semi-circle */
1231  lwline2 = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(-2 -3, -2 -2, -2 2, -2 3)"));
1233  rv = lw_dist2d_ptarray_ptarrayarc(lwline2->points, lwline1->points, &dl);
1234  CU_ASSERT_EQUAL( rv, LW_SUCCESS );
1235  CU_ASSERT_DOUBLE_EQUAL(dl.distance, 1, 0.000001);
1236 
1237  /* Four unit semi-circles surrounding the 2x2 box around origin */
1238  lwline_free(lwline1);
1239  lwline_free(lwline2);
1240  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)"));
1241  lwline2 = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(-2.5 -3, -2.5 -2, -2.5 2, -2.5 3)"));
1242  rv = lw_dist2d_ptarray_ptarrayarc(lwline2->points, lwline1->points, &dl);
1243  CU_ASSERT_EQUAL( rv, LW_SUCCESS );
1244  CU_ASSERT_DOUBLE_EQUAL(dl.distance, 0.5, 0.000001);
1245 
1246  lwline_free(lwline2);
1247  lwline_free(lwline1);
1248 }
static LWGEOM * lwgeom_from_text(const char *str)
Definition: cu_measures.c:25
void cu_error_msg_reset()
char cu_error_msg[MAX_CUNIT_ERROR_LENGTH+1]
#define ASSERT_STRING_EQUAL(o, e)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition: lwgeom.c:161
#define LW_FAILURE
Definition: liblwgeom.h:110
#define LW_SUCCESS
Definition: liblwgeom.h:111
void lwline_free(LWLINE *line)
Definition: lwline.c:67
void lw_dist2d_distpts_init(DISTPTS *dl, int mode)
Definition: measures.c:64
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:1257
#define DIST_MIN
Definition: measures.h:44
double distance
Definition: measures.h:51
Structure used in distance-calculations.
Definition: measures.h:50
POINTARRAY * points
Definition: liblwgeom.h:469

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().

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