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

3252 {
3253 
3254  uint32_t i;
3255  POINT4D p;
3256  int altered = LW_FALSE;
3257  int rv = LW_FALSE;
3258  static double tolerance = 1e-10;
3259 
3260  if ( ! pa )
3261  lwerror("ptarray_nudge_geodetic called with null input");
3262 
3263  for(i = 0; i < pa->npoints; i++ )
3264  {
3265  getPoint4d_p(pa, i, &p);
3266  if ( p.x < -180.0 && (-180.0 - p.x < tolerance) )
3267  {
3268  p.x = -180.0;
3269  altered = LW_TRUE;
3270  }
3271  if ( p.x > 180.0 && (p.x - 180.0 < tolerance) )
3272  {
3273  p.x = 180.0;
3274  altered = LW_TRUE;
3275  }
3276  if ( p.y < -90.0 && (-90.0 - p.y < tolerance) )
3277  {
3278  p.y = -90.0;
3279  altered = LW_TRUE;
3280  }
3281  if ( p.y > 90.0 && (p.y - 90.0 < tolerance) )
3282  {
3283  p.y = 90.0;
3284  altered = LW_TRUE;
3285  }
3286  if ( altered == LW_TRUE )
3287  {
3288  ptarray_set_point4d(pa, i, &p);
3289  altered = LW_FALSE;
3290  rv = LW_TRUE;
3291  }
3292  }
3293  return rv;
3294 }
double x
Definition: liblwgeom.h:351
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
Definition: lwgeom_api.c:425
unsigned int uint32_t
Definition: uthash.h:78
#define LW_FALSE
Definition: liblwgeom.h:76
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition: lwgeom_api.c:113
double y
Definition: liblwgeom.h:351
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
uint32_t npoints
Definition: liblwgeom.h:370

Here is the call graph for this function:

Here is the caller graph for this function: