PostGIS  2.3.7dev-r@@SVN_REVISION@@
Datum ST_GeneratePoints ( PG_FUNCTION_ARGS  )

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

References gserialized_from_lwgeom(), lwgeom_free(), lwgeom_from_gserialized(), and lwgeom_to_points().

973 {
974  GSERIALIZED *gser_input;
975  GSERIALIZED *gser_result;
976  LWGEOM *lwgeom_input;
977  LWGEOM *lwgeom_result;
978  int32 npoints;
979 
980  gser_input = PG_GETARG_GSERIALIZED_P(0);
981  npoints = DatumGetInt32(DirectFunctionCall1(numeric_int4, PG_GETARG_DATUM(1)));
982 
983  /* Smartasses get nothing back */
984  if (npoints < 0)
985  PG_RETURN_NULL();
986 
987  /* Types get checked in the code, we'll keep things small out there */
988  lwgeom_input = lwgeom_from_gserialized(gser_input);
989  lwgeom_result = (LWGEOM*)lwgeom_to_points(lwgeom_input, npoints);
990  lwgeom_free(lwgeom_input);
991  PG_FREE_IF_COPY(gser_input, 0);
992 
993  /* Return null as null */
994  if (!lwgeom_result)
995  PG_RETURN_NULL();
996 
997  /* Serialize and return */
998  gser_result = gserialized_from_lwgeom(lwgeom_result, 0);
999  lwgeom_free(lwgeom_result);
1000  PG_RETURN_POINTER(gser_result);
1001 }
unsigned int int32
Definition: shpopen.c:273
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1063
LWMPOINT * lwgeom_to_points(const LWGEOM *lwgeom, int npoints)
GSERIALIZED * gserialized_from_lwgeom(LWGEOM *geom, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
Definition: g_serialized.c:933

Here is the call graph for this function: