MapServer / MapServer-import

3 stars 2 forks source link

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

Open tbonfort opened 12 years ago

tbonfort commented 12 years ago

Reporter: sdlime Date: 2004/09/02 - 23:05

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
}
tbonfort commented 12 years ago

Author: sdlime Date: 2004/09/03 - 19:04

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
tbonfort commented 12 years ago

Author: sgillies@frii.com Date: 2004/09/03 - 19:30

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)
tbonfort commented 12 years ago

Author: sgillies@frii.com Date: 2004/09/03 - 19:58

steve, problem is that when you reference layer->class[i], i is uninitialized.
tbonfort commented 12 years ago

Author: sgillies@frii.com Date: 2004/09/04 - 18:23

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
tbonfort commented 12 years ago

Author: sdlime Date: 2004/09/04 - 19:56

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

Steve
tbonfort commented 12 years ago

Author: sgillies@frii.com Date: 2004/09/04 - 20:22

Confirmed.