PostGIS  2.2.8dev-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 441 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().

442 {
443  GEOGRAPHIC_POINT A, B, mL, nR;
444  double deltaLng, baseArea, topArea;
445  double bE, tE, ratio, sign;
446 
447  A = *a;
448  B = *b;
449 
450  mL.lat = latitude_min;
451  mL.lon = FP_MIN(A.lon, B.lon);
452  nR.lat = FP_MIN(A.lat, B.lat);
453  nR.lon = FP_MAX(A.lon, B.lon);
454  LWDEBUGF(4, "mL (%.12g %.12g)", mL.lat, mL.lon);
455  LWDEBUGF(4, "nR (%.12g %.12g)", nR.lat, nR.lon);
456  baseArea = spheroid_boundingbox_area(&mL, &nR, spheroid);
457  LWDEBUGF(4, "baseArea %.12g", baseArea);
458 
459  mL.lat = FP_MIN(A.lat, B.lat);
460  mL.lon = FP_MIN(A.lon, B.lon);
461  nR.lat = FP_MAX(A.lat, B.lat);
462  nR.lon = FP_MAX(A.lon, B.lon);
463  LWDEBUGF(4, "mL (%.12g %.12g)", mL.lat, mL.lon);
464  LWDEBUGF(4, "nR (%.12g %.12g)", nR.lat, nR.lon);
465  topArea = spheroid_boundingbox_area(&mL, &nR, spheroid);
466  LWDEBUGF(4, "topArea %.12g", topArea);
467 
468  deltaLng = B.lon - A.lon;
469  LWDEBUGF(4, "deltaLng %.12g", deltaLng);
470  bE = spheroid_parallel_arc_length(A.lat, deltaLng, spheroid);
471  tE = spheroid_parallel_arc_length(B.lat, deltaLng, spheroid);
472  LWDEBUGF(4, "bE %.12g", bE);
473  LWDEBUGF(4, "tE %.12g", tE);
474 
475  ratio = (bE + tE)/tE;
476  sign = SIGNUM(B.lon - A.lon);
477  return (baseArea + topArea / ratio) * sign;
478 }
static double spheroid_parallel_arc_length(double latitude, double deltaLongitude, const SPHEROID *spheroid)
Definition: lwspheroid.c:406
#define FP_MIN(A, B)
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:32
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:423
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
#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: