Opened 18 years ago

Closed 18 years ago

#1828 closed defect (fixed)

cannot serve multipolygons

Reported by: ross.elliott@… Owned by: sdlime
Priority: high Milestone:
Component: WFS Server Version: 4.8
Severity: normal Keywords:
Cc:

Description

Mapserver cannot serve multipolygons (haven't checked other multi types yet).
The problem seems to be when it tries to decide if a ring is an outer or an
inner and ends up making them all inners. I've been using the lakes layer from
the CITE dataset to test this but as it only contains one polygon with a hole
it's not really much of a test.

Change History (6)

comment:1 by ross.elliott@…, 18 years ago

I have a fix for this which seems to work for multipolygons with and without
holes. It assumes that all rings are outers unless a ring is enclosed by
another, this is necessary because otherwise only polys with holes would work.

int *msGetOuterList(shapeObj *shape)
{
  int i;
  int *list;
  int c1,c2;
  shapeObj *rings;
  shapeObj *ring;

  rings = (shapeObj *)malloc(sizeof(*rings) * shape->numlines);
  if(!rings)
        return NULL;

  list = (int *)malloc(sizeof(int)*shape->numlines);
  if(!list)
  {
        free(rings);
        return(NULL);
  }

  for(i=0; i< shape->numlines; i++)
        msInitShape(&rings[i]),msAddLine(&rings[i],&(shape->line[i]));


  for(i=0; i < shape->numlines; i++)
  {
    list[i] = MS_TRUE; // default to being an outer in case there are no holes
    ring = &rings[i];

    // check to see if our ring is contained in any of the other rings, if so
then it's an inner ring
    for(c1=0; c1<shape->numlines; c1++)
    {
      if(c1 == i) continue; // no point checking against ourself


      for(c2=0; c2 < ring->line[0].numpoints; c2++)
      {
        if(msIntersectPointPolygon(&(ring->line[0].point[c2]), &rings[c1]) ==
MS_TRUE)
        {
                list[i] = MS_FALSE;
                break;
        }
      }
    }
  }

  for(i=0; i< shape->numlines; i++)
        msFreeShape(&rings[i]);
  free(rings);
  return(list);
}

comment:2 by dmorissette, 18 years ago

Cc: mapserver-bugs@… added
Owner: changed from mapserverbugs to sdlime
Reassigned to Steve who I believe is the author of that code.

comment:3 by sdlime, 18 years ago

I had tried that code with other multipolygon data without issue but will have 
a look. What version specifically were you having trouble with? Early versions 
of 4.8 suffered from something similar (see bug 1648) but I rewrote these 
functions back in Feb.

Steve

comment:4 by ross.elliott@…, 18 years ago

This was on 4.8.1, I'm on holiday this week, but I'll see if I can find some
time to try the same dataset against the latest release.

comment:5 by sdlime, 18 years ago

Excellent, that makes sense then. Fingers crossed that it works. The example I
had with the other bug was way nasty so I'm hopefull...

Steve

comment:6 by sdlime, 18 years ago

Resolution: fixed
Status: newclosed
Marking as fixed. Can repoen later if necessary.

Steve
Note: See TracTickets for help on using tickets.