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

Frieso ter Haseborg ter-haseborg at sf-datentechnik.de
Mon Sep 29 07:55:20 EDT 2003


Hi Eric,

>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.

Yes I tried this when starting my testing of this feature, since I found
this notation in the examples.
But I fear $class->color is obsolete. Properties in this class can be
set but take no effect.

This is what I tried so far:
$class = $layer->getClass(0);
$class->name = 'Test';
$class->color->red = 0;
$class->color->green = 255;	//specify green as class-color
$class->color->blue = 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");
$color = $style->color;
echo 'Style-color:
'.$color->red.'-'.$color->green.'-'.$color->blue.'<br>';
$color = $class->color;
echo 'Class-color: '.$color->red.'-'.$color->green.'-'.$color->blue;
$map->save('test.map');

Map-output shows that no changes took place:
LAYER
    NAME "p"
    SIZEUNITS PIXELS
    STATUS ON
    TOLERANCE 0
    TOLERANCEUNITS PIXELS
    TYPE POINT
    UNITS METERS
    CLASS
      LABEL
        SIZE MEDIUM
        TYPE BITMAP
        BUFFER 0
        COLOR 0 0 0
        FORCE FALSE
        MINDISTANCE -1
        MINFEATURESIZE -1
        OFFSET 0 0
        PARTIALS TRUE
        POSITION AUTO
      END
      STYLE
          COLOR 255 0 0 //this is the initial value 
                        // specified in my mapfile
                        // oviously no change
        MAXSIZE 100
        MINSIZE 1
        SIZE 40
        SYMBOL 16
      END
    END
  END

If there's anything else I can try, just let me know.
Frieso




>Message: 3
>Subject: Re: [Mapserver-users] can I use different symbols in
>	thesamedynamiclayer?
>From: Eric Bridger <eric at gomoos.org>
>To: Mapserver List <mapserver-users at lists.gis.umn.edu>
>Date: 26 Sep 2003 16:23:07 +0000
>
>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




More information about the mapserver-users mailing list