[Mapserver-users] can I use different symbols in thesamedynamiclayer?

Eric Bridger eric at gomoos.org
Fri Sep 26 12:23:07 EDT 2003


I'm concerned about this because of a planned upgrade to 4.0.  

What Vinko says is true when you want mapserver to draw your features
based on a known data source.  But Frieso wants to draw dynamic points
from an unknown data source using mapscript.  This is something I do
repeatedly in Perl mapscript 3.6.  I define a generic point layer, with
perhaps default settings, but then draw each point after setting the
proper values on the fly. There is only one class in the layer and no
CLASSITEM.

Most of the CLASS  members are read/write:
$class->{symbol}
$class->{size}
$class->{label}->{color}
$class->{label}->{angle}
$class->{color}, etc. etc.

msDrawPoint() uses the current values from the classindex passed. And
those values have just been set.
I would guess that 4.0's style object works the same way, and in fact,
Frieso IS able to change the symbol index so I suspect that there is
some other problem.

Frieso, as a work around have you tried using the old $class->{color}
member?   The old CLASS members seem to still exist in 4.0.


On Fri, 2003-09-26 at 18:26, Vinko Vrsalovic wrote:
> On Fri, Sep 26, 2003 at 12:40:25PM +0200, Frieso ter Haseborg wrote:
> > 
> > So obviously the changes are stored in the map, but they don't take any
> > effect.
>  
> One layer is a collection of figures of some type, a class defines
> how a certain figure will be drawn based on a certain attribute
> (CLASSITEM) or characteristic, so, to draw differently two or more 
> features on one layer, you must add as many classes as different 
> colors (or symbols, etc) you need.
>  
> > IMHO this can't take any effect since I got a new class, but the next
> > point doesn't know it has to use this new class.
>  
> Exactly, that's why you need to set the class index in the
> $point->draw() call:
> 
> int draw(mapObj map, layerObj layer, imageObj img, 
>             int class_index, string text)
> 
> The fourth parameter is what you need to change:
> 
> > >> $class = $layer->getClass(0);
> > >> $style = $class->getStyle(0);
> > >> $style->color->setRGB(0, 0, 255); //draw a blue point
> > >> $style->set ( 'symbol', $sym1 );
> > >> $pt->setXY( 2100000, 10100000 );
> > >> $pt->draw($map, $layer, $image, 0, "Pt1");
> > >> 
> > >> $class = ms_newClassObj($layer);    //new class instance
> > >> $style = ms_newStyleObj($class);	    //new style instance
> > >> $style->color->setRGB(0, 255, 0); //draw a green one - !this failes,
> > >> second symbol becomes blue also!
> > >> $style->set ( 'symbol', $sym2 );
> > >> $pt->setXY( 4400000, 10000000 );
> > >> $pt->draw($map, $layer, $image, 1, "Pt2");
> 				     ! <- here
> 
> Another way to do this is through addFeature(), this is the way i do it
> because i usually need to add polygons and lines besides points, i'll
> send an example if needed.
> 
> HTH,
> -- 
> Vinko Vrsalovic <el[|- at -|]vinko.cl>
> http://www.cprsig.cl
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> 





More information about the mapserver-users mailing list