PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum ST_Snap ( PG_FUNCTION_ARGS  )

Definition at line 3462 of file postgis/lwgeom_geos.c.

References geometry_serialize(), lwerror(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_snap(), POSTGIS_GEOS_VERSION, and result.

3463 {
3464 #if POSTGIS_GEOS_VERSION < 33
3465  lwerror("The GEOS version this PostGIS binary "
3466  "was compiled against (%d) doesn't support "
3467  "'ST_Snap' function (3.3.0+ required)",
3469  PG_RETURN_NULL();
3470 #else /* POSTGIS_GEOS_VERSION >= 33 */
3471  GSERIALIZED *geom1, *geom2, *result;
3472  LWGEOM *lwgeom1, *lwgeom2, *lwresult;
3473  double tolerance;
3474 
3475  geom1 = (GSERIALIZED *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
3476  geom2 = (GSERIALIZED *) PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
3477  tolerance = PG_GETARG_FLOAT8(2);
3478 
3479  lwgeom1 = lwgeom_from_gserialized(geom1);
3480  lwgeom2 = lwgeom_from_gserialized(geom2);
3481 
3482  lwresult = lwgeom_snap(lwgeom1, lwgeom2, tolerance);
3483  lwgeom_free(lwgeom1);
3484  lwgeom_free(lwgeom2);
3485  PG_FREE_IF_COPY(geom1, 0);
3486  PG_FREE_IF_COPY(geom2, 1);
3487 
3488  result = geometry_serialize(lwresult);
3489  lwgeom_free(lwresult);
3490 
3491  PG_RETURN_POINTER(result);
3492 
3493 #endif /* POSTGIS_GEOS_VERSION >= 33 */
3494 
3495 }
#define POSTGIS_GEOS_VERSION
Definition: sqldefines.h:10
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
char ** result
Definition: liblwgeom.h:218
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
LWGEOM * lwgeom_snap(const LWGEOM *geom1, const LWGEOM *geom2, double tolerance)
Snap vertices and segments of a geometry to another using a given tolerance.
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)

Here is the call graph for this function: