PostGIS  3.1.6dev-r@@SVN_REVISION@@

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

3395 {
3396  int type;
3397  uint32_t i = 0;
3398  int rv = LW_FALSE;
3399 
3400  assert(geom);
3401 
3402  /* No points in nothing */
3403  if ( lwgeom_is_empty(geom) )
3404  return LW_FALSE;
3405 
3406  type = geom->type;
3407 
3408  if ( type == POINTTYPE )
3409  return ptarray_nudge_geodetic(((LWPOINT*)geom)->point);
3410 
3411  if ( type == LINETYPE )
3412  return ptarray_nudge_geodetic(((LWLINE*)geom)->points);
3413 
3414  if ( type == POLYGONTYPE )
3415  {
3416  LWPOLY *poly = (LWPOLY*)geom;
3417  for ( i = 0; i < poly->nrings; i++ )
3418  {
3419  int n = ptarray_nudge_geodetic(poly->rings[i]);
3420  rv = (rv == LW_TRUE ? rv : n);
3421  }
3422  return rv;
3423  }
3424 
3425  if ( type == TRIANGLETYPE )
3426  return ptarray_nudge_geodetic(((LWTRIANGLE*)geom)->points);
3427 
3428  if ( lwtype_is_collection( type ) )
3429  {
3430  LWCOLLECTION *col = (LWCOLLECTION*)geom;
3431 
3432  for ( i = 0; i < col->ngeoms; i++ )
3433  {
3434  int n = lwgeom_nudge_geodetic(col->geoms[i]);
3435  rv = (rv == LW_TRUE ? rv : n);
3436  }
3437  return rv;
3438  }
3439 
3440  lwerror("unsupported type (%s) passed to lwgeom_nudge_geodetic", lwtype_name(type));
3441  return rv;
3442 }
#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:1088
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:116
#define POLYGONTYPE
Definition: liblwgeom.h:118
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:216
#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...
Definition: lwgeodetic.c:3394
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...
Definition: lwgeodetic.c:3342
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:203
type
Definition: ovdump.py:42
uint32_t ngeoms
Definition: liblwgeom.h:594
LWGEOM ** geoms
Definition: liblwgeom.h:589
uint8_t type
Definition: liblwgeom.h:476
POINTARRAY ** rings
Definition: liblwgeom.h:533
uint32_t nrings
Definition: liblwgeom.h:538

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, LWGEOM::type, and ovdump::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: