perl shapeobj values

Eric Bridger eric at GOMOOS.ORG
Thu Jun 2 22:24:32 EDT 2005


At 07:51 PM 06/02/2005 -0500, Simpson wrote:
>Hello,
>
>Could someone please tell me how to use the values attribute of shapeObj in
>Perl.
>I saw lots of examples in PHP, but no Perls.
>
>Thanks,
>Drew.

Here's some perl code.

if ( !$layerObj->queryByPoint( $map, $click, $mapscript::MS_MULTIPLE, 0 ) ) {
            my $rslts = $layerObj->getResults();
            if ($rslts)
            {
                for (my $i = 0; $i < $rslts->{numresults}; $i++)
                {
                    my $rslt = $layerObj->getResult($i);
                    my $qid = undef;
                    $qid = $rslt->{shapeindex};
                    my $tid = $rslt->{tileindex};
                    $layerObj->open();
                    my $qshape = $layerObj->getFeature($qid, $tid);
                    if($qshape)
                    {
                        for(my $i = 0; $i < $qshape->{numvalues}; $i++)
                        {
                            my $val = $qshape->getValue($i);
                            my $col =  $layerObj->getItem($i);
                            # do something with them.
                        }

                    }
                    $layerObj->close();
                }# end for results
            }
        } # end if queryByPoint


See also:  http://zcologia.com/mapserver/querying-howto



More information about the mapserver-users mailing list