PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ lwgeom_snap()

LWGEOM* lwgeom_snap ( const LWGEOM geom1,
const LWGEOM geom2,
double  tolerance 

Snap vertices and segments of a geometry to another using a given tolerance.

geom1the geometry to snap
geom2the geometry to snap to
tolerancethe distance under which vertices and segments are snapped

Requires GEOS-3.3.0+

Definition at line 1271 of file liblwgeom/lwgeom_geos.c.

References LWGEOM::flags, FLAGS_GET_Z, geos_clean(), geos_clean_and_fail(), get_result_srid(), input_lwgeom_to_geos(), lwgeom_geos_error(), lwnotice(), output_geos_as_lwgeom(), and SRID_INVALID.

Referenced by _lwt_toposnap(), and ST_Snap().

1272 {
1273  LWGEOM* result;
1274  int32_t srid = get_result_srid(geom1, geom2, __func__);
1275  uint8_t is3d = (FLAGS_GET_Z(geom1->flags) || FLAGS_GET_Z(geom2->flags));
1276  GEOSGeometry *g1, *g2, *g3;
1278  if (srid == SRID_INVALID) return NULL;
1280  initGEOS(lwnotice, lwgeom_geos_error);
1282  if (!input_lwgeom_to_geos(&g1, geom1, __func__)) return NULL;
1283  if (!input_lwgeom_to_geos(&g2, geom2, __func__)) return geos_clean_and_fail(g1, NULL, NULL, __func__);
1285  g3 = GEOSSnap(g1, g2, tolerance);
1287  if (!g3) return geos_clean_and_fail(g1, g2, NULL, __func__);
1289  if (!output_geos_as_lwgeom(&g3, &result, srid, is3d, __func__))
1290  return geos_clean_and_fail(g1, g2, g3, __func__);
1292  geos_clean(g1, g2, g3);
1293  return result;
1294 }
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:177
uint8_t flags
Definition: liblwgeom.h:399
static LWGEOM * geos_clean_and_fail(GEOSGeometry *g1, GEOSGeometry *g2, GEOSGeometry *g3, const char *funcname)
static uint8_t output_geos_as_lwgeom(GEOSGeometry **g, LWGEOM **geom, const int32_t srid, const uint8_t is3d, const char *funcname)
void lwgeom_geos_error(const char *fmt,...)
static void geos_clean(GEOSGeometry *g1, GEOSGeometry *g2, GEOSGeometry *g3)
Definition: liblwgeom.h:191
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:139
static uint8_t input_lwgeom_to_geos(GEOSGeometry **g, const LWGEOM *geom, const char *funcname)
static int32_t get_result_srid(const LWGEOM *geom1, const LWGEOM *geom2, const char *funcname)
unsigned char uint8_t
Definition: uthash.h:79
Here is the call graph for this function:
Here is the caller graph for this function: