PostGIS  2.2.8dev-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 1217 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().

1218 {
1219  double d;
1220  GEOGRAPHIC_POINT gcp1s, gcp1e, gcp2s, gcp2e, c1, c2;
1221  double d1s = edge_distance_to_point(e1, &(e2->start), &gcp1s);
1222  double d1e = edge_distance_to_point(e1, &(e2->end), &gcp1e);
1223  double d2s = edge_distance_to_point(e2, &(e1->start), &gcp2s);
1224  double d2e = edge_distance_to_point(e2, &(e1->end), &gcp2e);
1225 
1226  d = d1s;
1227  c1 = gcp1s;
1228  c2 = e2->start;
1229 
1230  if ( d1e < d )
1231  {
1232  d = d1e;
1233  c1 = gcp1e;
1234  c2 = e2->end;
1235  }
1236 
1237  if ( d2s < d )
1238  {
1239  d = d2s;
1240  c1 = e1->start;
1241  c2 = gcp2s;
1242  }
1243 
1244  if ( d2e < d )
1245  {
1246  d = d2e;
1247  c1 = e1->end;
1248  c2 = gcp2e;
1249  }
1250 
1251  if ( closest1 ) *closest1 = c1;
1252  if ( closest2 ) *closest2 = c2;
1253 
1254  return d;
1255 }
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:32
GEOGRAPHIC_POINT start
Definition: lwgeodetic.h:43
double edge_distance_to_point(const GEOGRAPHIC_EDGE *e, const GEOGRAPHIC_POINT *gp, GEOGRAPHIC_POINT *closest)
Definition: lwgeodetic.c:1166
GEOGRAPHIC_POINT end
Definition: lwgeodetic.h:44
Here is the call graph for this function:
Here is the caller graph for this function: