PostGIS  3.3.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 3192 of file lwgeodetic.c.

3193 {
3194 
3195  uint32_t i;
3196  POINT4D p;
3197  int altered = LW_FALSE;
3198  int rv = LW_FALSE;
3199  static double tolerance = 1e-10;
3200 
3201  if ( ! pa )
3202  lwerror("ptarray_nudge_geodetic called with null input");
3203 
3204  for(i = 0; i < pa->npoints; i++ )
3205  {
3206  getPoint4d_p(pa, i, &p);
3207  if ( p.x < -180.0 && (-180.0 - p.x <= tolerance) )
3208  {
3209  p.x = -180.0;
3210  altered = LW_TRUE;
3211  }
3212  if ( p.x > 180.0 && (p.x - 180.0 <= tolerance) )
3213  {
3214  p.x = 180.0;
3215  altered = LW_TRUE;
3216  }
3217  if ( p.y < -90.0 && (-90.0 - p.y <= tolerance) )
3218  {
3219  p.y = -90.0;
3220  altered = LW_TRUE;
3221  }
3222  if ( p.y > 90.0 && (p.y - 90.0 <= tolerance) )
3223  {
3224  p.y = 90.0;
3225  altered = LW_TRUE;
3226  }
3227  if ( altered == LW_TRUE )
3228  {
3229  ptarray_set_point4d(pa, i, &p);
3230  altered = LW_FALSE;
3231  rv = LW_TRUE;
3232  }
3233  }
3234  return rv;
3235 }
#define LW_FALSE
Definition: liblwgeom.h:109
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition: lwgeom_api.c:126
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:108
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
Definition: lwgeom_api.c:370
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
double x
Definition: liblwgeom.h:429
double y
Definition: liblwgeom.h:429
uint32_t npoints
Definition: liblwgeom.h:442

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

Referenced by lwgeom_nudge_geodetic().

Here is the call graph for this function:
Here is the caller graph for this function: