[Mapserver-users] Trouble using Perl newClass->setText( $newLayer, "hello" )
Lowell Filak
lfilak at medinaco.org
Thu Feb 12 13:35:35 PST 2004
I don't know how far it will go but, do you have logging turned on and
is there anything in the log?
I noticed that there is an msResetErrorList() in mapfile.c under the
loadExpressionString function that is used to load the string value into
the classObj but I don't see anything printed if it segfaults in the
function.?
Also, did you already check to see if it is segfaulting on the
$newClass->{label} = ... for some reason after the text is set?
Lowell
The following message was sent by "PATTERSON KENNETH ALLEN"
<kapatter at srpnet.com> on Wed, 11 Feb 2004 17:01:43 -0700.
>
> I am creating a layer on the fly with one class. I am able to create
the map successfully w/out using setText(). The symbols in the layer
shows up fine. As soon as I call $newClass->setText( $newLayer,
"hello" ) to display a field/value it segfaults. My code snippet is
below. Can anyone advise what I am doing wrong?
>
> Thanks,
> Ken
>
> # ------------------------------------------- CreateALayer
---------------------------------------------
> sub CreateALayer {
> my ($msObj, $shapeFName) = @_;
>
> if ($msObj && $shapeFName) {
> my $newLayer = new mapscript::layerObj( $msObj );
> if ($newLayer) {
> print "\t\tNew Layer $newLayer created, setting values.\n";
> $newLayer->{name} = "WindData";
> $newLayer->{group} = "Dynamic Layer";
> $newLayer->{template} = "dummy-template-name";
> $newLayer->{status} = $mapscript::MS_ON;
> $newLayer->{data} = $shapeFName;
> $newLayer->{type} = $mapscript::MS_POINT;
>
> my $newClass = new mapscript::classObj( $newLayer );
> if ($newClass) {
> print "\t\tCreated Class object $newClass, setting values\n";
> $newClass->{name} = "Wind Gust";
> $newClass->{status} = $mapscript::MS_ON;
> $newClass->setExpression( "(\"[WGUST]\" ne \"\")" );
> $newClass->{color} = $msObj->addColor( 255, 0, 0 );
> $newClass->{symbol} = 1;
> $newClass->{minscale} = 100;
> $newClass->{maxscale} = 800000;
> $newClass->{size} = 8;
>
>
> $newClass->setText( $newLayer, "([WGUST])" ); # This causes a
segfault!
>
>
> $newClass->{label} = new mapscript::labelObj();
>
> if ($newClass->{label}) {
> print "\t\tNew Lable object $newClass->{label} created!\n";
> $newClass->{label}->{backgroundcolor} = $msObj->addColor( 80, 80,
80 );
> $newClass->{label}->{color} = $msObj->addColor( 255, 200, 0 );
> $newClass->{label}->{size} = 8;
> $nwsClass->{label}->{type} = $mapscript::MS_TRUETYPE;
> $nwsClass->{label}->{font} = "helmetBI";
> $nwsClass->{label}->{position} = $mapscript::MS_AUTO;
> $nwsClass->{label}->{partials} = $mapscript::MS_FALSE;
> $nwsClass->{label}->{minsize} = 6;
> $nwsClass->{label}->{maxsize} = 12;
>
> } else {
> print "\t\tError: Unable to create lable object!\n";
> return( 0 );
> }
>
>
> return( 1 );
>
> } else {
> print "\t\tError: Unable to create class object!\n";
> return( 0 );
> }
> } else {
> print "\t\tError: Unable to create layer object!\n";
> return( 0 );
> }
>
> }
>
> return( 0 );
> }
>
>
>
>
> _______________________________________________
> 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