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

◆ lwgeom_nudge_geodetic()

int lwgeom_nudge_geodetic ( LWGEOM geom)
extern

Gently move coordinates of LWGEOM if they are close enough into geodetic range.

Gently move coordinates of LWGEOM if they are close enough into geodetic range.

This routine nudges those points, and only those points, back over to the bounds. http://trac.osgeo.org/postgis/ticket/1292

Definition at line 3404 of file lwgeodetic.c.

3405{
3406 int type;
3407 uint32_t i = 0;
3408 int rv = LW_FALSE;
3409
3410 assert(geom);
3411
3412 /* No points in nothing */
3413 if ( lwgeom_is_empty(geom) )
3414 return LW_FALSE;
3415
3416 type = geom->type;
3417
3418 if ( type == POINTTYPE )
3419 return ptarray_nudge_geodetic(((LWPOINT*)geom)->point);
3420
3421 if ( type == LINETYPE )
3422 return ptarray_nudge_geodetic(((LWLINE*)geom)->points);
3423
3424 if ( type == POLYGONTYPE )
3425 {
3426 LWPOLY *poly = (LWPOLY*)geom;
3427 for ( i = 0; i < poly->nrings; i++ )
3428 {
3429 int n = ptarray_nudge_geodetic(poly->rings[i]);
3430 rv = (rv == LW_TRUE ? rv : n);
3431 }
3432 return rv;
3433 }
3434
3435 if ( type == TRIANGLETYPE )
3436 return ptarray_nudge_geodetic(((LWTRIANGLE*)geom)->points);
3437
3438 if ( lwtype_is_collection( type ) )
3439 {
3440 LWCOLLECTION *col = (LWCOLLECTION*)geom;
3441
3442 for ( i = 0; i < col->ngeoms; i++ )
3443 {
3444 int n = lwgeom_nudge_geodetic(col->geoms[i]);
3445 rv = (rv == LW_TRUE ? rv : n);
3446 }
3447 return rv;
3448 }
3449
3450 lwerror("unsupported type (%s) passed to lwgeom_nudge_geodetic", lwtype_name(type));
3451 return rv;
3452}
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition lwutil.c:216
#define LW_FALSE
Definition liblwgeom.h:108
#define LINETYPE
Definition liblwgeom.h:117
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
Definition lwgeom.c:1087
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition liblwgeom.h:116
#define POLYGONTYPE
Definition liblwgeom.h:118
#define TRIANGLETYPE
Definition liblwgeom.h:129
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:107
int lwgeom_nudge_geodetic(LWGEOM *geom)
When features are snapped or sometimes they are just this way, they are very close to the geodetic bo...
static int ptarray_nudge_geodetic(POINTARRAY *pa)
When features are snapped or sometimes they are just this way, they are very close to the geodetic bo...
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition lwutil.c:190
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition lwinline.h:193
uint32_t ngeoms
Definition liblwgeom.h:566
LWGEOM ** geoms
Definition liblwgeom.h:561
uint8_t type
Definition liblwgeom.h:448
POINTARRAY ** rings
Definition liblwgeom.h:505
uint32_t nrings
Definition liblwgeom.h:510

References LWCOLLECTION::geoms, LINETYPE, LW_FALSE, LW_TRUE, lwerror(), lwgeom_is_empty(), lwgeom_nudge_geodetic(), lwtype_is_collection(), lwtype_name(), LWCOLLECTION::ngeoms, LWPOLY::nrings, POINTTYPE, POLYGONTYPE, ptarray_nudge_geodetic(), LWPOLY::rings, TRIANGLETYPE, and LWGEOM::type.

Referenced by geography_from_geometry(), gserialized_geography_from_lwgeom(), and lwgeom_nudge_geodetic().

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