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

Definition at line 755 of file cu_measures.c.

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

Referenced by measures_suite_setup().

756 {
757  /* int lw_dist2d_ptarray_ptarrayarc(const POINTARRAY *pa, const POINTARRAY *pb, DISTPTS *dl) */
758  DISTPTS dl;
759  int rv;
760  LWLINE *lwline1;
761  LWLINE *lwline2;
762 
763  /* Unit semi-circle above X axis */
764  lwline1 = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(-1 0, 0 1, 1 0)"));
765 
766  /* Line above top of semi-circle */
767  lwline2 = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(-2 2, -1 2, 1 2, 2 2)"));
769  rv = lw_dist2d_ptarray_ptarrayarc(lwline2->points, lwline1->points, &dl);
770  CU_ASSERT_DOUBLE_EQUAL(dl.distance, 1, 0.000001);
771 
772  /* Reversed arguments, should fail */
775  rv = lw_dist2d_ptarray_ptarrayarc(lwline1->points, lwline2->points, &dl);
776  //printf("%s\n", cu_error_msg);
777  CU_ASSERT_STRING_EQUAL("lw_dist2d_ptarray_ptarrayarc called with non-arc input", cu_error_msg);
778 
779  lwline_free(lwline2);
780 
781  /* Line along side of semi-circle */
782  lwline2 = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(-2 -3, -2 -2, -2 2, -2 3)"));
784  rv = lw_dist2d_ptarray_ptarrayarc(lwline2->points, lwline1->points, &dl);
785  CU_ASSERT_DOUBLE_EQUAL(dl.distance, 1, 0.000001);
786 
787  /* Four unit semi-circles surrounding the 2x2 box around origin */
788  lwline_free(lwline1);
789  lwline_free(lwline2);
790  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)"));
791  lwline2 = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(-2.5 -3, -2.5 -2, -2.5 2, -2.5 3)"));
792  rv = lw_dist2d_ptarray_ptarrayarc(lwline2->points, lwline1->points, &dl);
793  CU_ASSERT_DOUBLE_EQUAL(dl.distance, 0.5, 0.000001);
794 
795  lwline_free(lwline2);
796  lwline_free(lwline1);
797 }
#define DIST_MIN
void lwline_free(LWLINE *line)
Definition: lwline.c:63
static LWGEOM * lwgeom_from_text(const char *str)
Definition: cu_measures.c:23
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:1143
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition: lwgeom.c:89
double distance
Definition: measures.h:23
Structure used in distance-calculations.
Definition: measures.h:21
void lw_dist2d_distpts_init(DISTPTS *dl, int mode)
Definition: measures.c:27
char cu_error_msg[MAX_CUNIT_ERROR_LENGTH+1]
POINTARRAY * points
Definition: liblwgeom.h:378

Here is the call graph for this function:

Here is the caller graph for this function: