PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ spheroid_striparea()

static double spheroid_striparea ( const GEOGRAPHIC_POINT a,
const GEOGRAPHIC_POINT b,
double  latitude_min,
const SPHEROID spheroid 
)
static

This function doesn't work for edges crossing the dateline or in the southern hemisphere.

Points are pre-conditioned in ptarray_area_spheroid.

Definition at line 460 of file lwspheroid.c.

461 {
462  GEOGRAPHIC_POINT A, B, mL, nR;
463  double deltaLng, baseArea, topArea;
464  double bE, tE, ratio, sign;
465 
466  A = *a;
467  B = *b;
468 
469  mL.lat = latitude_min;
470  mL.lon = FP_MIN(A.lon, B.lon);
471  nR.lat = FP_MIN(A.lat, B.lat);
472  nR.lon = FP_MAX(A.lon, B.lon);
473  LWDEBUGF(4, "mL (%.12g %.12g)", mL.lat, mL.lon);
474  LWDEBUGF(4, "nR (%.12g %.12g)", nR.lat, nR.lon);
475  baseArea = spheroid_boundingbox_area(&mL, &nR, spheroid);
476  LWDEBUGF(4, "baseArea %.12g", baseArea);
477 
478  mL.lat = FP_MIN(A.lat, B.lat);
479  mL.lon = FP_MIN(A.lon, B.lon);
480  nR.lat = FP_MAX(A.lat, B.lat);
481  nR.lon = FP_MAX(A.lon, B.lon);
482  LWDEBUGF(4, "mL (%.12g %.12g)", mL.lat, mL.lon);
483  LWDEBUGF(4, "nR (%.12g %.12g)", nR.lat, nR.lon);
484  topArea = spheroid_boundingbox_area(&mL, &nR, spheroid);
485  LWDEBUGF(4, "topArea %.12g", topArea);
486 
487  deltaLng = B.lon - A.lon;
488  LWDEBUGF(4, "deltaLng %.12g", deltaLng);
489  bE = spheroid_parallel_arc_length(A.lat, deltaLng, spheroid);
490  tE = spheroid_parallel_arc_length(B.lat, deltaLng, spheroid);
491  LWDEBUGF(4, "bE %.12g", bE);
492  LWDEBUGF(4, "tE %.12g", tE);
493 
494  ratio = (bE + tE)/tE;
495  sign = SIGNUM(B.lon - A.lon);
496  return (baseArea + topArea / ratio) * sign;
497 }
#define SIGNUM(n)
Macro that returns: -1 if n < 0, 1 if n > 0, 0 if n == 0.
#define FP_MAX(A, B)
#define FP_MIN(A, B)
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
static double spheroid_parallel_arc_length(double latitude, double deltaLongitude, const SPHEROID *spheroid)
Definition: lwspheroid.c:425
static double spheroid_boundingbox_area(const GEOGRAPHIC_POINT *southWestCorner, const GEOGRAPHIC_POINT *northEastCorner, const SPHEROID *spheroid)
Computes the area on the spheroid of a box bounded by meridians and parallels.
Definition: lwspheroid.c:442
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:53

References FP_MAX, FP_MIN, GEOGRAPHIC_POINT::lat, GEOGRAPHIC_POINT::lon, LWDEBUGF, SIGNUM, spheroid_boundingbox_area(), and spheroid_parallel_arc_length().

Referenced by ptarray_area_spheroid().

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