Dynamic Layer Creation Problem

Stephen Woodbridge woodbri at SWOODBRIDGE.COM
Sat Oct 29 20:54:17 EDT 2005


Hi all,

I know this has been covered before but I haven't been able to find 
anything that helps. I'm doing perl mapscript.

if ($line->{numpoints}) {
     warn "numpoints=$line->{numpoints}\n"; # reports 257
     my $lay = new mapscript::layerObj($map);
     $lay->{status} = 1;
     $lay->{type} = $mapscript::MS_LAYER_LINE;
     $lay->{name} = "tsp_route";

     my $class = new mapscript::classObj($lay);
     #$class->{status} = 1;   # doesn't help

     my $style = new mapscript::styleObj($class);
     # what should the value for pen be? tried 0 and 1 to no luck
     $style->{color} = new mapscript::colorObj(255,0,0,1);
     #$style->{size} = 1;    # doesn't help
     #$style->{symbol} = 1;  # doesn't help

     warn "numclasses=$lay->{numclasses}\n"; # reports 1
     warn "numstyles=$class->{numstyles}\n"; # reports 1

     my $shp = new mapscript::shapeObj($mapscript::MS_SHAPE_LINE);
     $shp->add($line);
     $shp->draw($map, $lay, $img);
}

This code is running but is not drawing the polyline, $line->{numpoints} 
= 257 points.

Yes, I know I can template this in the mapfile, but I would rather not. 
We have all these function in mapscript and it seems they should just 
work if you do the logical thing like above.

-Steve W.



More information about the mapserver-users mailing list