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

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


Hi,

>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.
Sounds good to me, but why can I change the symbol on using only ONE
class?

>Exactly, that's why you need to set the class index in the
>$point->draw() call:
Whoops. There's the missing piece of the puzzle! 

First of all I managed to draw two different colored symbols using two
static classe in my MapFile with specifying the particular class-index.
So far success. :-D

But my try to do this dynamically failed since I did'nt manage to
transfer the label-data into my new class.

What I did:
[...]
$newclass = ms_newClassObj($layer);    // create a new class
$originalclass = $layer->getClass(0);  
$newclass->set('name','new class');             
$newclass->set('type',    $originalclass->type );   
$newclass->set('status',  $originalclass->status );   // retrieve data
from previous class
$newclass->set('minscale',$originalclass->minscale ); // provide new
class with this data 
$newclass->set('maxscale',$originalclass->maxscale );
$newclass->label=$originalclass->label;               // transfer
label-information //THIS FAILES!
$style = ms_newStyleObj($newclass);
$style->color->setRGB(0, 255, 0);
$style->set ( 'symbol', $sym3 );
$pt->setXY( -4100000, 2500000 );
$pt->draw($map, $layer, $image, 1, "Pt3");            // use new class
=> index=1
$map->save('test3.map');
[...]

The output of test3.map shows:
   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
      NAME "new class"		// okay here's my new class - but no
label-data
      STYLE
          COLOR 0 255 0
        MAXSIZE 100
        MINSIZE 1
        SIZE 1
        SYMBOL 1
      END
    END
  END

So one problem solved and another one found?



>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.
Yes a example would be a great help!

TIA,

Frieso ter Haseborg
- Software Development - 
 
--

-------------------------------------------------- 
S&F Datentechnik GmbH&Co.KG 
Reimersstr. 41b 
26789 Leer, Germany




More information about the mapserver-users mailing list