PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ test_edge_distance_to_point()

static void test_edge_distance_to_point ( void  )
static

Definition at line 724 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().

725 {
726  GEOGRAPHIC_EDGE e;
728  GEOGRAPHIC_POINT closest;
729  double d;
730 
731  /* closest point at origin, one degree away */
732  edge_set(-50.0, 0.0, 50.0, 0.0, &e);
733  point_set(0.0, 1.0, &g);
734  d = edge_distance_to_point(&e, &g, 0);
735  CU_ASSERT_DOUBLE_EQUAL(d, M_PI / 180.0, 0.00001);
736 
737  /* closest point at origin, one degree away */
738  edge_set(-50.0, 0.0, 50.0, 0.0, &e);
739  point_set(0.0, 2.0, &g);
740  d = edge_distance_to_point(&e, &g, &closest);
741 #if 0
742  printf("LINESTRING(%.8g %.8g, %.8g %.8g)\n", e.start.lon, e.start.lat, e.end.lon, e.end.lat);
743  printf("POINT(%.9g %.9g)\n", g.lon, g.lat);
744  printf("\nDISTANCE == %.8g\n", d);
745 #endif
746  CU_ASSERT_DOUBLE_EQUAL(d, M_PI / 90.0, 0.00001);
747  CU_ASSERT_DOUBLE_EQUAL(closest.lat, 0.0, 0.00001);
748  CU_ASSERT_DOUBLE_EQUAL(closest.lon, 0.0, 0.00001);
749 
750  /* Ticket #2351 */
751  edge_set(149.386990599235, -26.3567415843982, 149.386990599247, -26.3567415843965, &e);
752  point_set(149.386990599235, -26.3567415843982, &g);
753  d = edge_distance_to_point(&e, &g, &closest);
754  CU_ASSERT_DOUBLE_EQUAL(d, 0.0, 0.00001);
755  // printf("CLOSE POINT(%g %g)\n", closest.lon, closest.lat);
756  // printf(" ORIG POINT(%g %g)\n", g.lon, g.lat);
757  CU_ASSERT_DOUBLE_EQUAL(g.lat, closest.lat, 0.00001);
758  CU_ASSERT_DOUBLE_EQUAL(g.lon, closest.lon, 0.00001);
759 }
Two-point great circle segment from a to b.
Definition: lwgeodetic.h:56
static void edge_set(double lon1, double lat1, double lon2, double lat2, GEOGRAPHIC_EDGE *e)
Definition: cu_geodetic.c:347
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:47
GEOGRAPHIC_POINT start
Definition: lwgeodetic.h:58
double edge_distance_to_point(const GEOGRAPHIC_EDGE *e, const GEOGRAPHIC_POINT *gp, GEOGRAPHIC_POINT *closest)
Definition: lwgeodetic.c:1183
GEOGRAPHIC_POINT end
Definition: lwgeodetic.h:59
static void point_set(double lon, double lat, GEOGRAPHIC_POINT *p)
Definition: cu_geodetic.c:356
Here is the call graph for this function:
Here is the caller graph for this function: