Python Mapscript QueryByPoint
Eric Bridger
eric at GOMOOS.ORG
Wed Mar 9 08:23:55 PST 2005
On Wed, 2005-03-09 at 09:56, Sean Gillies wrote:
> Jon,
>
> Check the querying howto under mapscript/doc. I am hosting an HTML
> version of the same doc at
>
>
> http://users.frii.com/sgillies/projects/mapscript/querying-HOWTO.html
>
> cheers,
> Sean
>
Sean's guide was a big help to me, though a little sparse on some of the
finer details, in particular on how to get the field names as well as
the values.
So here's some Perl code: (only tested with shape files and PostGIS
layers)
$layer->open();
my $shape = $layer->getFeature($qid, $tid);
if($shape)
{
for(my $i = 0; $i < $shape->{numvalues}; $i++)
{
my $val = $shape->getValue($i);
my $name = $layer->getItem($i);
print "$name = $val\n";
}
}
$data_layer->close();
HTH
Eric
P.S. the tile index is used in the getFeature call, but if you are not
using tiled shape files it is probably not needed. I'm not sure.
More information about the MapServer-users
mailing list