PostGIS  2.4.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 3388 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().

3389 {
3390  int type;
3391  int i = 0;
3392  int rv = LW_FALSE;
3393 
3394  assert(geom);
3395 
3396  /* No points in nothing */
3397  if ( lwgeom_is_empty(geom) )
3398  return LW_FALSE;
3399 
3400  type = geom->type;
3401 
3402  if ( type == POINTTYPE )
3403  return ptarray_nudge_geodetic(((LWPOINT*)geom)->point);
3404 
3405  if ( type == LINETYPE )
3406  return ptarray_nudge_geodetic(((LWLINE*)geom)->points);
3407 
3408  if ( type == POLYGONTYPE )
3409  {
3410  LWPOLY *poly = (LWPOLY*)geom;
3411  for ( i = 0; i < poly->nrings; i++ )
3412  {
3413  int n = ptarray_nudge_geodetic(poly->rings[i]);
3414  rv = (rv == LW_TRUE ? rv : n);
3415  }
3416  return rv;
3417  }
3418 
3419  if ( type == TRIANGLETYPE )
3420  return ptarray_nudge_geodetic(((LWTRIANGLE*)geom)->points);
3421 
3422  if ( lwtype_is_collection( type ) )
3423  {
3424  LWCOLLECTION *col = (LWCOLLECTION*)geom;
3425 
3426  for ( i = 0; i < col->ngeoms; i++ )
3427  {
3428  int n = lwgeom_nudge_geodetic(col->geoms[i]);
3429  rv = (rv == LW_TRUE ? rv : n);
3430  }
3431  return rv;
3432  }
3433 
3434  lwerror("unsupported type (%s) passed to lwgeom_nudge_geodetic", lwtype_name(type));
3435  return rv;
3436 }
#define LINETYPE
Definition: liblwgeom.h:86
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:3336
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define TRIANGLETYPE
Definition: liblwgeom.h:98
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
#define LW_FALSE
Definition: liblwgeom.h:77
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
LWGEOM ** geoms
Definition: liblwgeom.h:509
POINTARRAY ** rings
Definition: liblwgeom.h:457
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
Definition: lwgeom.c:1048
int nrings
Definition: liblwgeom.h:455
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:3388
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
uint8_t type
Definition: liblwgeom.h:396
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:1346
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: