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

Sean Gillies sgillies at frii.com
Thu Mar 18 06:41:20 PST 2004


Bill,

If you set the expression of the default class in your map file, and
leave the expression of the new class undefined, the new class will
become the default and there will be no need to move it.

layer.classitem = 'ATTRIBUTE1'    # Name of column in your respondants  
table
layer.getClass(0).setExpression('FOO') or something like that.

This is the best practice rather than moving classes around.

cheers,
Sean

On Mar 18, 2004, at 6:46 AM, Wheaton, William D. wrote:

> 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
> _______________________________________________
> 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