PostGIS  2.2.7dev-r@@SVN_REVISION@@
double distance_sphere_method ( double  lat1,
double  long1,
double  lat2,
double  long2,
SPHEROID sphere 
)

Definition at line 439 of file lwgeom_spheroid.c.

References SPHEROID::a, distance(), and SPHEROID::e_sq.

Referenced by distance_ellipse().

440 {
441  double R,S,X,Y,deltaX,deltaY;
442 
443  double distance = 0.0;
444  double sin_lat = sin(lat1);
445  double sin2_lat = sin_lat * sin_lat;
446 
447  double Geocent_a = sphere->a;
448  double Geocent_e2 = sphere->e_sq;
449 
450  R = Geocent_a / (sqrt(1.0e0 - Geocent_e2 * sin2_lat));
451  /* 90 - lat1, but in radians */
452  S = R * sin(M_PI_2 - lat1) ;
453 
454  deltaX = long2 - long1; /* in rads */
455  deltaY = lat2 - lat1; /* in rads */
456 
457  /* think: a % of 2*pi*S */
458  X = deltaX/(2.0*M_PI) * 2 * M_PI * S;
459  Y = deltaY/(2.0*M_PI) * 2 * M_PI * R;
460 
461  distance = sqrt((X * X + Y * Y));
462 
463  return distance;
464 }
double e_sq
Definition: liblwgeom.h:301
Datum distance(PG_FUNCTION_ARGS)
double a
Definition: liblwgeom.h:297

Here is the call graph for this function:

Here is the caller graph for this function: