[Mapserver-users] Can't locate object method "TIEHASH"

Sean Gillies sgillies at frii.com
Fri May 28 10:00:31 EDT 2004


On May 28, 2004, at 6:38 AM, Eric Bridger wrote:

> On Fri, 2004-05-28 at 05:54, Agneta Schick wrote:
>> Hello mapserver-users,
>>
>> I've searched the mail archive and found 2 messages on this topic,
>> both were, however, unanswered.
>>
>> So I'll try again...
>>
>> Platform:
>> 	MapServer 4.0.1
>> 	solaris 9
>> 	Perl 5.8.3
>>
>> I want to test an application querying shape files.
>> My perl mapscript code
>> ...
>>   $layer->queryByPoint($tmp_map,$pnt,$mapscript::MS_SINGLE,1000);
>>   my $res = $layer->getResult(0);
>>   $layer->open();
>>   my $shape=new mapscript::shapeObj($layer->{type});
>>   my $shape_index = $layer->getShape($shape,-1,$res->{shapeindex});
>>   my $table =
>> mapscript::msDBFOpen("/space/b3sn13/webdb/htdocs/ermos/data/ 
>> usgs.dbf","r+");
>> ....
>> is terminated with
>> Can't locate object method "TIEHASH" via package "_DBFHandle".
>>
>> Is this a mapscript problem or is something missing in the  
>> installation?
>>
>> (I tried the same perl script on solaris 8, mapserver 3.6.5, perl 5.6
>> and got the same error).
>
> This sounds familiar to me but I can't remember the details.
>
> The solution is to not use mapscript's DBF functions. I've never gotten
> them to work.  Use some other dbase module. I use XBase.pm
> http://search.cpan.org/~janpaz/DBD-XBase-0.241/lib/XBase.pm to do all
> dbf access of shapefiles.
>
> Eric
>

Will one of you enter this as a new MapScript-SWIG bug?  If it turns  
out that
none of us are using the msDBF* functions through mapscript, then I  
should see
about removing them from the module.

I too prefer to use XBase much of the time.

For querying, use shapeObj::getValue() to get at the attributes of  
features.
The following code

     for ($i=0; $i<$layer->{numitems}; $i++) {
         $att_name = $layer->getItem($i);
         $att_value = $shape->getValue($i);
         ...

gets attribute names and items.  It's a bit awkward that you can't get  
both from
the same object.  If you feel strongly about that, file a new feature  
enhancement
in Bugzilla.

cheers,
Sean

--
Sean Gillies
sgillies at frii dot com
http://users.frii.com/sgillies




More information about the mapserver-users mailing list