[postgis-tickets] [PostGIS] #5089: ST_Reverse does not handle CURVEPOLYGON/COMPOUNDCURVE correctly
PostGIS
trac at osgeo.org
Wed Feb 9 03:23:43 PST 2022
#5089: ST_Reverse does not handle CURVEPOLYGON/COMPOUNDCURVE correctly
-----------------------+---------------------------
Reporter: bhoefling | Owner: strk
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 3.3.0
Component: liblwgeom | Version: 3.2.x
Keywords: |
-----------------------+---------------------------
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:
https://github.com/postgis/postgis/blob/f6def67654c25d812446239036cee44812613748/regress/core/reverse.sql#L47
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.
EXPECTED:
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)
https://github.com/postgis/postgis/blob/2fb15205263248249b1f1dd09abc117e8f67807c/liblwgeom/lwgeom.c#L135
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();
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
Björn
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5089>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list