going crazy on setting the colors of my zip polygons via perl mapscript

Sean Gillies sgillies at FRII.COM
Mon Nov 29 09:42:59 EST 2004


Everybody, do yourselves a big favor and upgrade to MapServer 4.2.5
or the 4.4 beta.  The 4.0 mapscript had some real useablity problems
and you are only making it worse by referring to ancient 3.5 and 3.6
examples!

This is how you do it (4.2+).  Add noise to translate into Perl :)

     new_class = mapscript.classObj(layer)

     # Add a style since a new class has 0 styles
     new_style = mapscript.styleObj(new_class)

     # Set the color using setRGB
     new_style.color.setRGB(255, 153, 153)

Sean

On Nov 29, 2004, at 6:06 AM, Simpson wrote:

> I think if you dynamically create your class objects you need to
> manually
> keep track of the 'numstyles' property.
> Try setting 'numstyles' to 1 like so:
>
> $class->{numstyles} = 1;
>
> Drew.
>
> -----Original Message-----
> From: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU]On
> Behalf Of Joseph Norris
> Sent: Sunday, November 28, 2004 6:48 PM
> To: MAPSERVER-USERS at LISTS.UMN.EDU
> Subject: Re: [UMN_MAPSERVER-USERS] going crazy on setting the colors of
> my zip polygons via perl mapscript
>
>
> Come on!!!! Does anyone out there set color with perl/mapscript? I can
> do a
> class->setExpression("/lkasjdfkj/") - at least I think it is working -
> no
> errors however I can not set the color so that my map reflects that the
> regex was found?  I just know that someone out there has got it to
> work.
> Please and thanks.
>
>
> #Joseph Norris (Perl - what else is there?/Linux/CGI/Mysql) print
> @c=map chr
> $_+100,(6,17,15,16,-68,-3,10,11,16,4,1,14,-68,12,1,14,8,-68,4,-3,
> -1,7,1,14,-
> 68,-26,11,15,1,12,4,-68,-22,11,14,14,5,15,-90);
>
> -----Original Message-----
> From: UMN MapServer Users List [mailto:MAPSERVER-USERS at lists.umn.edu]On
> Behalf Of Joseph Norris
> Sent: Saturday, November 27, 2004 10:03 PM
> To: MAPSERVER-USERS at lists.umn.edu
> Subject: [UMN_MAPSERVER-USERS] going crazy on setting the colors of my
> zip
> polygons via perl mapscript
>
> Group,
>
> I have found several samples of setting the color of a polygon based
> upon
> class that I come up with this:
>
>     $zip_expression =~ s/\|$//;
>     my $class = new mapscript::classObj($layerObj);
>     $class->setExpression("/$zip_expression/");
>     $class->{styles}->{color}->{red} = 255;
>     $class->{styles}->{color}->{green} = 153;
>     $class->{styles}->{color}->{blue} = 153;
>     $layerObj->draw($map, $img);
>
> However - this is not working.  I am getting the right zip codes but no
> matter what I do I can not get my mapscript to set the color based
> upon the
> expression. When I was build the map file via perl I could set these
> just
> fine but now I would like to use the perl->mapscript interface to do
> this.
>
> What is wrong with the above snippet?
>
> Thanks.
>
>
> #Joseph Norris (Perl - what else is there?/Linux/CGI/Mysql) print
> @c=map chr
> $_+100,(6,17,15,16,-68,-3,10,11,16,4,1,14,-68,12,1,14,8,-68,4,-3,
> -1,7,1,14,-
> 68,-26,11,15,1,12,4,-68,-22,11,14,14,5,15,-90);
>
>
--
Sean Gillies
sgillies at frii dot com
http://users.frii.com/sgillies



More information about the mapserver-users mailing list