Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-7525

GIS: ST_NumInteriorRings returns 1 on a polygon consisting of two separate parts

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: N/A
    • Fix Version/s: 10.1.6
    • Component/s: GIS
    • Labels:
    • Sprint:
      10.1.6-1

      Description

      I am not sure what is the correct behavior here. The polygon consists of two separate parts (see the picture).

      Here http://support.esri.com/en/knowledgebase/GISDictionary/term/polygon I see two definitions of 'polygon':

      [data models] On a map, a closed shape defined by a connected sequence of x,y coordinate pairs, where the first and last coordinate pair are the same and all other pairs are unique.

      [ESRI software] In ArcGIS software, a shape defined by one or more rings, where a ring is a path that starts and ends at the same point. If a polygon has more than one ring, the rings may be separate from one another or they may nest inside one another, but they may not overlap.

      The polygon in question fits the second definition. Also, PostGIS which is rather strict about misuse of different shapes, agrees to create it as a polygon.

      But both PostGIS and MariaDB return ST_NumInteriorRings = 1 for it. I don't know why, obviously there are no interior rings in here. I could not however find a clear definition of how ST_NumInteriorRings should behave in this case.

      MariaDB [test]> select ST_NumInteriorRings(ST_PolyFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),(-1 -1,-5 -1,-5 -5,-1 -5,-1 -1))'));
      +------------------------------------------------------------------------------------------------------------+
      | ST_NumInteriorRings(ST_PolyFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),(-1 -1,-5 -1,-5 -5,-1 -5,-1 -1))')) |
      +------------------------------------------------------------------------------------------------------------+
      |                                                                                                          1 |
      +------------------------------------------------------------------------------------------------------------+
      1 row in set (0.00 sec)
      
      pgis=#  select ST_NumInteriorRings(ST_PolyFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),(-1 -1,-5 -1,-5 -5,-1 -5,-1 -1))'));
       st_numinteriorrings 
      ---------------------
                         1
      (1 row)
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              holyfoot Alexey Botchkov added a comment -

              That contradiction was created by the OpenGIS standard.
              Accordingly to it, the POLYGON should have exactly one ExteriorRing and all the other rings should
              lie within that ExteriorRing and thus be the InteriorRings.
              But practically it's often convenient to let polygons have several 'ExteriorRings' and that doesn't make calculations on
              shapes any more complicated. So that would be a shame to deprive user that convenience just to follow the standard.
              So i belive we shouldn't fix this issue - rather document it.

              Show
              holyfoot Alexey Botchkov added a comment - That contradiction was created by the OpenGIS standard. Accordingly to it, the POLYGON should have exactly one ExteriorRing and all the other rings should lie within that ExteriorRing and thus be the InteriorRings. But practically it's often convenient to let polygons have several 'ExteriorRings' and that doesn't make calculations on shapes any more complicated. So that would be a shame to deprive user that convenience just to follow the standard. So i belive we shouldn't fix this issue - rather document it.
              Hide
              greenman Ian Gilfillan added a comment -

              I have documented this on the https://mariadb.com/kb/en/mariadb/st_numinteriorrings/ page, will also do so on the https://mariadb.com/kb/en/mariadb/polygon page

              Show
              greenman Ian Gilfillan added a comment - I have documented this on the https://mariadb.com/kb/en/mariadb/st_numinteriorrings/ page, will also do so on the https://mariadb.com/kb/en/mariadb/polygon page

                People

                • Assignee:
                  holyfoot Alexey Botchkov
                  Reporter:
                  elenst Elena Stepanova
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - 0 minutes
                    0m
                    Logged:
                    Time Spent - 3 hours
                    3h

                      Agile