[postgis-devel] ST_Union, ST_Collect and ST_Difference strictness

Darafei "Komяpa" Praliaskouski me at komzpa.net
Mon Dec 18 08:12:50 PST 2017


Hi Paul,

Unfortunately in case of expression

(select ST_Union(geom) from table where <some_spatial_thing_that_is_false>)

there is no way to get EMPTY with correct SRID as output of ST_Union.
Currently it returns NULL.

When such expression is chained further with ST_Difference or ST_Union or
ST_Collect, it makes your second argument disappear too, which is not
intuitive behavior.

For our local needs we're already using non-strict wrappers:
https://github.com/gojuno/lostgis/blob/master/sql/functions/ST_Safe_Difference.sql
-
and I think that it would be beneficial for everybody, especially newbies
who can't yet grasp NULL, EMPTY and typed EMPTY zen :)


пн, 18 дек. 2017 г. в 18:54, Paul Ramsey <pramsey at cleverelephant.ca>:

> EMPTY are capable of carrying SRID around:
>
> select st_srid(st_setsrid('POINT EMPTY'::geometry, 23));
>
> The use case you describe is a textbook use of EMPTY, in fact why the
> whole gnarly (and deeply inconvenient) concept exists at all.
>
> P
>
>
> On Mon, Dec 18, 2017 at 7:51 AM, Darafei "Komяpa" Praliaskouski
> <me at komzpa.net> wrote:
> >>
> >> NULL is for "unknown", while what you're after is an EMPTY
> >> How about seeing if ST_Union(geom) can return an EMPTY when passed
> >> nothing ?
> >
> >
> > For EMPTY that is made from ST_Union of zero rows, you don't have a SRID.
> > You can in theory allow operations between an empty of different SRID,
> but
> > you cannot store it a column that has a SRID.
> >
> > I think both proposals are good in terms of user experience, but as long
> as
> > SRID is part of geometry body, but not header, your does not seem simple
> to
> > implement.
> >
> > _______________________________________________
> > postgis-devel mailing list
> > postgis-devel at lists.osgeo.org
> > https://lists.osgeo.org/mailman/listinfo/postgis-devel
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20171218/b44aecf6/attachment-0001.html>


More information about the postgis-devel mailing list