Opened 11 years ago

Closed 9 years ago

#2283 closed defect (fixed)

shp2pgsql may be parsing shp's multipolygon incorrectly

Reported by: qtxie Owned by: mcayland
Priority: high Milestone: PostGIS 2.2.0
Component: utils/loader-dumper Version: master
Keywords: multipolygon Cc:

Description

I find shp2pgsql may be parsing shp's multipolygon incorrectly, which will generate two overlapped innter rings. Please see the picture in attachment.

The algorithm to put the inner rings into the list of the outer rings may be wrong. In function:

file: shp2pgsql-core.c
int
FindPolygons(SHPObject *obj, Ring ***Out);
{
    ...
    /* Put the inner rings into the list of the outer rings */
    /* of which they are within */
    for (pi = 0; pi < in_index; pi++)
    {
        // May be wrong to do those.
        // Some inner rings insert to the wrong outer ring
        ....
    }

According 'ESRI_shapefile_technical_description.pdf', the rings along with a outer ring is the inner rings belong with it, so we don't need to find the inner ring manually.

Attachments (2)

hole_correct.JPG (22.8 KB ) - added by qtxie 11 years ago.
Correct split the multipolygon
hole_wrong.JPG (22.3 KB ) - added by qtxie 11 years ago.
Incorrect split the multipolygon

Download all attachments as: .zip

Change History (8)

by qtxie, 11 years ago

Attachment: hole_correct.JPG added

Correct split the multipolygon

by qtxie, 11 years ago

Attachment: hole_wrong.JPG added

Incorrect split the multipolygon

comment:1 by robe, 11 years ago

Milestone: PostGIS 2.0.4

comment:2 by robe, 11 years ago

Milestone: PostGIS 2.0.4PostGIS 2.1.1

comment:3 by robe, 11 years ago

Milestone: PostGIS 2.1.1PostGIS 2.2.0

sounds complicated — too much so for a micro release

comment:4 by pramsey, 9 years ago

Confirmed, this polygon

MULTIPOLYGON(
 ((0 0,100 0,100 100,0 100,0 0),(10 10,90 10,90 90,10 90,10 10)),
 ((20 20,20 80,80 80,80 20,20 20),(30 30,30 70,70 70,70 30,30 30))
)

when exported to shape and then reimported, turns into this one

MULTIPOLYGON(
 ((0 0,0 100,100 100,100 0,0 0),(10 10,90 10,90 90,10 90,10 10),(30 30,70 30,70 70,30 70,30 30)),
 ((20 20,20 80,80 80,80 20,20 20))
)

comment:5 by pramsey, 9 years ago

Fixed in 2.1 at r13932

comment:6 by pramsey, 9 years ago

Resolution: fixed
Status: newclosed

Fixed in trunk at r13933

Note: See TracTickets for help on using tickets.