502 double delta_lon_tolerance;
515 lwerror(
"ptarray_area_spheroid: cannot handle ptarray that crosses equator");
518 if ( gbox2d.
ymax < 0.0 )
526 delta_lon_tolerance = (90.0 / (fabs(gbox2d.
ymin) / 8.0) - 2.0) / 10000.0;
531 delta_lon_tolerance = (90.0 / (fabs(gbox2d.
ymax) / 8.0) - 2.0) / 10000.0;
539 for ( i = 1; i < pa->
npoints; i++ )
542 double strip_area = 0.0;
543 double delta_lon = 0.0;
559 LWDEBUGF(4,
"in_south %d", in_south);
568 shift = (M_PI - a1.
lon) + 0.088;
570 shift = (M_PI - b1.
lon) + 0.088;
581 delta_lon = fabs(b1.
lon - a1.
lon);
584 LWDEBUGF(4,
"delta_lon %.18g", delta_lon);
585 LWDEBUGF(4,
"delta_lon_tolerance %.18g", delta_lon_tolerance);
587 if ( delta_lon > 0.0 )
589 if ( delta_lon < delta_lon_tolerance )
592 LWDEBUGF(4,
"strip_area %.12g", strip_area);
598 double step = floor(delta_lon / delta_lon_tolerance);
600 double pDistance = 0.0;
603 LWDEBUGF(4,
"distance %.18g", distance);
604 step = distance / step;
607 while (pDistance < (distance - step * 1.01))
612 LWDEBUGF(4,
" azimuth %.12g", azimuth);
613 pDistance = pDistance + step;
614 LWDEBUGF(4,
" pDistance %.12g", pDistance);
617 LWDEBUGF(4,
" strip_area %.12g", strip_area);
int ptarray_calculate_gbox_cartesian(const POINTARRAY *pa, GBOX *gbox)
Calculate box (x/y) and add values to gbox.
double spheroid_distance(const GEOGRAPHIC_POINT *a, const GEOGRAPHIC_POINT *b, const SPHEROID *spheroid)
Computes the shortest distance along the surface of the spheroid between two points.
int crosses_dateline(const GEOGRAPHIC_POINT *s, const GEOGRAPHIC_POINT *e)
int spheroid_project(const GEOGRAPHIC_POINT *r, const SPHEROID *spheroid, double distance, double azimuth, GEOGRAPHIC_POINT *g)
Given a location, an azimuth and a distance, computes the location of the projected point...
Datum area(PG_FUNCTION_ARGS)
static double spheroid_striparea(const GEOGRAPHIC_POINT *a, const GEOGRAPHIC_POINT *b, double latitude_min, const SPHEROID *spheroid)
This function doesn't work for edges crossing the dateline or in the southern hemisphere.
void point_shift(GEOGRAPHIC_POINT *p, double shift)
Shift a point around by a number of radians.
Point in spherical coordinates on the world.
#define LW_TRUE
Return types for functions with status returns.
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
double spheroid_direction(const GEOGRAPHIC_POINT *r, const GEOGRAPHIC_POINT *s, const SPHEROID *spheroid)
Computes the direction of the geodesic joining two points on the spheroid.
Datum distance(PG_FUNCTION_ARGS)
uint8_t gflags(int hasz, int hasm, int geodetic)
Construct a new flags char.
void geographic_point_init(double lon, double lat, GEOGRAPHIC_POINT *g)
Initialize a geographic point.
#define deg2rad(d)
Conversion functions.
#define LWDEBUGF(level, msg,...)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
#define SIGNUM(n)
Macro that returns: -1 if n < 0, 1 if n > 0, 0 if n == 0.