[Mapserver-users] Trouble using Perl newClass->setText( $newLayer, "hello" )
PATTERSON KENNETH ALLEN
kapatter at srpnet.com
Thu Feb 12 08:30:41 PST 2004
With humble apologies.... I do not have a problem with setText(), it works just fine. The dynamic layer works great.
I do however have a syntax bug. Whilst building this code I did not change six occurrences of $nwsClass to $newClass and did not use "use strict" (the primary failure).
If anyone spent any time on this, my deep apologies are in order.
Regretfully yours,
Ken
-----Original Message-----
From: mapserver-users-admin at lists.gis.umn.edu
[mailto:mapserver-users-admin at lists.gis.umn.edu]On Behalf Of PATTERSON
KENNETH ALLEN
Sent: Wednesday, February 11, 2004 5:02 PM
To: mapserver-users at lists.gis.umn.edu
Subject: [Mapserver-users] Trouble using Perl newClass->setText(
$newLayer, "hello" )
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