[Mapserver-users] Trouble using Perl newClass->setText( $newLayer, "hello" )
PATTERSON KENNETH ALLEN
kapatter at srpnet.com
Wed Feb 11 16:01:43 PST 2004
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 );
}
More information about the MapServer-users
mailing list