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

Definition at line 704 of file cu_geodetic.c.

References edge_distance_to_point(), edge_set(), GEOGRAPHIC_EDGE::end, GEOGRAPHIC_POINT::lat, GEOGRAPHIC_POINT::lon, point_set(), and GEOGRAPHIC_EDGE::start.

Referenced by geodetic_suite_setup().

705 {
706  GEOGRAPHIC_EDGE e;
708  GEOGRAPHIC_POINT closest;
709  double d;
710 
711  /* closest point at origin, one degree away */
712  edge_set(-50.0, 0.0, 50.0, 0.0, &e);
713  point_set(0.0, 1.0, &g);
714  d = edge_distance_to_point(&e, &g, 0);
715  CU_ASSERT_DOUBLE_EQUAL(d, M_PI / 180.0, 0.00001);
716 
717  /* closest point at origin, one degree away */
718  edge_set(-50.0, 0.0, 50.0, 0.0, &e);
719  point_set(0.0, 2.0, &g);
720  d = edge_distance_to_point(&e, &g, &closest);
721 #if 0
722  printf("LINESTRING(%.8g %.8g, %.8g %.8g)\n", e.start.lon, e.start.lat, e.end.lon, e.end.lat);
723  printf("POINT(%.9g %.9g)\n", g.lon, g.lat);
724  printf("\nDISTANCE == %.8g\n", d);
725 #endif
726  CU_ASSERT_DOUBLE_EQUAL(d, M_PI / 90.0, 0.00001);
727  CU_ASSERT_DOUBLE_EQUAL(closest.lat, 0.0, 0.00001);
728  CU_ASSERT_DOUBLE_EQUAL(closest.lon, 0.0, 0.00001);
729 
730  /* Ticket #2351 */
731  edge_set(149.386990599235, -26.3567415843982, 149.386990599247, -26.3567415843965, &e);
732  point_set(149.386990599235, -26.3567415843982, &g);
733  d = edge_distance_to_point(&e, &g, &closest);
734  CU_ASSERT_DOUBLE_EQUAL(d, 0.0, 0.00001);
735  // printf("CLOSE POINT(%g %g)\n", closest.lon, closest.lat);
736  // printf(" ORIG POINT(%g %g)\n", g.lon, g.lat);
737  CU_ASSERT_DOUBLE_EQUAL(g.lat, closest.lat, 0.00001);
738  CU_ASSERT_DOUBLE_EQUAL(g.lon, closest.lon, 0.00001);
739 }
Two-point great circle segment from a to b.
Definition: lwgeodetic.h:42
static void edge_set(double lon1, double lat1, double lon2, double lat2, GEOGRAPHIC_EDGE *e)
Definition: cu_geodetic.c:327
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:33
GEOGRAPHIC_POINT start
Definition: lwgeodetic.h:44
double edge_distance_to_point(const GEOGRAPHIC_EDGE *e, const GEOGRAPHIC_POINT *gp, GEOGRAPHIC_POINT *closest)
Definition: lwgeodetic.c:1165
GEOGRAPHIC_POINT end
Definition: lwgeodetic.h:45
static void point_set(double lon, double lat, GEOGRAPHIC_POINT *p)
Definition: cu_geodetic.c:336

Here is the call graph for this function:

Here is the caller graph for this function: