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

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


Hi,

$map-output are the follows:

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


>$class = $layer->getClass(0);
>$style = ms_newStyleObj($class);
>$style->color->setRGB(...

This takes no effect either.


>$class = ms_newClassObj($layer); 
>//Here copy the properties of the original class to the new ones as in:
>$originalclass = $layer->getClass(0);
>$class->set('name',$originalclass->name); //and so on
>$style = ms_newStyleObj($class);

This way I get a new class, but the also no effect on the symbol 
//Here's the map-output:
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
        MAXSIZE 100
        MINSIZE 1
        SIZE 40
        SYMBOL 17
      END
    END
    CLASS
      STYLE
          COLOR 0 255 0
        MAXSIZE 100
        MINSIZE 1
        SIZE 1
        SYMBOL 1
      END
    END
  END

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.

Do you've a working example for this operation?

TIA,
Frieso


>-----Original Message-----
>From: Vinko Vrsalovic [mailto:vinko at cprsig.cl]
>Sent: Friday, September 26, 2003 2:06 AM
>To: Frieso ter Haseborg
>Cc: Eric Bridger; mapserver-users at lists.gis.umn.edu
>Subject: Re: [Mapserver-users] can I use different symbols in
>thesamedynamiclayer?
>
>
>On Thu, Sep 25, 2003 at 05:00:25PM +0200, 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");
>> [...]
>>
>
>Have you checked the output of $map->save()?
>
>I think your problem is here:
>
>> $class = $layer->getClass (0);    //new class instance
>> $style = $class->getStyle(0);	    //new style instance
>
>These are not _new_ instances, just the same instances as in the first
>paragraph of your code, to draw different colors in the same class, you
>must add new styles, so try this (untested):
>
>$class = $layer->getClass(0);
>$style = ms_newStyleObj($class);
>$style->color->setRGB(...
>
>If this doesn't work you could try creating different classes for
>each point:
>
>$class = ms_newClassObj($layer); 
>//Here copy the properties of the original class to the new ones as in:
>$originalclass = $layer->getClass(0);
>$class->set('name',$originalclass->name); //and so on
>$style = ms_newStyleObj($class);
>
>
>-- 
>Vinko Vrsalovic <el[|- at -|]vinko.cl>
>http://www.cprsig.cl
>
>




More information about the mapserver-users mailing list