[mapserver-users] classindex

Stephen Lime steve.lime at dnr.state.mn.us
Fri Sep 14 12:42:57 PDT 2001


Yes, the draw method has changed. The old method did NOT take a class name
rather a string to be evaluated against the various class expressions. Because of
architecture changes the class to be used in rendering a feature must be known
prior to calling the draw method. The assumtion is that using mapscript that would
be handled in the scripting code. It doesn't have to be that way but I'll have to
make a few additions to the mapscript code to allow you to pass a string to have
evaluated against a number of class expressions. The method would be called
getClassIndex or something like that and would be there for layer objects.

All that said, your solution is simple. The first class you create is class 0, the second
is class 1 and so on. So from your code since all is dynamic you'd use 0 for ?????????????.

Steve

Stephen Lime
Internet Applications Analyst

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

>>> "Matt Carlson" <matt at aruke.com> 09/13/01 02:30AM >>>
i got this off of the mailing list archives for changes with mapserver 3.5.

- Draw() method of pointObj, RectObj take class_index instead
  of class_name as argument
   pointObj->Draw(map, layer, img, class_index, label_string)
   rectObj->Draw(map, layer, img, class_index, label_string)

how do i get class_index of a mapscript created class, or any class for that
matter?  i browsed through the source and the only reference to classindex i
could find was from the shapeObj.  why was this changed?

code:

###  create a layer ##
    $layer = new layerObj($map);
    $layer->{name} = "bmpl_".$bmpref;
    $layer->{type} = $mapscript::MS_POINT;
    $layer->{status} = $mapscript::MS_ON;

    ### layer classes ###

    $class = new classObj($layer);
    $class->{name} = 'bmcl_'.$bmpref;
    $symx = $map->getSymbolByName($bmpref);
    $class->{symbol} = $symx;

    @latpnts = split(/w/,$latclass{$bmpref});
    @lonpnts = split(/w/,$lonclass{$bmpref});

    ## point object ## loop through each set of points
    for ($k=0; $k<=$#latpnts ;$k++){
      $point = new pointObj();
      $point->{x} = @lonpnts[$k];
      $point->{y} = @latpnts[$k];
      $point->draw($map,$layer,$img,???????????????????????????,undef);
    }





More information about the MapServer-users mailing list