PostGIS  2.3.7dev-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 2950 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().

2951 {
2952 
2953  int i;
2954  POINT4D p;
2955  int altered = LW_FALSE;
2956  int rv = LW_FALSE;
2957  static double tolerance = 1e-10;
2958 
2959  if ( ! pa )
2960  lwerror("ptarray_nudge_geodetic called with null input");
2961 
2962  for(i = 0; i < pa->npoints; i++ )
2963  {
2964  getPoint4d_p(pa, i, &p);
2965  if ( p.x < -180.0 && (-180.0 - p.x < tolerance) )
2966  {
2967  p.x = -180.0;
2968  altered = LW_TRUE;
2969  }
2970  if ( p.x > 180.0 && (p.x - 180.0 < tolerance) )
2971  {
2972  p.x = 180.0;
2973  altered = LW_TRUE;
2974  }
2975  if ( p.y < -90.0 && (-90.0 - p.y < tolerance) )
2976  {
2977  p.y = -90.0;
2978  altered = LW_TRUE;
2979  }
2980  if ( p.y > 90.0 && (p.y - 90.0 < tolerance) )
2981  {
2982  p.y = 90.0;
2983  altered = LW_TRUE;
2984  }
2985  if ( altered == LW_TRUE )
2986  {
2987  ptarray_set_point4d(pa, i, &p);
2988  altered = LW_FALSE;
2989  rv = LW_TRUE;
2990  }
2991  }
2992  return rv;
2993 }
void ptarray_set_point4d(POINTARRAY *pa, int n, const POINT4D *p4d)
Definition: lwgeom_api.c:549
double x
Definition: liblwgeom.h:351
int npoints
Definition: liblwgeom.h:370
#define LW_FALSE
Definition: liblwgeom.h:76
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
double y
Definition: liblwgeom.h:351
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:102
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
Definition: lwgeom_api.c:244

Here is the call graph for this function:

Here is the caller graph for this function: