example for queryResultObj

Stephen Lime steve.lime at dnr.state.mn.us
Thu Mar 30 12:24:06 EST 2000


Attached a snippet for a area of interest search. It takes an extent and a layer
name and searches that layer. Then, a particular atttibute is pulled into a list
using the XBase module. Works great.

Steve


Stephen Lime
Internet Applications Analyst

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

>>> Phisan Santitamnont <fsvpss at eng.chula.ac.th> 03/29/00 05:43AM >>>
Dear Steve and co.,

i am looking for a search example
which should include using

'queryResultObj'

who can kindly provide me such thing.


Regards,


--
Phisan Santitamnont, Dr.-Ing.
Survey Engineering Department
Chulalongkorn University
Pathumwan Rd, Bangkok 10330
Tel. +66 (2) 218 66 61
Fax. +66 (2) 218 66 53
mailto:fsvpss at eng.chula.ac.th 
http://www.sv.eng.chula.ac.th/Staff/Phisan 



-------------- next part --------------
sub listmaps() {
  my($extent, $layername) = @_;

  my $map = new mapObj('tomo/find.map') or &error('Unable to load mapfile.');

  my $layer = $map->getLayerByName($layername) or &error('Layer not found.');
  $layer->{status} = $mapscript::MS_ON;

  my $results = $layer->queryUsingRect($map, $extent) or &error('Query 
failed.');

  my $table = '';
  my @maplist = '';
  for(my $i=0; $i<$results->{numresults}; $i++) {
    my $data = $results->next();
    
    if(!$table) {
      $table = new XBase $map->{shapepath}.'/'.$layer->{data}.'.dbf' or 
&error(XBase->errstr);
    }
    
    (my $deleted, $maplist[$i]) = $table->get_record($data->{shape}, 
'TILE_NAME');
  }

  $table->close();
  $results->free();
  undef $map;

  return(join(', ', @maplist));
}


More information about the mapserver-users mailing list