PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ ptarray_nudge_geodetic()

static int ptarray_nudge_geodetic ( POINTARRAY pa)
static

When features are snapped or sometimes they are just this way, they are very close to the geodetic bounds but slightly over.

This routine nudges those points, and only those points, back over to the bounds. http://trac.osgeo.org/postgis/ticket/1292

Definition at line 3352 of file lwgeodetic.c.

3353 {
3354 
3355  uint32_t i;
3356  POINT4D p;
3357  int altered = LW_FALSE;
3358  int rv = LW_FALSE;
3359  static double tolerance = 1e-10;
3360 
3361  if ( ! pa )
3362  lwerror("ptarray_nudge_geodetic called with null input");
3363 
3364  for(i = 0; i < pa->npoints; i++ )
3365  {
3366  getPoint4d_p(pa, i, &p);
3367  if ( p.x < -180.0 && (-180.0 - p.x < tolerance) )
3368  {
3369  p.x = -180.0;
3370  altered = LW_TRUE;
3371  }
3372  if ( p.x > 180.0 && (p.x - 180.0 < tolerance) )
3373  {
3374  p.x = 180.0;
3375  altered = LW_TRUE;
3376  }
3377  if ( p.y < -90.0 && (-90.0 - p.y < tolerance) )
3378  {
3379  p.y = -90.0;
3380  altered = LW_TRUE;
3381  }
3382  if ( p.y > 90.0 && (p.y - 90.0 < tolerance) )
3383  {
3384  p.y = 90.0;
3385  altered = LW_TRUE;
3386  }
3387  if ( altered == LW_TRUE )
3388  {
3389  ptarray_set_point4d(pa, i, &p);
3390  altered = LW_FALSE;
3391  rv = LW_TRUE;
3392  }
3393  }
3394  return rv;
3395 }
#define LW_FALSE
Definition: liblwgeom.h:77
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition: lwgeom_api.c:123
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
Definition: lwgeom_api.c:435
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
double x
Definition: liblwgeom.h:355
double y
Definition: liblwgeom.h:355
uint32_t npoints
Definition: liblwgeom.h:374
unsigned int uint32_t
Definition: uthash.h:78

References getPoint4d_p(), LW_FALSE, LW_TRUE, lwerror(), POINTARRAY::npoints, ptarray_set_point4d(), POINT4D::x, and POINT4D::y.

Referenced by lwgeom_nudge_geodetic().

Here is the call graph for this function:
Here is the caller graph for this function: