PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ _lwt_toposnap()

static LWGEOM* _lwt_toposnap ( LWGEOM src,
LWGEOM tgt,
double  tol 
)
static

Definition at line 420 of file lwgeom_topo.c.

421 {
422  LWGEOM *tmp = src;
423  LWGEOM *tmp2;
424  int changed;
425  int iterations = 0;
426 
427  int maxiterations = lwgeom_count_vertices(tgt);
428 
429  /* GEOS snapping can be unstable */
430  /* See https://trac.osgeo.org/geos/ticket/760 */
431  do {
432  tmp2 = lwgeom_snap(tmp, tgt, tol);
433  ++iterations;
434  changed = ( lwgeom_count_vertices(tmp2) != lwgeom_count_vertices(tmp) );
435  LWDEBUGF(2, "After iteration %d, geometry changed ? %d (%d vs %d vertices)", iterations, changed, lwgeom_count_vertices(tmp2), lwgeom_count_vertices(tmp));
436  if ( tmp != src ) lwgeom_free(tmp);
437  tmp = tmp2;
438  } while ( changed && iterations <= maxiterations );
439 
440  LWDEBUGF(1, "It took %d/%d iterations to properly snap",
441  iterations, maxiterations);
442 
443  return tmp;
444 }
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
LWGEOM * lwgeom_snap(const LWGEOM *geom1, const LWGEOM *geom2, double tolerance)
Snap vertices and segments of a geometry to another using a given tolerance.
uint32_t lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
Definition: lwgeom.c:1235
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88

References LWDEBUGF, lwgeom_count_vertices(), lwgeom_free(), and lwgeom_snap().

Referenced by _lwt_AddLine(), and _lwt_AddPoint().

Here is the call graph for this function:
Here is the caller graph for this function: