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

◆ lwgeom_nudge_geodetic()

int lwgeom_nudge_geodetic ( LWGEOM geom)

When features are snapped or sometimes they are just this way, they are very close to the geodetic bounds but slightly over.

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

3253{
3254 int type;
3255 uint32_t i = 0;
3256 int rv = LW_FALSE;
3257
3258 assert(geom);
3259
3260 /* No points in nothing */
3261 if ( lwgeom_is_empty(geom) )
3262 return LW_FALSE;
3263
3264 type = geom->type;
3265
3266 if ( type == POINTTYPE )
3267 return ptarray_nudge_geodetic(((LWPOINT*)geom)->point);
3268
3269 if ( type == LINETYPE )
3270 return ptarray_nudge_geodetic(((LWLINE*)geom)->points);
3271
3272 if ( type == POLYGONTYPE )
3273 {
3274 LWPOLY *poly = (LWPOLY*)geom;
3275 for ( i = 0; i < poly->nrings; i++ )
3276 {
3277 int n = ptarray_nudge_geodetic(poly->rings[i]);
3278 rv = (rv == LW_TRUE ? rv : n);
3279 }
3280 return rv;
3281 }
3282
3283 if ( type == TRIANGLETYPE )
3284 return ptarray_nudge_geodetic(((LWTRIANGLE*)geom)->points);
3285
3286 if ( lwtype_is_collection( type ) )
3287 {
3288 LWCOLLECTION *col = (LWCOLLECTION*)geom;
3289
3290 for ( i = 0; i < col->ngeoms; i++ )
3291 {
3292 int n = lwgeom_nudge_geodetic(col->geoms[i]);
3293 rv = (rv == LW_TRUE ? rv : n);
3294 }
3295 return rv;
3296 }
3297
3298 lwerror("unsupported type (%s) passed to lwgeom_nudge_geodetic", lwtype_name(type));
3299 return rv;
3300}
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:94
#define LINETYPE
Definition liblwgeom.h:103
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
Definition lwgeom.c:1196
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition liblwgeom.h:102
#define POLYGONTYPE
Definition liblwgeom.h:104
#define TRIANGLETYPE
Definition liblwgeom.h:115
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:93
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 void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
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:199
uint32_t ngeoms
Definition liblwgeom.h:580
LWGEOM ** geoms
Definition liblwgeom.h:575
uint8_t type
Definition liblwgeom.h:462
POINTARRAY ** rings
Definition liblwgeom.h:519
uint32_t nrings
Definition liblwgeom.h:524

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: