e1.start = e1.end;
}
- return spheroid_distance(&g1, &nearest2, s);
+ /* On sphere, return answer */
+ if ( use_sphere )
+ return distance;
+ /* On spheroid, calculate final answer based on closest approach */
+ else
+ return spheroid_distance(&g1, &nearest2, s);
+
}
/* Initialize start of line 1 */
double min_dist = MAXFLOAT;
double max_dist = MAXFLOAT;
GEOGRAPHIC_POINT closest1, closest2;
- double distance2;
double threshold_radians = threshold / spheroid->radius;
circ_tree_distance_tree_internal(n1, n2, threshold_radians, &min_dist, &max_dist, &closest1, &closest2);
- distance2 = spheroid_distance(&closest1, &closest2, spheroid);
- return distance2;
+ /* Spherical case */
+ if ( spheroid->a == spheroid->b )
+ {
+ return spheroid->radius * sphere_distance(&closest1, &closest2);
+ }
+ else
+ {
+ return spheroid_distance(&closest1, &closest2, spheroid);
+ }
}
static double