PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ ST_GeneratePoints()

Datum ST_GeneratePoints ( PG_FUNCTION_ARGS  )

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

1292 {
1293  GSERIALIZED *gser_input;
1294  GSERIALIZED *gser_result;
1295  LWGEOM *lwgeom_input;
1296  LWGEOM *lwgeom_result;
1297  int32 npoints;
1298  int32 seed = 0;
1299 
1300  gser_input = PG_GETARG_GSERIALIZED_P(0);
1301  npoints = PG_GETARG_INT32(1);
1302 
1303  if (npoints < 0)
1304  PG_RETURN_NULL();
1305 
1306  if (PG_NARGS() > 2 && ! PG_ARGISNULL(2))
1307  {
1308  seed = PG_GETARG_INT32(2);
1309  if (seed < 1)
1310  {
1311  lwpgerror("ST_GeneratePoints: seed must be greater than zero");
1312  PG_RETURN_NULL();
1313  }
1314  }
1315 
1316  /* Types get checked in the code, we'll keep things small out there */
1317  lwgeom_input = lwgeom_from_gserialized(gser_input);
1318  lwgeom_result = (LWGEOM*)lwgeom_to_points(lwgeom_input, npoints, seed);
1319  lwgeom_free(lwgeom_input);
1320  PG_FREE_IF_COPY(gser_input, 0);
1321 
1322  /* Return null as null */
1323  if (!lwgeom_result)
1324  PG_RETURN_NULL();
1325 
1326  /* Serialize and return */
1327  gser_result = geometry_serialize(lwgeom_result);
1328  lwgeom_free(lwgeom_result);
1329  PG_RETURN_POINTER(gser_result);
1330 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1155
LWMPOINT * lwgeom_to_points(const LWGEOM *lwgeom, uint32_t npoints, int32_t seed)
unsigned int int32
Definition: shpopen.c:54

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

Here is the call graph for this function: