Moveclassup (Was: RE: [Mapserver-users] Rendering mapscript styl e modifications)

Wheaton, William D. wdw at rti.org
Thu Mar 18 08:46:15 EST 2004


Frank--

Thanks for your suggestion to you moveclassup().  I tried it as follows:

$layer->moveclassup(1);

But it returned this error:
Fatal error: Call to undefined function: moveclassup() in
/var/www/htdocs/els/mapscript_test.phtml on line 32

I checked the documentation, and moveclassup is clearly something that
should exist.  I'm using mapserver 4.0.

You also suggested removing the default class.  That seemed to do the trick.
So your explanation of how the classes work (default index and subsequent
class indexes) helped me understand the concept behind managing classes.
Thank you!

Back to moveclassup...Note that I searched the archives and found not a
single mention of moveclassup in the email archives.

Here's the script again:
<?PHP
 
 dl('php_mapscript.so');
 
  $map = ms_newMapObj(mapscript_test.phtml);
 
       $layer=$map->getlayerbyname('Respondents');
       $class = ms_newClassObj($layer);
 	$style = ms_newStyleObj($class);
     	$style->color->setRGB(0, 255, 0);
     	$class->set("status", MS_ON);
      $layer->moveclassup(1)
 	$layer->set("status", MS_ON);
 
       $image=$map->prepareImage();
       $layer->draw($image);
       $image=$map->draw();
 
  $image_url=$image->saveWebImage(MS_PNG,1,1,0);
 
  echo("<img src=\"$image_url\">");
  ?>

-----------------------------------------
Bill Wheaton
RTI International
P.O. 12194, 3040 Cornwallis Rd.
RTP, NC 27709
wdw at rti.org, 919-541-6158 (V), 919-541-8830 (F)
 


-----Original Message-----
From: Frank Warmerdam [mailto:warmerdam at pobox.com] 
Sent: Wednesday, March 17, 2004 5:21 PM
To: Wheaton, William D.
Cc: 'mapserver-users at lists.gis.umn.edu'
Subject: Re: [Mapserver-users] Rendering mapscript style modifications


Wheaton, William D. wrote:
> But again, the map reflects what is in the .map file, not what I've 
> changed in the mapscript code.  The mapscript code is below-- is there 
> something missing here?  Do I need to specify a symbolname, symbol 
> size etc.?  Again, the graphic that is produced shows all of the 
> layers in my .map file, including the one that is modified in 
> mapscript.  But it is ignoring the modifications I'm making in 
> mapscript for that layer.  Many thanks for your assistance!
> 
> <?PHP
> 
> dl('php_mapscript.so');
> 
>  $map = ms_newMapObj(mapscript_test.phtml);
> 
>       $layer=$map->getlayerbyname('Respondents');
>       $class = ms_newClassObj($layer);
> 	$style = ms_newStyleObj($class);
>     	$style->color->setRGB(0, 255, 0);
>     	$class->set("status", MS_ON);
> 	$layer->set("status", MS_ON);
> 
>       $image=$map->prepareImage();
>       $layer->draw($image);
>       $image=$map->draw();
> 
>  $image_url=$image->saveWebImage(MS_PNG,1,1,0);
> 
>  echo("<img src=\"$image_url\">");
>  ?>

William,

I am no expert on MapScript, but it seems to me you haven't done anything to
put your "default class" ahead of the default class loaded from the mapfile.
As far as I can tell after your changes, the layer will have two classes
(with no criteria) and so the first (from the mapfile) will always be used
in preference to your new one.  You might try switching the classes or
actively destroying the old one.

I think something like $layer->moveclassup(1) might push your new class
ahead of the original class.

Good luck,
-- 
---------------------------------------+--------------------------------
---------------------------------------+------
I set the clouds in motion - turn up   | Frank Warmerdam,
warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the mapserver-users mailing list