PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ test_edge_distance_to_point()

static void test_edge_distance_to_point ( void  )
static

Definition at line 730 of file cu_geodetic.c.

731 {
732  GEOGRAPHIC_EDGE e;
734  GEOGRAPHIC_POINT closest;
735  double d;
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, 1.0, &g);
740  d = edge_distance_to_point(&e, &g, 0);
741  CU_ASSERT_DOUBLE_EQUAL(d, M_PI / 180.0, 0.00001);
742 
743  /* closest point at origin, one degree away */
744  edge_set(-50.0, 0.0, 50.0, 0.0, &e);
745  point_set(0.0, 2.0, &g);
746  d = edge_distance_to_point(&e, &g, &closest);
747 #if 0
748  printf("LINESTRING(%.8g %.8g, %.8g %.8g)\n", e.start.lon, e.start.lat, e.end.lon, e.end.lat);
749  printf("POINT(%.9g %.9g)\n", g.lon, g.lat);
750  printf("\nDISTANCE == %.8g\n", d);
751 #endif
752  CU_ASSERT_DOUBLE_EQUAL(d, M_PI / 90.0, 0.00001);
753  CU_ASSERT_DOUBLE_EQUAL(closest.lat, 0.0, 0.00001);
754  CU_ASSERT_DOUBLE_EQUAL(closest.lon, 0.0, 0.00001);
755 
756  /* Ticket #2351 */
757  edge_set(149.386990599235, -26.3567415843982, 149.386990599247, -26.3567415843965, &e);
758  point_set(149.386990599235, -26.3567415843982, &g);
759  d = edge_distance_to_point(&e, &g, &closest);
760  CU_ASSERT_DOUBLE_EQUAL(d, 0.0, 0.00001);
761  // printf("CLOSE POINT(%g %g)\n", closest.lon, closest.lat);
762  // printf(" ORIG POINT(%g %g)\n", g.lon, g.lat);
763  CU_ASSERT_DOUBLE_EQUAL(g.lat, closest.lat, 0.00001);
764  CU_ASSERT_DOUBLE_EQUAL(g.lon, closest.lon, 0.00001);
765 }
static void point_set(double lon, double lat, GEOGRAPHIC_POINT *p)
Definition: cu_geodetic.c:356
static void edge_set(double lon1, double lat1, double lon2, double lat2, GEOGRAPHIC_EDGE *e)
Definition: cu_geodetic.c:347
double edge_distance_to_point(const GEOGRAPHIC_EDGE *e, const GEOGRAPHIC_POINT *gp, GEOGRAPHIC_POINT *closest)
Definition: lwgeodetic.c:1218
GEOGRAPHIC_POINT start
Definition: lwgeodetic.h:63
GEOGRAPHIC_POINT end
Definition: lwgeodetic.h:64
Two-point great circle segment from a to b.
Definition: lwgeodetic.h:62
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:53

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

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