PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ 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 3200 of file lwgeodetic.c.

3201{
3202
3203 uint32_t i;
3204 POINT4D p;
3205 int altered = LW_FALSE;
3206 int rv = LW_FALSE;
3207 static double tolerance = 1e-10;
3208
3209 if ( ! pa )
3210 lwerror("ptarray_nudge_geodetic called with null input");
3211
3212 for(i = 0; i < pa->npoints; i++ )
3213 {
3214 getPoint4d_p(pa, i, &p);
3215 if ( p.x < -180.0 && (-180.0 - p.x <= tolerance) )
3216 {
3217 p.x = -180.0;
3218 altered = LW_TRUE;
3219 }
3220 if ( p.x > 180.0 && (p.x - 180.0 <= tolerance) )
3221 {
3222 p.x = 180.0;
3223 altered = LW_TRUE;
3224 }
3225 if ( p.y < -90.0 && (-90.0 - p.y <= tolerance) )
3226 {
3227 p.y = -90.0;
3228 altered = LW_TRUE;
3229 }
3230 if ( p.y > 90.0 && (p.y - 90.0 <= tolerance) )
3231 {
3232 p.y = 90.0;
3233 altered = LW_TRUE;
3234 }
3235 if ( altered == LW_TRUE )
3236 {
3237 ptarray_set_point4d(pa, i, &p);
3238 altered = LW_FALSE;
3239 rv = LW_TRUE;
3240 }
3241 }
3242 return rv;
3243}
#define LW_FALSE
Definition liblwgeom.h:94
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition lwgeom_api.c:125
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:93
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
Definition lwgeom_api.c:369
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
double x
Definition liblwgeom.h:414
double y
Definition liblwgeom.h:414
uint32_t npoints
Definition liblwgeom.h:427

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: