Opened 7 months ago

Closed 6 months ago

#5572 closed defect (worksforme)

ST_Difference drops z-dimension on empty result

Reported by: lkajan Owned by: pramsey
Priority: medium Milestone: PostGIS GEOS
Component: postgis Version: 3.4.x
Keywords: Cc: lkajan

Description

When calling ST_Difference with two 3D geometries the result may be a 2D geometry in case when geometries are equal and result is an EMPTY geometry.

Expected behavior:
As the documentation states: "This function supports 3d and will not drop the z-index."

To reproduce:

SELECT ST_AsText(ST_Difference('LINESTRINGZ(0 0 0,1 0 0)'::geometry, 'LINESTRINGZ(0 0 0,1 0 0)'::geometry));
    st_astext
------------------
 LINESTRING EMPTY
(1 row)

The result is a LINESTRING EMPTY and not a LINESTRINGZ EMPTY as one would expect.

PostGIS version:
POSTGIS="3.4.0 0874ea3" [EXTENSION] PGSQL="160" GEOS="3.9.0-CAPI-1.16.2" PROJ="7.2.1 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org USER_WRITABLE_DIRECTORY=/var/lib/postgresql/.local/share/proj DATABASE_PATH=/usr/share/proj/proj.db" LIBXML="2.9.10" LIBJSON="0.15" LIBPROTOBUF="1.3.3" WAGYU="0.5.0 (Internal)" TOPOLOGY

Change History (3)

comment:1 by robe, 6 months ago

Milestone: PostGIS 3.4.1PostGIS 3.3.6

comment:2 by pramsey, 6 months ago

Hum, this has been fixed at some point, either in PostGIS or GEOS (I'm guessing the latter).

# SELECT ST_AsText(ST_Difference('LINESTRINGZ(0 0 0,1 0 0)'::geometry, 'LINESTRINGZ(0 0 0,1 0 0)'::geometry));
     st_astext      
--------------------
 LINESTRING Z EMPTY

POSTGIS="3.5.0dev"
GEOS="3.13.0dev"

Last edited 6 months ago by pramsey (previous) (diff)

comment:3 by robe, 6 months ago

Milestone: PostGIS 3.3.6PostGIS GEOS
Resolution: worksforme
Status: newclosed

Works for me too on GEOS 3.12.2dev LINESTRING Z EMPTY

Going to close this out as GEOS.

Ikajan your GEOS is a very old micro. The latest release GEOS for 3.9 is 3.9.5 https://libgeos.org/usage/download/. If you can upgrade that that would be the best.

Note: See TracTickets for help on using tickets.