Mapscript - Perl - Query - shapeObj
Roberto Bianconi
roberto.bianconi at GMAIL.COM
Tue Jan 18 08:12:32 PST 2005
I think that once you query the layer, say with a $rectangle obj:
my $layer = $map->getLayerByName($layer_name);
$layer->queryByRect($map,$rectangle);
# you have the number of matches from
my $res = $layer->getNumResults();
# If your database is created as
my $dbh = new XBase "$dbfile";
# then you can do something like:
for my $r (1..$res) {
my $resultmember = $layer->getResult($r-1);
my $shaperecnum = $resultmember->{shapeindex};
# and then you get the record, with the fields as the array elements:
my @row = $dbh->get_record($shaperecnum);
}
Hope this helps.
Ciao,
Roberto
On Tue, 18 Jan 2005 15:17:28 +0100, Aaron Craig <mercutio at pobox.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> The values property in the Perl implementation of a shapeObj is a scalar
> reference.
>
> I was hoping that it would be a hashref to my database columns for the
> record returned by a layerObj->queryByPoint() call, similar to what it
> looks like PHP does.
>
> My output looks like:
>
> <snipping code>
> my $res = $lyr->getResult(0);
> my $shp = mapscript::shapeObj->new($mapscript::MS_SHAPE_POLYGON);
> $lyr->getShape($shp, $res->{tileindex}, $res->{shapeindex});
> print "values: $shp->{values}\n";
>
> values: _p_p_char=SCALAR(0xa3e7d74)
>
> In the end I need to get an id value out of the database from my query.
> ~ Is there a standard way of doing this?
>
> Thanks again for the help.
>
> - --
> Aaron Craig
> mercutio at pobox.com
More information about the MapServer-users
mailing list