PostGIS  3.0.0dev-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 1238 of file lwgeodetic.c.

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

1239 {
1240  double d;
1241  GEOGRAPHIC_POINT gcp1s, gcp1e, gcp2s, gcp2e, c1, c2;
1242  double d1s = edge_distance_to_point(e1, &(e2->start), &gcp1s);
1243  double d1e = edge_distance_to_point(e1, &(e2->end), &gcp1e);
1244  double d2s = edge_distance_to_point(e2, &(e1->start), &gcp2s);
1245  double d2e = edge_distance_to_point(e2, &(e1->end), &gcp2e);
1246 
1247  d = d1s;
1248  c1 = gcp1s;
1249  c2 = e2->start;
1250 
1251  if ( d1e < d )
1252  {
1253  d = d1e;
1254  c1 = gcp1e;
1255  c2 = e2->end;
1256  }
1257 
1258  if ( d2s < d )
1259  {
1260  d = d2s;
1261  c1 = e1->start;
1262  c2 = gcp2s;
1263  }
1264 
1265  if ( d2e < d )
1266  {
1267  d = d2e;
1268  c1 = e1->end;
1269  c2 = gcp2e;
1270  }
1271 
1272  if ( closest1 ) *closest1 = c1;
1273  if ( closest2 ) *closest2 = c2;
1274 
1275  return d;
1276 }
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:1187
GEOGRAPHIC_POINT end
Definition: lwgeodetic.h:59
Here is the call graph for this function:
Here is the caller graph for this function: