PostGIS  2.4.9dev-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 3336 of file lwgeodetic.c.

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

Referenced by lwgeom_nudge_geodetic().

3337 {
3338 
3339  int i;
3340  POINT4D p;
3341  int altered = LW_FALSE;
3342  int rv = LW_FALSE;
3343  static double tolerance = 1e-10;
3344 
3345  if ( ! pa )
3346  lwerror("ptarray_nudge_geodetic called with null input");
3347 
3348  for(i = 0; i < pa->npoints; i++ )
3349  {
3350  getPoint4d_p(pa, i, &p);
3351  if ( p.x < -180.0 && (-180.0 - p.x < tolerance) )
3352  {
3353  p.x = -180.0;
3354  altered = LW_TRUE;
3355  }
3356  if ( p.x > 180.0 && (p.x - 180.0 < tolerance) )
3357  {
3358  p.x = 180.0;
3359  altered = LW_TRUE;
3360  }
3361  if ( p.y < -90.0 && (-90.0 - p.y < tolerance) )
3362  {
3363  p.y = -90.0;
3364  altered = LW_TRUE;
3365  }
3366  if ( p.y > 90.0 && (p.y - 90.0 < tolerance) )
3367  {
3368  p.y = 90.0;
3369  altered = LW_TRUE;
3370  }
3371  if ( altered == LW_TRUE )
3372  {
3373  ptarray_set_point4d(pa, i, &p);
3374  altered = LW_FALSE;
3375  rv = LW_TRUE;
3376  }
3377  }
3378  return rv;
3379 }
void ptarray_set_point4d(POINTARRAY *pa, int n, const POINT4D *p4d)
Definition: lwgeom_api.c:437
double x
Definition: liblwgeom.h:352
int npoints
Definition: liblwgeom.h:371
#define LW_FALSE
Definition: liblwgeom.h:77
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
double y
Definition: liblwgeom.h:352
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
Definition: lwgeom_api.c:122
Here is the call graph for this function:
Here is the caller graph for this function: