PostGIS  2.5.0dev-r@@SVN_REVISION@@
int lwgeom_nudge_geodetic ( LWGEOM geom)

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

References LWCOLLECTION::geoms, LINETYPE, LW_FALSE, LW_TRUE, lwerror(), lwgeom_is_empty(), 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(), and gserialized_geography_from_lwgeom().

3304 {
3305  int type;
3306  uint32_t i = 0;
3307  int rv = LW_FALSE;
3308 
3309  assert(geom);
3310 
3311  /* No points in nothing */
3312  if ( lwgeom_is_empty(geom) )
3313  return LW_FALSE;
3314 
3315  type = geom->type;
3316 
3317  if ( type == POINTTYPE )
3318  return ptarray_nudge_geodetic(((LWPOINT*)geom)->point);
3319 
3320  if ( type == LINETYPE )
3321  return ptarray_nudge_geodetic(((LWLINE*)geom)->points);
3322 
3323  if ( type == POLYGONTYPE )
3324  {
3325  LWPOLY *poly = (LWPOLY*)geom;
3326  for ( i = 0; i < poly->nrings; i++ )
3327  {
3328  int n = ptarray_nudge_geodetic(poly->rings[i]);
3329  rv = (rv == LW_TRUE ? rv : n);
3330  }
3331  return rv;
3332  }
3333 
3334  if ( type == TRIANGLETYPE )
3335  return ptarray_nudge_geodetic(((LWTRIANGLE*)geom)->points);
3336 
3337  if ( lwtype_is_collection( type ) )
3338  {
3339  LWCOLLECTION *col = (LWCOLLECTION*)geom;
3340 
3341  for ( i = 0; i < col->ngeoms; i++ )
3342  {
3343  int n = lwgeom_nudge_geodetic(col->geoms[i]);
3344  rv = (rv == LW_TRUE ? rv : n);
3345  }
3346  return rv;
3347  }
3348 
3349  lwerror("unsupported type (%s) passed to lwgeom_nudge_geodetic", lwtype_name(type));
3350  return rv;
3351 }
#define LINETYPE
Definition: liblwgeom.h:85
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:3251
#define POLYGONTYPE
Definition: liblwgeom.h:86
#define TRIANGLETYPE
Definition: liblwgeom.h:97
uint32_t ngeoms
Definition: liblwgeom.h:506
uint32_t nrings
Definition: liblwgeom.h:454
unsigned int uint32_t
Definition: uthash.h:78
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
#define LW_FALSE
Definition: liblwgeom.h:76
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
LWGEOM ** geoms
Definition: liblwgeom.h:508
POINTARRAY ** rings
Definition: liblwgeom.h:456
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
Definition: lwgeom.c:1086
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:3303
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
uint8_t type
Definition: liblwgeom.h:395
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1386
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190

Here is the call graph for this function:

Here is the caller graph for this function: