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

◆ ST_GeneratePoints()

Datum ST_GeneratePoints ( PG_FUNCTION_ARGS  )

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

1128{
1129 GSERIALIZED *gser_input;
1130 GSERIALIZED *gser_result;
1131 LWGEOM *lwgeom_input;
1132 LWGEOM *lwgeom_result;
1133 int32 npoints;
1134 int32 seed = 0;
1135
1136 gser_input = PG_GETARG_GSERIALIZED_P(0);
1137 npoints = PG_GETARG_INT32(1);
1138
1139 if (npoints < 0)
1140 PG_RETURN_NULL();
1141
1142 if (PG_NARGS() > 2 && ! PG_ARGISNULL(2))
1143 {
1144 seed = PG_GETARG_INT32(2);
1145 if (seed < 1)
1146 {
1147 lwpgerror("ST_GeneratePoints: seed must be greater than zero");
1148 PG_RETURN_NULL();
1149 }
1150 }
1151
1152 /* Types get checked in the code, we'll keep things small out there */
1153 lwgeom_input = lwgeom_from_gserialized(gser_input);
1154 lwgeom_result = (LWGEOM*)lwgeom_to_points(lwgeom_input, npoints, seed);
1155 lwgeom_free(lwgeom_input);
1156 PG_FREE_IF_COPY(gser_input, 0);
1157
1158 /* Return null as null */
1159 if (!lwgeom_result)
1160 PG_RETURN_NULL();
1161
1162 /* Serialize and return */
1163 gser_result = geometry_serialize(lwgeom_result);
1164 lwgeom_free(lwgeom_result);
1165 PG_RETURN_POINTER(gser_result);
1166}
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1138
LWMPOINT * lwgeom_to_points(const LWGEOM *lwgeom, uint32_t npoints, int32_t seed)
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
unsigned int int32
Definition shpopen.c:273

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

Here is the call graph for this function: