[Mapserver-users] Perl Mapscript - styleObj
Simpson, Andrew
Andrew.Simpson at ssc.nasa.gov
Tue Sep 30 13:05:54 PDT 2003
Greetings,
I am using Mapscript 4.0 on Redhat Linux to render a layer from a shapefile.
I am successfully rendering a classification of the shape using expressions.
One issue I found was Mapscript creates style[0] when a class is created,
but would not render the style without manually bumping the 'numstyles'
attribute to 1.
Now I would like to add another style to each class to render the lines with
outlines (no OVERLAY stuff available).
The code between the pod/cut below is my failed attempt to add a new style
to the class.
My question, what is the approved method to add styleObj's to a class with
Perl Mapscript, and how do you reference a particular element of the
'styles' array? It looks like PHP has getStyle and setStyle methods, but
could not find Perl version.
Thanks for any help,
Drew.
==================== BEGIN SNIPPET
================================================================
for($c=0; $c<=$#CLASS; $c++)
{
@rgb = split(/\s+/,$colors[$c]);
if ($c < $#CLASS)
{
$expr="([CONTOUR] >= $CLASS[$c] and [CONTOUR] < $CLASS[$c +
1])";
}
else
{
$expr="([CONTOUR] >= $CLASS[$c])";
}
$class->{name} = "plume contours > $CLASS[$c]";
$class->setExpression($expr);
$class->{maxscale} = 100000;
$class->{minscale} = 10;
$class->{styles}->{color}->{red} = $rgb[0];
$class->{styles}->{color}->{green} = $rgb[1];
$class->{styles}->{color}->{blue} = $rgb[2];
$class->{styles}->{symbol} = 1;
$class->{styles}->{size} = 3;
$class->{styles}->{maxsize} = 3;
$class->{styles}->{minsize} = 3;
=pod
$class->{styles} = new mapscript::styleObj();
$class->{styles}->{color}->{red} = 0;
$class->{styles}->{color}->{green} = 0;
$class->{styles}->{color}->{blue} = 0;
$class->{styles}->{symbol} = 1;
$class->{styles}->{size} = 1;
$class->{styles}->{maxsize} = 1;
$class->{styles}->{minsize} = 1;
$class->{numstyles} = 2;
=cut
$class->{label}->{type} = $mapscript::MS_BITMAP;
$class->{label}->{position} = $mapscript::MS_UC;
$class->{label}->{color}->{red} = $rgb[0];
$class->{label}->{color}->{green} = $rgb[1];
$class->{label}->{color}->{blue} = $rgb[2];
$class->{label}->{shadowcolor}->{red} = 0;
$class->{label}->{shadowcolor}->{green} = 0;
$class->{label}->{shadowcolor}->{blue} = 0;
$class->{label}->{size} = $mapscript::MS_SMALL;
if ($c < $#CLASS)
{
$class = new mapscript::classObj($layer);
$class->{numstyles} = 1; # styles will not work without
bumping this up
}
}
========================== END SNIPPET
======================================================
More information about the MapServer-users
mailing list