Perl mapscript fetching attributes

Kralidis,Tom [Burlington] Tom.Kralidis at EC.GC.CA
Fri May 18 14:11:44 EDT 2007


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