PostGIS  2.1.10dev-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 2988 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().

2989 {
2990  int type;
2991  int i = 0;
2992  int rv = LW_FALSE;
2993 
2994  assert(geom);
2995 
2996  /* No points in nothing */
2997  if ( lwgeom_is_empty(geom) )
2998  return LW_FALSE;
2999 
3000  type = geom->type;
3001 
3002  if ( type == POINTTYPE )
3003  return ptarray_nudge_geodetic(((LWPOINT*)geom)->point);
3004 
3005  if ( type == LINETYPE )
3006  return ptarray_nudge_geodetic(((LWLINE*)geom)->points);
3007 
3008  if ( type == POLYGONTYPE )
3009  {
3010  LWPOLY *poly = (LWPOLY*)geom;
3011  for ( i = 0; i < poly->nrings; i++ )
3012  {
3013  int n = ptarray_nudge_geodetic(poly->rings[i]);
3014  rv = (rv == LW_TRUE ? rv : n);
3015  }
3016  return rv;
3017  }
3018 
3019  if ( type == TRIANGLETYPE )
3020  return ptarray_nudge_geodetic(((LWTRIANGLE*)geom)->points);
3021 
3022  if ( lwtype_is_collection( type ) )
3023  {
3024  LWCOLLECTION *col = (LWCOLLECTION*)geom;
3025 
3026  for ( i = 0; i < col->ngeoms; i++ )
3027  {
3028  int n = lwgeom_nudge_geodetic(col->geoms[i]);
3029  rv = (rv == LW_TRUE ? rv : n);
3030  }
3031  return rv;
3032  }
3033 
3034  lwerror("unsupported type (%s) passed to lwgeom_nudge_geodetic", lwtype_name(type));
3035  return rv;
3036 }
#define LINETYPE
Definition: liblwgeom.h:61
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:2936
#define POLYGONTYPE
Definition: liblwgeom.h:62
#define TRIANGLETYPE
Definition: liblwgeom.h:73
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:164
#define LW_FALSE
Definition: liblwgeom.h:52
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:51
LWGEOM ** geoms
Definition: liblwgeom.h:465
POINTARRAY ** rings
Definition: liblwgeom.h:413
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
Definition: lwgeom.c:955
int nrings
Definition: liblwgeom.h:411
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:2988
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:60
uint8_t type
Definition: liblwgeom.h:352
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:1229

Here is the call graph for this function:

Here is the caller graph for this function: