PostGIS  2.3.7dev-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 3002 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().

3003 {
3004  int type;
3005  int i = 0;
3006  int rv = LW_FALSE;
3007 
3008  assert(geom);
3009 
3010  /* No points in nothing */
3011  if ( lwgeom_is_empty(geom) )
3012  return LW_FALSE;
3013 
3014  type = geom->type;
3015 
3016  if ( type == POINTTYPE )
3017  return ptarray_nudge_geodetic(((LWPOINT*)geom)->point);
3018 
3019  if ( type == LINETYPE )
3020  return ptarray_nudge_geodetic(((LWLINE*)geom)->points);
3021 
3022  if ( type == POLYGONTYPE )
3023  {
3024  LWPOLY *poly = (LWPOLY*)geom;
3025  for ( i = 0; i < poly->nrings; i++ )
3026  {
3027  int n = ptarray_nudge_geodetic(poly->rings[i]);
3028  rv = (rv == LW_TRUE ? rv : n);
3029  }
3030  return rv;
3031  }
3032 
3033  if ( type == TRIANGLETYPE )
3034  return ptarray_nudge_geodetic(((LWTRIANGLE*)geom)->points);
3035 
3036  if ( lwtype_is_collection( type ) )
3037  {
3038  LWCOLLECTION *col = (LWCOLLECTION*)geom;
3039 
3040  for ( i = 0; i < col->ngeoms; i++ )
3041  {
3042  int n = lwgeom_nudge_geodetic(col->geoms[i]);
3043  rv = (rv == LW_TRUE ? rv : n);
3044  }
3045  return rv;
3046  }
3047 
3048  lwerror("unsupported type (%s) passed to lwgeom_nudge_geodetic", lwtype_name(type));
3049  return rv;
3050 }
#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:2950
#define POLYGONTYPE
Definition: liblwgeom.h:86
#define TRIANGLETYPE
Definition: liblwgeom.h:97
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: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:1012
int nrings
Definition: liblwgeom.h:454
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:3002
#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:1310
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:102

Here is the call graph for this function:

Here is the caller graph for this function: