PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ ST_GeneratePoints()

Datum ST_GeneratePoints ( PG_FUNCTION_ARGS  )

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

1230{
1231 GSERIALIZED *gser_input;
1232 GSERIALIZED *gser_result;
1233 LWGEOM *lwgeom_input;
1234 LWGEOM *lwgeom_result;
1235 int32 npoints;
1236 int32 seed = 0;
1237
1238 gser_input = PG_GETARG_GSERIALIZED_P(0);
1239 npoints = PG_GETARG_INT32(1);
1240
1241 if (npoints < 0)
1242 PG_RETURN_NULL();
1243
1244 if (PG_NARGS() > 2 && ! PG_ARGISNULL(2))
1245 {
1246 seed = PG_GETARG_INT32(2);
1247 if (seed < 1)
1248 {
1249 lwpgerror("ST_GeneratePoints: seed must be greater than zero");
1250 PG_RETURN_NULL();
1251 }
1252 }
1253
1254 /* Types get checked in the code, we'll keep things small out there */
1255 lwgeom_input = lwgeom_from_gserialized(gser_input);
1256 lwgeom_result = (LWGEOM*)lwgeom_to_points(lwgeom_input, npoints, seed);
1257 lwgeom_free(lwgeom_input);
1258 PG_FREE_IF_COPY(gser_input, 0);
1259
1260 /* Return null as null */
1261 if (!lwgeom_result)
1262 PG_RETURN_NULL();
1263
1264 /* Serialize and return */
1265 gser_result = geometry_serialize(lwgeom_result);
1266 lwgeom_free(lwgeom_result);
1267 PG_RETURN_POINTER(gser_result);
1268}
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1246
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: