Dynamic Layer Creation Problem
Sean Gillies
sgillies at FRII.COM
Sat Oct 29 18:02:31 PDT 2005
On Oct 29, 2005, at 6:54 PM, Stephen Woodbridge wrote:
> 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.
>
Steve,
You're neglecting to set the classindex attribute of your "shp"
shapeObj. There are other problems in your code as well, but that's
most likely the main one.
Sean
---
Sean Gillies
sgillies at frii dot com
http://zcologia.com
More information about the MapServer-users
mailing list