[Mapserver-users] can I use different symbols inthesamedynamiclayer?

Frieso ter Haseborg ter-haseborg at sf-datentechnik.de
Fri Sep 26 06:10:21 EDT 2003


Hi,

yes my symbol changes, due to your help! ;-)

But the color doesn't.

Here's the layer part of my mapfile:
LAYER
NAME p
TYPE POINT
STATUS ON

   CLASS
      SYMBOL 1
      COLOR 255 0 0 //initialize symbols in red - will be changed by php
later
      SIZE 40

      LABEL
         COLOR 0 0 0
         SIZE medium
         POSITION AUTO
      END
   END
END

I extended my mapscript with a "$map->save"-Command as mentioned by
Vinko in the next post:
$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");
$map->save('test.map');


$class = $layer->getClass (0);      //new class instance
$style = $class->getStyle(0);       //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, 0, "Pt2");
$map->save('test2.map');

This gives the following outputs in the layer-section:
//test.map
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 0 0 255	// blue for the first point
        MAXSIZE 100
        MINSIZE 1
        SIZE 40
        SYMBOL 16 // that's sym1
      END
    END
  END

//test2.map
  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 0 255 0 // green for the second point, 
                        // so it's correct in the map, 
                        // but not on the screen. I'm confused!

        MAXSIZE 100
        MINSIZE 1
        SIZE 40
        SYMBOL 17 // that's sym2
      END
    END
  END

So obviously the changes are stored in the map, but they don't take any
effect.

TIA,
Frieso

