PostGIS  2.2.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 2939 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().

2940 {
2941 
2942  int i;
2943  POINT4D p;
2944  int altered = LW_FALSE;
2945  int rv = LW_FALSE;
2946  static double tolerance = 1e-10;
2947 
2948  if ( ! pa )
2949  lwerror("ptarray_nudge_geodetic called with null input");
2950 
2951  for(i = 0; i < pa->npoints; i++ )
2952  {
2953  getPoint4d_p(pa, i, &p);
2954  if ( p.x < -180.0 && (-180.0 - p.x < tolerance) )
2955  {
2956  p.x = -180.0;
2957  altered = LW_TRUE;
2958  }
2959  if ( p.x > 180.0 && (p.x - 180.0 < tolerance) )
2960  {
2961  p.x = 180.0;
2962  altered = LW_TRUE;
2963  }
2964  if ( p.y < -90.0 && (-90.0 - p.y < tolerance) )
2965  {
2966  p.y = -90.0;
2967  altered = LW_TRUE;
2968  }
2969  if ( p.y > 90.0 && (p.y - 90.0 < tolerance) )
2970  {
2971  p.y = 90.0;
2972  altered = LW_TRUE;
2973  }
2974  if ( altered == LW_TRUE )
2975  {
2976  ptarray_set_point4d(pa, i, &p);
2977  altered = LW_FALSE;
2978  rv = LW_TRUE;
2979  }
2980  }
2981  return rv;
2982 }
void ptarray_set_point4d(POINTARRAY *pa, int n, const POINT4D *p4d)
Definition: lwgeom_api.c:536
double x
Definition: liblwgeom.h:336
int npoints
Definition: liblwgeom.h:355
#define LW_FALSE
Definition: liblwgeom.h:62
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:61
double y
Definition: liblwgeom.h:336
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
Definition: lwgeom_api.c:231

Here is the call graph for this function:

Here is the caller graph for this function: