PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ ST_AsMVTGeom()

Datum ST_AsMVTGeom ( PG_FUNCTION_ARGS  )

Definition at line 42 of file lwgeom_out_mvt.c.

References buffer(), geometry_serialize(), lwgeom_free(), lwgeom_from_gserialized(), mvt_geom(), PG_FUNCTION_INFO_V1(), and pgis_asmvt_transfn().

43 {
44 #ifndef HAVE_LIBPROTOBUF
45  elog(ERROR, "Missing libprotobuf-c");
46  PG_RETURN_NULL();
47 #else
48  LWGEOM *lwgeom_in, *lwgeom_out;
49  GSERIALIZED *geom_in, *geom_out;
50  GBOX *bounds;
51  int extent, buffer;
52  bool clip_geom;
53  if (PG_ARGISNULL(0))
54  PG_RETURN_NULL();
55  geom_in = PG_GETARG_GSERIALIZED_P_COPY(0);
56  lwgeom_in = lwgeom_from_gserialized(geom_in);
57  if (PG_ARGISNULL(1))
58  elog(ERROR, "%s: parameter bounds cannot be null", __func__);
59  bounds = (GBOX *) PG_GETARG_POINTER(1);
60  extent = PG_ARGISNULL(2) ? 4096 : PG_GETARG_INT32(2);
61  buffer = PG_ARGISNULL(3) ? 256 : PG_GETARG_INT32(3);
62  clip_geom = PG_ARGISNULL(4) ? true : PG_GETARG_BOOL(4);
63  // NOTE: can both return in clone and in place modification so
64  // not known if lwgeom_in can be freed
65  lwgeom_out = mvt_geom(lwgeom_in, bounds, extent, buffer, clip_geom);
66  if (lwgeom_out == NULL)
67  PG_RETURN_NULL();
68  geom_out = geometry_serialize(lwgeom_out);
69  lwgeom_free(lwgeom_out);
70  PG_FREE_IF_COPY(geom_in, 0);
71  PG_RETURN_POINTER(geom_out);
72 #endif
73 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
Datum buffer(PG_FUNCTION_ARGS)
LWGEOM * mvt_geom(LWGEOM *lwgeom, const GBOX *gbox, uint32_t extent, uint32_t buffer, bool clip_geom)
Transform a geometry into vector tile coordinate space.
Definition: mvt.c:692
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
Here is the call graph for this function: