[Mapserver-users] Setting the classindex of a shapeObj() has no effect

Bjoern Platzen bplatzen at sosnetz.de
Thu Nov 20 07:13:01 PST 2003


Hi Eric,

thanks! That works perfectly!

Bye, 

Bjoern.

Am Mittwoch, 19. November 2003 14:09 schrieb Eric Bridger:
> Bjoern,
> Since I use the same method for drawing points I've run into the same
> issue.  I think the comments in my Wiki example mention this.  I
> never figured out exactly why this is so. Perhaps a layers features
> are drawn without respect to any Class attributes.
>
> The solution  I use is to call $class =
> $layer->getClass($class_index); # class_index is based on some
> category Then set the attrbutes, e.g. $class->{symbol} =
> $symbol_index; $class->{size} = 20;
> $class->{color} = .... etc.
>
> Finally $pointDraw($map,  $layer, $point ...)
>
> in ADDITION to calling $layer->addFeature($shape) which makes the
> points queryable. This seems like something of a hack, i.e. drawing
> all the points twice.
>
> I don't call $layer->draw()
>
> In your case you may not need to set the class attributes. Perhaps
> just calling $layer->getClass(0) or getClass(1) prior to
> $point->draw() will be enough.
>
> Eric
>
> At 12:36 AM 11/19/2003 +0100, Bjoern Platzen wrote:
> >Hi folks,
> >
> >I'm still messing around with PythonMapScript...
> >With a lot of help from the list, I am now able to create queryable
> >Features for a layer. Now I want to show my points with different
> >symbols. In my database-table, Ive got a field for a category. If
> > the category-field contains '1', the point should be drawn with the
> > CLASS 0, otherwise with CLASS 1.
> >
> >Here's the layer-definition in the mapfile:
> >LAYER
> >  NAME 'baustellen'
> >  TYPE POINT
> >  STATUS on
> >  CLASS
> >    Symbol 'bau'
> >  END#class
> >  CLASS
> >    Symbol 'db'
> >  END#class
> >  TEMPLATE 'rahmen2.html'
> >  TOLERANCE 50
> >END#LAYER
> >END # Map File
> >
> >Here's the code-snippet, that produces the points:
> >for l in r[1]:
> >    #r[1] is the
> > resultset[[pointx,pointy,date1,date2,category],[..],..] newPoint =
> > mapscript.pointObj()
> >    newPoint.x = l[0]
> >    newPoint.y = l[1]
> >    newLine = mapscript.lineObj()
> >    newLine.add(newPoint)
> >    newShape = mapscript.shapeObj(mapscript.MS_SHAPE_POINT)
> >    newShape.add(newLine)
> >    newShape.index=l[6]
> >    if l[4]=='1':#l[4] contains the category
> >        newShape.classindex = 0
> >    else:
> >        newShape.classindex = 1
> >    myLayer.addFeature(newShape)
> >
> >All features are displayed with the symbol defined in CLASS 0.
> >
> >I thought classindex would be an attribute of the shapeObj() that is
> >read- and writeable.
> >
> >What will I have to do to display my Points with different
> >symbols/classes??
> >
> >Thanks in advance for any help!
> >
> >Bye,
> >
> >Bjoern
> >--
> >small office solutions
> >info at sosnetz.de  -  http://www.sosnetz.de
> >
> >_______________________________________________
> >Mapserver-users mailing list
> >Mapserver-users at lists.gis.umn.edu
> >http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
>
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users

-- 
small office solutions
info at sosnetz.de  -  http://www.sosnetz.de




More information about the MapServer-users mailing list