PostGIS  3.2.2dev-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 3378 of file lwgeodetic.c.

3379 {
3380  int type;
3381  uint32_t i = 0;
3382  int rv = LW_FALSE;
3383 
3384  assert(geom);
3385 
3386  /* No points in nothing */
3387  if ( lwgeom_is_empty(geom) )
3388  return LW_FALSE;
3389 
3390  type = geom->type;
3391 
3392  if ( type == POINTTYPE )
3393  return ptarray_nudge_geodetic(((LWPOINT*)geom)->point);
3394 
3395  if ( type == LINETYPE )
3396  return ptarray_nudge_geodetic(((LWLINE*)geom)->points);
3397 
3398  if ( type == POLYGONTYPE )
3399  {
3400  LWPOLY *poly = (LWPOLY*)geom;
3401  for ( i = 0; i < poly->nrings; i++ )
3402  {
3403  int n = ptarray_nudge_geodetic(poly->rings[i]);
3404  rv = (rv == LW_TRUE ? rv : n);
3405  }
3406  return rv;
3407  }
3408 
3409  if ( type == TRIANGLETYPE )
3410  return ptarray_nudge_geodetic(((LWTRIANGLE*)geom)->points);
3411 
3412  if ( lwtype_is_collection( type ) )
3413  {
3414  LWCOLLECTION *col = (LWCOLLECTION*)geom;
3415 
3416  for ( i = 0; i < col->ngeoms; i++ )
3417  {
3418  int n = lwgeom_nudge_geodetic(col->geoms[i]);
3419  rv = (rv == LW_TRUE ? rv : n);
3420  }
3421  return rv;
3422  }
3423 
3424  lwerror("unsupported type (%s) passed to lwgeom_nudge_geodetic", lwtype_name(type));
3425  return rv;
3426 }
#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:3378
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:3326
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: