PostGIS  2.2.8dev-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 2991 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, ovdump::type, and LWGEOM::type.

Referenced by geography_from_geometry(), and gserialized_geography_from_lwgeom().

2992 {
2993  int type;
2994  int i = 0;
2995  int rv = LW_FALSE;
2996 
2997  assert(geom);
2998 
2999  /* No points in nothing */
3000  if ( lwgeom_is_empty(geom) )
3001  return LW_FALSE;
3002 
3003  type = geom->type;
3004 
3005  if ( type == POINTTYPE )
3006  return ptarray_nudge_geodetic(((LWPOINT*)geom)->point);
3007 
3008  if ( type == LINETYPE )
3009  return ptarray_nudge_geodetic(((LWLINE*)geom)->points);
3010 
3011  if ( type == POLYGONTYPE )
3012  {
3013  LWPOLY *poly = (LWPOLY*)geom;
3014  for ( i = 0; i < poly->nrings; i++ )
3015  {
3016  int n = ptarray_nudge_geodetic(poly->rings[i]);
3017  rv = (rv == LW_TRUE ? rv : n);
3018  }
3019  return rv;
3020  }
3021 
3022  if ( type == TRIANGLETYPE )
3023  return ptarray_nudge_geodetic(((LWTRIANGLE*)geom)->points);
3024 
3025  if ( lwtype_is_collection( type ) )
3026  {
3027  LWCOLLECTION *col = (LWCOLLECTION*)geom;
3028 
3029  for ( i = 0; i < col->ngeoms; i++ )
3030  {
3031  int n = lwgeom_nudge_geodetic(col->geoms[i]);
3032  rv = (rv == LW_TRUE ? rv : n);
3033  }
3034  return rv;
3035  }
3036 
3037  lwerror("unsupported type (%s) passed to lwgeom_nudge_geodetic", lwtype_name(type));
3038  return rv;
3039 }
#define LINETYPE
Definition: liblwgeom.h:71
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:2939
#define POLYGONTYPE
Definition: liblwgeom.h:72
#define TRIANGLETYPE
Definition: liblwgeom.h:83
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:188
#define LW_FALSE
Definition: liblwgeom.h:62
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:61
LWGEOM ** geoms
Definition: liblwgeom.h:493
POINTARRAY ** rings
Definition: liblwgeom.h:441
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
Definition: lwgeom.c:999
int nrings
Definition: liblwgeom.h:439
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:2991
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
uint8_t type
Definition: liblwgeom.h:380
type
Definition: ovdump.py:41
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:1297
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
Here is the call graph for this function:
Here is the caller graph for this function: