PostGIS  3.4.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 3403 of file lwgeodetic.c.

3404 {
3405  int type;
3406  uint32_t i = 0;
3407  int rv = LW_FALSE;
3408 
3409  assert(geom);
3410 
3411  /* No points in nothing */
3412  if ( lwgeom_is_empty(geom) )
3413  return LW_FALSE;
3414 
3415  type = geom->type;
3416 
3417  if ( type == POINTTYPE )
3418  return ptarray_nudge_geodetic(((LWPOINT*)geom)->point);
3419 
3420  if ( type == LINETYPE )
3421  return ptarray_nudge_geodetic(((LWLINE*)geom)->points);
3422 
3423  if ( type == POLYGONTYPE )
3424  {
3425  LWPOLY *poly = (LWPOLY*)geom;
3426  for ( i = 0; i < poly->nrings; i++ )
3427  {
3428  int n = ptarray_nudge_geodetic(poly->rings[i]);
3429  rv = (rv == LW_TRUE ? rv : n);
3430  }
3431  return rv;
3432  }
3433 
3434  if ( type == TRIANGLETYPE )
3435  return ptarray_nudge_geodetic(((LWTRIANGLE*)geom)->points);
3436 
3437  if ( lwtype_is_collection( type ) )
3438  {
3439  LWCOLLECTION *col = (LWCOLLECTION*)geom;
3440 
3441  for ( i = 0; i < col->ngeoms; i++ )
3442  {
3443  int n = lwgeom_nudge_geodetic(col->geoms[i]);
3444  rv = (rv == LW_TRUE ? rv : n);
3445  }
3446  return rv;
3447  }
3448 
3449  lwerror("unsupported type (%s) passed to lwgeom_nudge_geodetic", lwtype_name(type));
3450  return rv;
3451 }
#define LW_FALSE
Definition: liblwgeom.h:94
#define LINETYPE
Definition: liblwgeom.h:103
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:102
#define POLYGONTYPE
Definition: liblwgeom.h:104
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:115
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:93
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:3403
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:3351
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:580
LWGEOM ** geoms
Definition: liblwgeom.h:575
uint8_t type
Definition: liblwgeom.h:462
POINTARRAY ** rings
Definition: liblwgeom.h:519
uint32_t nrings
Definition: liblwgeom.h:524

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: