Re: SRID lost in ST_UNION

Erik Wienhold <[email protected]>
Newsgroups gmane.comp.gis.postgis
Message-ID <[email protected]>
On 2024-10-15 12:14 +0200, Łukasz Szałek via postgis-users wrote:
> 1)
> PostgreSQL 15.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
> POSTGIS="3.3.2 4975da8" [EXTENSION] PGSQL="150" GEOS="3.11.1-CAPI-1.17.1" PROJ="7.2.1" LIBXML="2.9.1" LIBJSON="0.11"
> 
> Query:
> select ST_SRID(ST_GeomFromText('POLYGON ((4.9882543 50.4415584, 4.9882543 50.4415586, 4.9882545 50.4415586, 4.9882545 50.4415584, 4.9882543 50.4415584))',4326)), st_srid(ST_UNION(ARRAY[ST_GeomFromText('POLYGON ((4.9882543 50.4415584, 4.9882543 50.4415586, 4.9882545 50.4415586, 4.9882545 50.4415584, 4.9882543 50.4415584))',4326)]));
> st_srid | st_srid
> ---------+---------
>     4326 |    4326
> (1 row)
> 
> 
> 2)
> PostgreSQL 17.0 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 11.4.1 20231218 (Red Hat 11.4.1-3), 64-bit
> POSTGIS="3.3.7 a0c7967" [EXTENSION] PGSQL="170" GEOS="3.13.0-CAPI-1.19.0" PROJ="9.5.0" LIBXML="2.9.13" LIBJSON="0.14" LIBPROTOBUF="1.3.3" WAGYU="0.5.0 (Internal)"
> 
> Query:
> select ST_SRID(ST_GeomFromText('POLYGON ((4.9882543 50.4415584, 4.9882543 50.4415586, 4.9882545 50.4415586, 4.9882545 50.4415584, 4.9882543 50.4415584))',4326)), st_srid(ST_UNION(ARRAY[ST_GeomFromText('POLYGON ((4.9882543 50.4415584, 4.9882543 50.4415586, 4.9882545 50.4415586, 4.9882545 50.4415584, 4.9882543 50.4415584))',4326)]));
> st_srid | st_srid
> ---------+---------
>     4326 |       0
> 
> Is there a regression between those versions?

Yes, I see the same regression in 3.4.3 as well.  This is caused by [1]
which sets SRID=0 [2] because the SRID has not been determined at this
point.

[1] https://trac.osgeo.org/postgis/ticket/5677
[2] https://trac.osgeo.org/postgis/browser/git/postgis/lwgeom_geos.c?rev=f37390b9cc4b33e8a7ec15e0396112fca19391c9#L659

-- 
Erik
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.