PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ distance_sphere_method()

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

Definition at line 452 of file lwgeom_spheroid.c.

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

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: