PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ distance_sphere_method()

double distance_sphere_method ( double  lat1,
double  long1,
double  lat2,
double  long2,
SPHEROID sphere 
)

Definition at line 451 of file lwgeom_spheroid.c.

452 {
453  double R,S,X,Y,deltaX,deltaY;
454 
455  double distance = 0.0;
456  double sin_lat = sin(lat1);
457  double sin2_lat = sin_lat * sin_lat;
458 
459  double Geocent_a = sphere->a;
460  double Geocent_e2 = sphere->e_sq;
461 
462  R = Geocent_a / (sqrt(1.0e0 - Geocent_e2 * sin2_lat));
463  /* 90 - lat1, but in radians */
464  S = R * sin(M_PI_2 - lat1) ;
465 
466  deltaX = long2 - long1; /* in rads */
467  deltaY = lat2 - lat1; /* in rads */
468 
469  /* think: a % of 2*pi*S */
470  X = deltaX/(2.0*M_PI) * 2 * M_PI * S;
471  Y = deltaY/(2.0*M_PI) * 2 * M_PI * R;
472 
473  distance = sqrt((X * X + Y * Y));
474 
475  return distance;
476 }
static double distance(double x1, double y1, double x2, double y2)
Definition: lwtree.c:1032
double e_sq
Definition: liblwgeom.h:365
double a
Definition: liblwgeom.h:361

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

Referenced by distance_ellipse().

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