PostGIS  2.1.10dev-r@@SVN_REVISION@@
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 328 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().

329 {
330  GEOGRAPHIC_POINT A, B, mL, nR;
331  double deltaLng, baseArea, topArea;
332  double bE, tE, ratio, sign;
333 
334  A = *a;
335  B = *b;
336 
337  mL.lat = latitude_min;
338  mL.lon = FP_MIN(A.lon, B.lon);
339  nR.lat = FP_MIN(A.lat, B.lat);
340  nR.lon = FP_MAX(A.lon, B.lon);
341  LWDEBUGF(4, "mL (%.12g %.12g)", mL.lat, mL.lon);
342  LWDEBUGF(4, "nR (%.12g %.12g)", nR.lat, nR.lon);
343  baseArea = spheroid_boundingbox_area(&mL, &nR, spheroid);
344  LWDEBUGF(4, "baseArea %.12g", baseArea);
345 
346  mL.lat = FP_MIN(A.lat, B.lat);
347  mL.lon = FP_MIN(A.lon, B.lon);
348  nR.lat = FP_MAX(A.lat, B.lat);
349  nR.lon = FP_MAX(A.lon, B.lon);
350  LWDEBUGF(4, "mL (%.12g %.12g)", mL.lat, mL.lon);
351  LWDEBUGF(4, "nR (%.12g %.12g)", nR.lat, nR.lon);
352  topArea = spheroid_boundingbox_area(&mL, &nR, spheroid);
353  LWDEBUGF(4, "topArea %.12g", topArea);
354 
355  deltaLng = B.lon - A.lon;
356  LWDEBUGF(4, "deltaLng %.12g", deltaLng);
357  bE = spheroid_parallel_arc_length(A.lat, deltaLng, spheroid);
358  tE = spheroid_parallel_arc_length(B.lat, deltaLng, spheroid);
359  LWDEBUGF(4, "bE %.12g", bE);
360  LWDEBUGF(4, "tE %.12g", tE);
361 
362  ratio = (bE + tE)/tE;
363  sign = signum(B.lon - A.lon);
364  return (baseArea + topArea / ratio) * sign;
365 }
static double spheroid_parallel_arc_length(double latitude, double deltaLongitude, const SPHEROID *spheroid)
Definition: lwspheroid.c:293
#define signum(a)
Ape a java function.
Definition: lwgeodetic.h:66
#define FP_MIN(A, B)
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:33
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:310
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
#define FP_MAX(A, B)

Here is the call graph for this function:

Here is the caller graph for this function: