PostGIS  2.1.10dev-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 2936 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().

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

Here is the call graph for this function:

Here is the caller graph for this function: