Perl mapscript fetching attributes
Tamas Szekeres
szekerest at GMAIL.COM
Fri May 18 11:50:57 PDT 2007
Tom,
I don't think you have to call initValues. The purpose of that
function is to allocate space for the attributes of an inline feature
and clears the allocation made by the data provider previously.
Best regards,
Tamas
2007/5/18, Kralidis,Tom [Burlington] <Tom.Kralidis at ec.gc.ca>:
> Hi all,
>
> I'm using Perl mapscript to read a layer from a mapfile and I would like to have the attribute info, here's the script:
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
> use mapscript 4.10.0;
>
> my $mapfile = new mapscript::mapObj($ARGV[0]) or die "$!\n";
> my $layer = $mapfile->getLayerByName($ARGV[1]) or die "Can't get layer $ARGV[1]: $!\n";
>
> my $status = $layer->open();
>
> $status = $layer->whichShapes($layer->getExtent());
>
> while (my $shape = $layer->nextShape()) {
> $shape->initValues($shape->{numvalues});
> print $shape->getValue(2) . "\n";
> }
>
> $layer->close();
>
> ..but I can't seem to fetch the attribute information. The underlying datatype for the LAYER object is a shapefile.
>
> Any suggestions?
>
> Thanks
>
> ..Tom
>
>
>
More information about the MapServer-users
mailing list