[postgis-devel] ST_GeneratePoints randomness

Darafei "Komяpa" Praliaskouski me at komzpa.net
Fri Jan 18 05:51:23 PST 2019


Hi Felix,

would you prefer the function to always return the same set of random
points, or get the fact that it can return different set of points on
invocations in different transactions documented?

I'm not sure treating it same as random() is a great idea, I use it more
like "give me a point cloud that fills this polygon" converting it for
usage in point-accepting functions, like calculating the median of the
polygon. I'd prefer it cached like it is now for such cases.

What are you using your random geodata for?

On Wed, Jan 16, 2019 at 1:11 AM Felix Kunde <felix-kunde at gmx.de> wrote:

> Hi list,
>
> I thought that this topic better belongs on this list.
> I'm trying to create some random spatial data using the ST_GeneratePoints
> functions. I wanted to reuse it also for lines and polygons but stumbled
> over the issue that multiple calls of the function in one transaction
> produce the same result. I tested different query constructs - even looping
> over a PL/pgSQL function - but no luck. So whereas:
>
> SELECT
>   random() AS random_a,
>   random() AS random_b;
>
> creates different results, this:
>
> SELECT
>   ST_AsText(ST_GeneratePoints('POLYGON((0 0,1 0,1 1,0 1,0 0))'::geometry,
> 2)) AS random_a,
>   ST_AsText(ST_GeneratePoints('POLYGON((0 0,1 0,1 1,0 1,0 0))'::geometry,
> 2)) AS random_b;
>
> will produce the same. There are workaround to generate random geodata, of
> course.
> Just wanted to point it out here and see, if you are aware of this. I
> couldn't found any ticket regarding this behaviour.
>
> Best, Felix
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-devel



-- 
Darafei Praliaskouski
Support me: http://patreon.com/komzpa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20190118/4f5a9378/attachment.html>


More information about the postgis-devel mailing list