Opened 8 months ago

Closed 6 weeks ago

#5089 closed defect (fixed)

ST_Reverse does not handle CURVEPOLYGON/COMPOUNDCURVE correctly

Reported by: bhoefling Owned by: strk
Priority: medium Milestone: PostGIS 3.3.0
Component: liblwgeom Version: 3.2.x
Keywords: Cc: bhoefling


ST_Reverse works for CIRCULARSTRING, and for simple CURVEPOLYGON.

But if the CURVEPOLYGON contains a COMPOUNDCURVE with more than one component, the reverse order is wrong.

Testcase is from here:

Actual Result:

SELECT 'cplg2', ST_AsText(ST_Reverse('CURVEPOLYGON (COMPOUNDCURVE (CIRCULARSTRING (0 0,1 1,1 0),(1 0,0 1),(0 1,0 0)))'::geometry));

?column? | st_astext

cplg2 | CURVEPOLYGON(COMPOUNDCURVE(CIRCULARSTRING(1 0,1 1,0 0),(0 1,1 0),(0 0,0 1)))

(1 row)

Note that each sub-component is reversed. But it is necessary to additionally reverse the order of the components as such. Otherwise, the end/start nodes don't match any more.


CURVEPOLYGON(COMPOUNDCURVE((0 0,0 1), (0 1,1 0), CIRCULARSTRING(1 0,1 1,0 0)))

Implementation details: lwgeom.c, lwgeom_reverse_in_place(LWGEOM *geom)

This CASE needs to be differentiated more.

Tested on Docker postgis/postgis:13-master

SELECT postgis_full_version();

— POSTGIS="3.3.0dev 3.2.0-398-g4fa57df0b" [EXTENSION] PGSQL="130" GEOS="3.11.0dev-CAPI-1.16.0" PROJ="8.2.0" LIBXML="2.9.10" LIBJSON="0.15" LIBPROTOBUF="1.3.3" WAGYU="0.5.0 (Internal)" (core procs from "3.1.4 ded6c34" need upgrade)

SELECT version();


PostgreSQL 13.5 (Debian 13.5-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit


Change History (4)

comment:1 by bhoefling, 8 months ago

Cc: bhoefling added

comment:2 by bhoefling, 8 months ago

For reference, here is an older bug that fixed the CURVESTRING case:

comment:3 by pramsey, 6 weeks ago

Fixed in master at e87cf16e6/git

comment:4 by pramsey, 6 weeks ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.