Opened 4 years ago

Closed 3 years ago

#4858 closed defect (wontfix)

ST_DumpPoints ring indices are inconsistent with ST_DumpRings and ST_InteriorRingN

Reported by: mdavis Owned by: pramsey
Priority: medium Milestone: PostGIS 3.2.0
Component: postgis Version: 2.5.x -- EOL
Keywords: Cc:

Description

ST_DumpPoints produces polygon ring indices which start at 1, for the shell, and 2 and up for holes. This is inconsistent with ST_DumpRings, which produces index 0 for the shell, and 1 and up for holes. It is also inconsistent with ST_InteriorRingN, which numbers holes starting at 1.

Note that ST_InteriorRingN uses OGC standard numbering, which is 1-based.

It would be good to have consistency between functions, conformity with the standard, and avoid arithmetic to adjust indexes. Perhaps ST_DumpPoints should be changed to number rings starting at 0.

For example:

SELECT dmp.path, ST_AsText(dmp.geom) 
FROM ST_DumpPoints('POLYGON (( 3 0, 3 3, 6 3, 6 0, 3 0 ), ( 5 1, 4 2, 5 2, 5 1 ))':: geometry) AS dmp;

 path  | st_astext  
-------+------------
 {1,1} | POINT(3 0)
 {1,2} | POINT(3 3)
 {1,3} | POINT(6 3)
 {1,4} | POINT(6 0)
 {1,5} | POINT(3 0)
 {2,1} | POINT(5 1)
 {2,2} | POINT(4 2)
 {2,3} | POINT(5 2)
 {2,4} | POINT(5 1)

but:

SELECT dmp.path, ST_AsText(dmp.geom) 
FROM ST_DumpRings('POLYGON (( 3 0, 3 3, 6 3, 6 0, 3 0 ), ( 5 1, 4 2, 5 2, 5 1 ))':: geometry) AS dmp;

 path |           st_astext            
------+--------------------------------
 {0}  | POLYGON((3 0,3 3,6 3,6 0,3 0))
 {1}  | POLYGON((5 1,4 2,5 2,5 1))

Change History (7)

comment:1 by mdavis, 4 years ago

See also Dev list conversation.

comment:2 by mdavis, 4 years ago

Sounds like there is reluctance to introduce indexing starting at zero, since that is not in harmony with Postgres convention.

To satisfy the requirement for 1-based indexing, ST_DumpRings could be changed to start at 1. It is then consistent with ST_DumpPoints. This is inconsistent with ST_InteriorRingN, but perhaps that doesn't matter.

To provide a complete and consistent set of ring accessor functions, the following functions could be added:

ST_RingN - returns polygon rings, with 1 = shell and 2..N the holes ST_NumRings - returns the total number of rings in a polygon

These are consistent with (updated) ST_DumpRings and ST_DumpPoints.

comment:3 by pramsey, 3 years ago

Milestone: PostGIS 3.1.23.1.3

comment:4 by pramsey, 3 years ago

Milestone: 3.1.3PostGIS 3.1.3

Milestone renamed

comment:5 by robe, 3 years ago

Milestone: PostGIS 3.1.3PostGIS 3.1.4

In prep for 3.1.3 release

comment:6 by robe, 3 years ago

Milestone: PostGIS 3.1.4PostGIS 3.2.0

We can't change this in a micro

comment:7 by pramsey, 3 years ago

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