>-----Original Message-----
>From: Eric Bridger [mailto:eric at gomoos.org]
>Sent: Thursday, September 25, 2003 1:46 PM
>To: Frieso ter Haseborg
>Subject: RE: [Mapserver-users] can I use different symbols
>inthesamedynamiclayer?
>
>
>This works for me using Mapserver 3.6.  I sincerely hope it 
>works in 4.0
>since I plan to upgrade soon.  Perhaps you should show us the relevant
>section of you map file.
>
>Does your symbol change? Just not the color?
>
>On Thu, 2003-09-25 at 15:00, Frieso ter Haseborg wrote:
>> Hi Eric,
>> 
>> nope, no success so far. I tried this:
>> 
>> [...]
>> $pt = ms_newPointObj();
>> 
>> $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 = $layer->getClass (0);    //new class instance
>> $style = $class->getStyle(0);	    //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, 0, "Pt2");
>> [...]
>> 
>> What am I doing wrong? :-(
>> 
>> TIA,
>> Frieso
>> 
>> >-----Original Message-----
>> >From: Eric Bridger [mailto:eric at gomoos.org]
>> >Sent: Wednesday, September 24, 2003 1:15 PM
>> >To: Frieso ter Haseborg
>> >Cc: Mapserver List
>> >Subject: RE: [Mapserver-users] can I use different symbols in
>> >thesamedynamiclayer?
>> >
>> >
>> >I wasn't very clear.  Not a new class, a new class instance. Or, for
>> >MS4.0, a new style instance. So your layer would have 1 class and 1
>> >sytle. For each point you want to draw, in psuedo code:
>> >$layer = getLayerByName()
>> >$point = new pointObj(); # the point can be re-used.
>> >foreach lat, lon {
>> >   $class = $layer->getClass(0);
>> >   $style = $class->getSytle(0);
>> >   # set your style attributes, symbol, color, etc.
>> >   ....
>> >   $point->draw();
>> >}
>> >
>> >On Wed, 2003-09-24 at 15:02, Frieso ter Haseborg wrote:
>> >> Hi,
>> >> 
>> >> okay: new color, new class - sounds good, I think. But - 
>here comes
>> >> another newbie-question - how do I tell the points to which 
>> >class they
>> >> belong???
>> >> 
>> >> Doesn't this lead back to the 
>CLASSITEM/EXPRESSION-question or am I
>> >> missing something?
>> >> 
>> >> TIA,
>> >> Frieso
>> >> 
>> >> 
>> >> >-----Original Message-----
>> >> >From: Eric Bridger [mailto:eric at gomoos.org]
>> >> >Sent: Wednesday, September 24, 2003 12:02 PM
>> >> >To: Frieso ter Haseborg
>> >> >Cc: Mapserver List
>> >> >Subject: RE: [Mapserver-users] can I use different symbols in
>> >> >thesamedynamic layer?
>> >> >
>> >> >
>> >> >You're right Frieso,
>> >> >I am still using 3.6
>> >> >
>> >> >The issue you mention below exists in 3.6 as well.  What 
>> >you need to do
>> >> >is to get a new class for each point and set the color and 
>> >symbol anew.
>> >> >
>> >> >On Wed, 2003-09-24 at 09:27, Frieso ter Haseborg wrote:
>> >> >> Hi,
>> >> >> 
>> >> >> one more question: Can't I change the color the same way? After
>> >> >> successfully using different symbols, I tried to change the 
>> >> >color of the
>> >> >> symbols also. But a color-change only takes effect for the 
>> >> >first change
>> >> >> resp. for the first symbol drawn. All subsequent symbols 
>> >are drawn in
>> >> >> _this_ new color also, but not in the individual color 
>> >specified for
>> >> >> each symbol.
>> >> >> 
>> >> >> My PHP/MapScript goes like this:
>> >> >> $sym1 = $map->getSymbolByName ( "excl" );
>> >> >> $sym2 = $map->getSymbolByName ( "tent" );
>> >> >> $class = $layer->getClass (0);
>> >> >> $style = $class->getStyle(0);
>> >> >> 
>> >> >> // first point
>> >> >> $style->color->setRGB(0, 0, 255); // now the next point will 
>> >> >change to
>> >> >> blue 
>> >> >> 					    // (symbols 
>in mapfile are
>> >> >> initialized in red)
>> >> >> 					    // THIS 
>CHANGE WORKS!
>> >> >> $style->set ( 'symbol', $sym1 );
>> >> >> $pt = ms_newPointObj();
>> >> >> $pt->setXY( 2100000, 10100000 );
>> >> >> $pt->draw($map, $layer, $image, 0, "Pt1");
>> >> >> 
>> >> >> // second point
>> >> >> $style->color->setRGB(0, 255, 0); // now the next 
>point IMO should
>> >> >> become green, but it doesn't, it stays blue
>> >> >> 					    // THIS 
>CHANGE FAILES!
>> >> >> $style->set ( 'symbol', $sym2 );
>> >> >> $pt = ms_newPointObj();
>> >> >> $pt->setXY( 4400000, 10000000 );
>> >> >> $pt->draw($map, $layer, $image, 0, "Pt2");
>> >> >> 
>> >> >> 
>> >> >> Am I overlooking something or is there any restriction 
>I ran into?
>> >> >> 
>> >> >> TIA,
>> >> >>  
>> >> >> Frieso ter Haseborg
>> >> >> - Software Development - 
>> >> >>  
>> >> >> --
>> >> >> 
>> >> >> -------------------------------------------------- 
>> >> >> S&F Datentechnik GmbH&Co.KG 
>> >> >> Reimersstr. 41b 
>> >> >> 26789 Leer, Germany
>> >> >> 
>> >> >> 
>> >> >> 
>> >> >> >-----Original Message-----
>> >> >> >From: Frieso ter Haseborg 
>> >> >> >Sent: Wednesday, September 24, 2003 9:52 AM
>> >> >> >To: Eric Bridger
>> >> >> >Cc: mapserver-users at lists.gis.umn.edu
>> >> >> >Subject: RE: [Mapserver-users] can I use different 
>symbols in the
>> >> >> >samedynamic layer?
>> >> >> >
>> >> >> >
>> >> >> >Hi Eric,
>> >> >> >
>> >> >> >thanx, yes this helped a lot. It works - but so far 
>only, when 
>> >> >> >using the StyleObj-Class.
>> >> >> >
>> >> >> >I did the following in PHP:
>> >> >> >
>> >> >> >$sym1 = $map->getSymbolByName ( "excl" );
>> >> >> >$sym2 = $map->getSymbolByName ( "tent" );
>> >> >> >$class = $layer->getClass (0);
>> >> >> >$style = $class->getStyle(0);
>> >> >> >
>> >> >> >$style->set ( 'symbol', $sym1 );
>> >> >> >[...]//draw point1
>> >> >> >
>> >> >> >$style->set ( 'symbol', $sym2 );
>> >> >> >[...]//draw point2
>> >> >> >
>> >> >> >It looks like the symbol attribute is obsolete in MS and 
>> >> >> >PHP/MapScript version 4.0, though no error is raised. It 
>> >> >> >simply effects nothing in my configuration. Which version 
>> >> >do you use?
>> >> >> >
>> >> >> >Anyway it works, thanx again!
>> >> >> >
>> >> >> >Best regards,
>> >> >> > 
>> >> >> >Frieso ter Haseborg
>> >> >> >- Software Development - 
>> >> >> > 
>> >> >> >--
>> >> >> >
>> >> >> >-------------------------------------------------- 
>> >> >> >S&F Datentechnik GmbH&Co.KG 
>> >> >> >Reimersstr. 41b 
>> >> >> >26789 Leer, Germany
>> >> >> > 
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> 
>> >> >> _______________________________________________
>> >> >> 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
>> 
>
>
>
>




More information about the mapserver-users mailing list