[PostGIS] #6065: ValidateTopology fails to report invalid side-labeling

PostGIS trac at osgeo.org
Sun Apr 12 23:54:49 PDT 2026


#6065: ValidateTopology fails to report invalid side-labeling
-----------------------+---------------------------
  Reporter:  strk      |      Owner:  strk
      Type:  defect    |     Status:  reopened
  Priority:  medium    |  Milestone:  PostGIS 3.7.0
 Component:  topology  |    Version:  master
Resolution:            |   Keywords:
-----------------------+---------------------------
Comment (by strk):

 It looks like `CG_Orientation` gets the orietation right:
 {{{
 strk at strk=# with ring as ( select * from topology.getRingEdges('t6065',
 -1) ), geoms as ( select r.sequence seq, r.edge as sid, e.geom from ring r
 join t6065.edge e on ( abs(r.edge) = e.edge_id ) ), shell as ( select
 ST_MakePolygon(ST_MakeLine( case when sid > 0 then geom else
 ST_Reverse(geom) end order by seq)) g from geoms ) select g,
 ST_IsValidDetail(g), st_area(g), st_isPolygonCCW(g), CG_Orientation(g)
 from shell;
 -[ RECORD 1
 ]----+-----------------------------------------------------------------------------------------------------------------------------------------------------------
 g                |
 01030000000100000004000000FD613B270D6C314031AA543619475140890205230D6C31408177583619475140A4613B270D6C31402FAA543619475140FD613B270D6C314031AA543619475140
 st_isvaliddetail | (t,,)
 st_area          | 4.127836234257221e-21
 st_ispolygonccw  | t
 cg_orientation   | -1

 strk at strk=# with ring as ( select * from topology.getRingEdges('t6065', 1)
 ), geoms as ( select r.sequence seq, r.edge as sid, e.geom from ring r
 join t6065.edge e on ( abs(r.edge) = e.edge_id ) ), shell as ( select
 ST_MakePolygon(ST_MakeLine( case when sid > 0 then geom else
 ST_Reverse(geom) end order by seq)) g from geoms ) select g,
 ST_IsValidDetail(g), st_area(g), st_isPolygonCCW(g), CG_Orientation(g)
 from shell;
 -[ RECORD 1
 ]----+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 g                |
 0103000000010000000A000000890205230D6C31408177583619475140FD613B270D6C314031AA5436194751405D58985776943140195EE965DE47514085FFA6647B9F31408FC1C62B394851405D58985776943140195EE965DE475140FD613B270D6C314031AA543619475140A4613B270D6C31402FAA543619475140890205230D6C31408177583619475140320205230D6C31407E77583619475140890205230D6C31408177583619475140
 st_isvaliddetail | (f,"Ring Self-
 intersection",01010000005D58985776943140195EE965DE475140)
 st_area          | 6.732252036060648e-20
 st_ispolygonccw  | t
 cg_orientation   | 1
 }}}

 Note how `ST_IsPolygonCCW` gives the same response for the two rings while
 `CG_Orientation` changes between them. The above is the answer with
 POSTGIS="3.7.0dev 3.6.0rc2-417-g67ff872e2" (before the long double
 introduction). With the `long double` on my system both `ST_IsPolygonCCW`
 and `CG_Orientation` agree on winding order of the problematic ring:

 {{{
 0103000000010000000A000000890205230D6C31408177583619475140FD613B270D6C314031AA5436194751405D58985776943140195EE965DE47514085FFA6647B9F31408FC1C62B394851405D58985776943140195EE965DE475140FD613B270D6C314031AA543619475140A4613B270D6C31402FAA543619475140890205230D6C31408177583619475140320205230D6C31407E77583619475140890205230D6C31408177583619475140
 }}}
-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/6065#comment:9>
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