Opened 20 years ago

Closed 20 years ago

#846 closed defect (fixed)

Setting classindex of a feature added to mapfile has no effect...

Reported by: sdlime Owned by: sdlime
Priority: highest Milestone:
Component: MapServer C Library Version: 4.3
Severity: critical Keywords:
Cc: sgillies@…

Description

The fix (need to take into account scale with the if-then):

int msShapeGetClass(layerObj *layer, shapeObj *shape, double scale)
{
  int i;

  if(layer->connectiontype == MS_INLINE) return shape->classindex;
  
  for(i=0; i<layer->numclasses; i++) {
    
    if(scale > 0) {  // verify scale here 
      if((layer->class[i].maxscale > 0) && (scale > layer->class[i].maxscale))
        continue; // can skip this one, next class
      if((layer->class[i].minscale > 0) && (scale <= layer->class[i].minscale))
        continue; // can skip this one, next class
    }

    if(layer->class[i].status != MS_DELETE &&
msEvalExpression(&(layer->class[i].expression), layer->classitemindex,
shape->values, layer->numitems) == MS_TRUE)
      return(i);
  }

  return(-1); // no match
}

Change History (9)

comment:1 by sgillies@…, 20 years ago

Cc: sgillies@… added

comment:2 by sdlime, 20 years ago

Resolution: fixed
Status: newclosed
Block of code added to msGetClass was:

  // INLINE features do not work with expressions, allow the classindex
  // value set prior to calling this function to carry through.
  if(layer->connectiontype == MS_INLINE) {
    if(scale > 0) {  // verify scale here 
      if((layer->class[i].maxscale > 0) && (scale > layer->class[i].maxscale))
        return -1; // can skip this feature
      if((layer->class[i].minscale > 0) && (scale <= layer->class[i].minscale))
        return -1; // can skip this feature
    }

    return shape->classindex;
  }

I think it makes sense to do this here. The alternative is to update
msDrawVectorLayer layer NOT to call msGetClass for INLINE layers.

Steve

comment:3 by sgillies@…, 20 years ago

Resolution: fixed
Status: closedreopened
Steve, my InlineFeatureTestCase.testAddPointFeature segfaults after this
commit.

class InlineFeatureTestCase(MapTestCase):
    """tests for issue http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=562"""
    
    def testAddPointFeature(self):
        """adding a point to an inline feature works correctly"""
        inline_layer = self.map.getLayerByName('INLINE')
        p = mapscript.pointObj(0.2, 51.5)
        l = mapscript.lineObj()
        self.addPointToLine(l, p)
        shape = mapscript.shapeObj(inline_layer.type)
        self.addLineToShape(shape, l)
        inline_layer.addFeature(shape)
        msimg = self.map.draw()
        filename = 'testAddPointFeature.png'
        msimg.save(filename)

comment:4 by sgillies@…, 20 years ago

steve, problem is that when you reference layer->class[i], i is uninitialized.

comment:5 by sgillies@…, 20 years ago

Severity: normalmajor

comment:6 by sgillies@…, 20 years ago

Priority: highhighest
Severity: majorcritical
Marking as critical.  Inline layers are broken, can be verified using
shp2img from the mapserver build directory

[sean@lenny mapserver]$ ./shp2img -m tests/test.map -o tests/test.png
Segmentation fault




comment:7 by sdlime, 20 years ago

Oops, stupid on my part. I can't compile on this end (I'm in Brasil) and typo
slipped through. Try it now.

Steve

comment:8 by sgillies@…, 20 years ago

Confirmed.

comment:9 by sdlime, 20 years ago

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.