PostGIS  2.4.9dev-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 455 of file lwspheroid.c.

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().

456 {
457  GEOGRAPHIC_POINT A, B, mL, nR;
458  double deltaLng, baseArea, topArea;
459  double bE, tE, ratio, sign;
460 
461  A = *a;
462  B = *b;
463 
464  mL.lat = latitude_min;
465  mL.lon = FP_MIN(A.lon, B.lon);
466  nR.lat = FP_MIN(A.lat, B.lat);
467  nR.lon = FP_MAX(A.lon, B.lon);
468  LWDEBUGF(4, "mL (%.12g %.12g)", mL.lat, mL.lon);
469  LWDEBUGF(4, "nR (%.12g %.12g)", nR.lat, nR.lon);
470  baseArea = spheroid_boundingbox_area(&mL, &nR, spheroid);
471  LWDEBUGF(4, "baseArea %.12g", baseArea);
472 
473  mL.lat = FP_MIN(A.lat, B.lat);
474  mL.lon = FP_MIN(A.lon, B.lon);
475  nR.lat = FP_MAX(A.lat, B.lat);
476  nR.lon = FP_MAX(A.lon, B.lon);
477  LWDEBUGF(4, "mL (%.12g %.12g)", mL.lat, mL.lon);
478  LWDEBUGF(4, "nR (%.12g %.12g)", nR.lat, nR.lon);
479  topArea = spheroid_boundingbox_area(&mL, &nR, spheroid);
480  LWDEBUGF(4, "topArea %.12g", topArea);
481 
482  deltaLng = B.lon - A.lon;
483  LWDEBUGF(4, "deltaLng %.12g", deltaLng);
484  bE = spheroid_parallel_arc_length(A.lat, deltaLng, spheroid);
485  tE = spheroid_parallel_arc_length(B.lat, deltaLng, spheroid);
486  LWDEBUGF(4, "bE %.12g", bE);
487  LWDEBUGF(4, "tE %.12g", tE);
488 
489  ratio = (bE + tE)/tE;
490  sign = SIGNUM(B.lon - A.lon);
491  return (baseArea + topArea / ratio) * sign;
492 }
static double spheroid_parallel_arc_length(double latitude, double deltaLongitude, const SPHEROID *spheroid)
Definition: lwspheroid.c:420
#define FP_MIN(A, B)
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:52
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:437
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
#define SIGNUM(n)
Macro that returns: -1 if n < 0, 1 if n > 0, 0 if n == 0.
#define FP_MAX(A, B)
Here is the call graph for this function:
Here is the caller graph for this function: