PostGIS  3.0.0dev-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 3316 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().

3317 {
3318  int type;
3319  uint32_t i = 0;
3320  int rv = LW_FALSE;
3321 
3322  assert(geom);
3323 
3324  /* No points in nothing */
3325  if ( lwgeom_is_empty(geom) )
3326  return LW_FALSE;
3327 
3328  type = geom->type;
3329 
3330  if ( type == POINTTYPE )
3331  return ptarray_nudge_geodetic(((LWPOINT*)geom)->point);
3332 
3333  if ( type == LINETYPE )
3334  return ptarray_nudge_geodetic(((LWLINE*)geom)->points);
3335 
3336  if ( type == POLYGONTYPE )
3337  {
3338  LWPOLY *poly = (LWPOLY*)geom;
3339  for ( i = 0; i < poly->nrings; i++ )
3340  {
3341  int n = ptarray_nudge_geodetic(poly->rings[i]);
3342  rv = (rv == LW_TRUE ? rv : n);
3343  }
3344  return rv;
3345  }
3346 
3347  if ( type == TRIANGLETYPE )
3348  return ptarray_nudge_geodetic(((LWTRIANGLE*)geom)->points);
3349 
3350  if ( lwtype_is_collection( type ) )
3351  {
3352  LWCOLLECTION *col = (LWCOLLECTION*)geom;
3353 
3354  for ( i = 0; i < col->ngeoms; i++ )
3355  {
3356  int n = lwgeom_nudge_geodetic(col->geoms[i]);
3357  rv = (rv == LW_TRUE ? rv : n);
3358  }
3359  return rv;
3360  }
3361 
3362  lwerror("unsupported type (%s) passed to lwgeom_nudge_geodetic", lwtype_name(type));
3363  return rv;
3364 }
#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:3264
#define POLYGONTYPE
Definition: liblwgeom.h:86
#define TRIANGLETYPE
Definition: liblwgeom.h:97
uint32_t ngeoms
Definition: liblwgeom.h:509
uint32_t nrings
Definition: liblwgeom.h:457
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:172
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: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:511
POINTARRAY ** rings
Definition: liblwgeom.h:459
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
Definition: lwgeom.c:1077
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:3316
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
uint8_t type
Definition: liblwgeom.h:398
type
Definition: ovdump.py:41
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: