PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ lwgeom_nudge_geodetic()

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

3245 {
3246  int type;
3247  uint32_t i = 0;
3248  int rv = LW_FALSE;
3249 
3250  assert(geom);
3251 
3252  /* No points in nothing */
3253  if ( lwgeom_is_empty(geom) )
3254  return LW_FALSE;
3255 
3256  type = geom->type;
3257 
3258  if ( type == POINTTYPE )
3259  return ptarray_nudge_geodetic(((LWPOINT*)geom)->point);
3260 
3261  if ( type == LINETYPE )
3262  return ptarray_nudge_geodetic(((LWLINE*)geom)->points);
3263 
3264  if ( type == POLYGONTYPE )
3265  {
3266  LWPOLY *poly = (LWPOLY*)geom;
3267  for ( i = 0; i < poly->nrings; i++ )
3268  {
3269  int n = ptarray_nudge_geodetic(poly->rings[i]);
3270  rv = (rv == LW_TRUE ? rv : n);
3271  }
3272  return rv;
3273  }
3274 
3275  if ( type == TRIANGLETYPE )
3276  return ptarray_nudge_geodetic(((LWTRIANGLE*)geom)->points);
3277 
3278  if ( lwtype_is_collection( type ) )
3279  {
3280  LWCOLLECTION *col = (LWCOLLECTION*)geom;
3281 
3282  for ( i = 0; i < col->ngeoms; i++ )
3283  {
3284  int n = lwgeom_nudge_geodetic(col->geoms[i]);
3285  rv = (rv == LW_TRUE ? rv : n);
3286  }
3287  return rv;
3288  }
3289 
3290  lwerror("unsupported type (%s) passed to lwgeom_nudge_geodetic", lwtype_name(type));
3291  return rv;
3292 }
#define LW_FALSE
Definition: liblwgeom.h:109
#define LINETYPE
Definition: liblwgeom.h:118
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
Definition: lwgeom.c:1105
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:117
#define POLYGONTYPE
Definition: liblwgeom.h:119
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:130
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:108
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:3244
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:3192
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:595
LWGEOM ** geoms
Definition: liblwgeom.h:590
uint8_t type
Definition: liblwgeom.h:477
POINTARRAY ** rings
Definition: liblwgeom.h:534
uint32_t nrings
Definition: liblwgeom.h:539

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: