507 double delta_lon_tolerance;
520 lwerror(
"ptarray_area_spheroid: cannot handle ptarray that crosses equator");
523 if ( gbox2d.
ymax < 0.0 )
531 delta_lon_tolerance = (90.0 / (fabs(gbox2d.
ymin) / 8.0) - 2.0) / 10000.0;
536 delta_lon_tolerance = (90.0 / (fabs(gbox2d.
ymax) / 8.0) - 2.0) / 10000.0;
544 for ( i = 1; i < pa->
npoints; i++ )
547 double strip_area = 0.0;
548 double delta_lon = 0.0;
564 LWDEBUGF(4,
"in_south %d", in_south);
573 shift = (M_PI - a1.
lon) + 0.088;
575 shift = (M_PI - b1.
lon) + 0.088;
586 delta_lon = fabs(b1.
lon - a1.
lon);
589 LWDEBUGF(4,
"delta_lon %.18g", delta_lon);
590 LWDEBUGF(4,
"delta_lon_tolerance %.18g", delta_lon_tolerance);
592 if ( delta_lon > 0.0 )
594 if ( delta_lon < delta_lon_tolerance )
597 LWDEBUGF(4,
"strip_area %.12g", strip_area);
603 double step = floor(delta_lon / delta_lon_tolerance);
605 double pDistance = 0.0;
612 while (pDistance < (
distance - step * 1.01))
617 LWDEBUGF(4,
" azimuth %.12g", azimuth);
618 pDistance = pDistance + step;
619 LWDEBUGF(4,
" pDistance %.12g", pDistance);
622 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.
uint8_t gflags(int hasz, int hasm, int geodetic)
Construct a new flags char.
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
#define LW_TRUE
Return types for functions with status returns.
#define SIGNUM(n)
Macro that returns: -1 if n < 0, 1 if n > 0, 0 if n == 0.
void point_shift(GEOGRAPHIC_POINT *p, double shift)
Shift a point around by a number of radians.
void geographic_point_init(double lon, double lat, GEOGRAPHIC_POINT *g)
Initialize a geographic point.
int crosses_dateline(const GEOGRAPHIC_POINT *s, const GEOGRAPHIC_POINT *e)
#define deg2rad(d)
Conversion functions.
Datum distance(PG_FUNCTION_ARGS)
Datum area(PG_FUNCTION_ARGS)
#define LWDEBUGF(level, msg,...)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
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.
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.
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.
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.
Point in spherical coordinates on the world.