PostGIS  3.2.2dev-r@@SVN_REVISION@@

◆ edge_distance_to_edge()

double edge_distance_to_edge ( const GEOGRAPHIC_EDGE e1,
const GEOGRAPHIC_EDGE e2,
GEOGRAPHIC_POINT closest1,
GEOGRAPHIC_POINT closest2 
)

Calculate the distance between two edges.

IMPORTANT: this test does not check for edge intersection!!! (distance == 0) You have to check for intersection before calling this function.

Definition at line 1271 of file lwgeodetic.c.

1272 {
1273  double d;
1274  GEOGRAPHIC_POINT gcp1s, gcp1e, gcp2s, gcp2e, c1, c2;
1275  double d1s = edge_distance_to_point(e1, &(e2->start), &gcp1s);
1276  double d1e = edge_distance_to_point(e1, &(e2->end), &gcp1e);
1277  double d2s = edge_distance_to_point(e2, &(e1->start), &gcp2s);
1278  double d2e = edge_distance_to_point(e2, &(e1->end), &gcp2e);
1279 
1280  d = d1s;
1281  c1 = gcp1s;
1282  c2 = e2->start;
1283 
1284  if ( d1e < d )
1285  {
1286  d = d1e;
1287  c1 = gcp1e;
1288  c2 = e2->end;
1289  }
1290 
1291  if ( d2s < d )
1292  {
1293  d = d2s;
1294  c1 = e1->start;
1295  c2 = gcp2s;
1296  }
1297 
1298  if ( d2e < d )
1299  {
1300  d = d2e;
1301  c1 = e1->end;
1302  c2 = gcp2e;
1303  }
1304 
1305  if ( closest1 ) *closest1 = c1;
1306  if ( closest2 ) *closest2 = c2;
1307 
1308  return d;
1309 }
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:64
GEOGRAPHIC_POINT end
Definition: lwgeodetic.h:65
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:54

References edge_distance_to_point(), GEOGRAPHIC_EDGE::end, and GEOGRAPHIC_EDGE::start.

Referenced by circ_tree_distance_tree_internal(), ptarray_distance_spheroid(), and test_edge_distance_to_edge().

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