PostGIS  3.2.2dev-r@@SVN_REVISION@@

◆ ST_GeneratePoints()

Datum ST_GeneratePoints ( PG_FUNCTION_ARGS  )

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

1202 {
1203  GSERIALIZED *gser_input;
1204  GSERIALIZED *gser_result;
1205  LWGEOM *lwgeom_input;
1206  LWGEOM *lwgeom_result;
1207  int32 npoints;
1208  int32 seed = 0;
1209 
1210  gser_input = PG_GETARG_GSERIALIZED_P(0);
1211  npoints = PG_GETARG_INT32(1);
1212 
1213  if (npoints < 0)
1214  PG_RETURN_NULL();
1215 
1216  if (PG_NARGS() > 2 && ! PG_ARGISNULL(2))
1217  {
1218  seed = PG_GETARG_INT32(2);
1219  if (seed < 1)
1220  {
1221  lwpgerror("ST_GeneratePoints: seed must be greater than zero");
1222  PG_RETURN_NULL();
1223  }
1224  }
1225 
1226  /* Types get checked in the code, we'll keep things small out there */
1227  lwgeom_input = lwgeom_from_gserialized(gser_input);
1228  lwgeom_result = (LWGEOM*)lwgeom_to_points(lwgeom_input, npoints, seed);
1229  lwgeom_free(lwgeom_input);
1230  PG_FREE_IF_COPY(gser_input, 0);
1231 
1232  /* Return null as null */
1233  if (!lwgeom_result)
1234  PG_RETURN_NULL();
1235 
1236  /* Serialize and return */
1237  gser_result = geometry_serialize(lwgeom_result);
1238  lwgeom_free(lwgeom_result);
1239  PG_RETURN_POINTER(gser_result);
1240 }
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:1138
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: